AnsweredAssumed Answered

100% stacked bar click action

Question asked by Andy Rathbone on Sep 13, 2018
Latest reply on Sep 13, 2018 by Andy Rathbone

Hi,

 

I am putting together a dashboard with a 100% stacked bar.  It is a single bar with three categories.

My data is quite simple and looks like the below.

 

Type     Value     ID

A          123          1

B          456          2

C          789          3

 

I can get the chart to display exactly as I want using the below code.

 

function a(){
    var d = this.chartDefinition;
    
    var columns = {
        'A': true, 
        'B': true, 
        'C': true};

     $.extend(d, {
        seriesInRows: true,
        valuesVisible: true,
        valuesOptimizeLegibility: true,
        plotFrameVisible: false,
        baseAxisVisible: false,
        orthoAxisVisible: false,
        legendPosition: 'right',
        valuesMask: '{value.percent}',
        colors: ['#00B0F0', '#808080', '#000000'],
        barSizeMax: 75,
    });
    
     d.dataWhere = function(cda) {
          if(cda.atoms.category.value == 'Type'){
            return columns[cda.atoms.series.value]; 
        }
    };
} 

 

What I am trying to do next is set up the click action for the chart. When the users clicks on the chart, it will take the value from the ID field and pass it into a parameter.  However, I can't get the ID form anywhere.

I have tried using the following code insted, but that does not work either.

 

function f() {
     this.chartDefinition.readers = [
          {names:’category’, indexes: 0},
          {names: ‘value’, indexes: 1},
          {indexs: 2}
     ];
}

 

Any help would be hugely apreciated as this is really frustrating me now.

 

Thank you

Andy

Outcomes