Pentaho

 View Only

 100% stacked bar click action

  • Pentaho
  • Ctools
  • Pentaho
Andy Rathbone's profile image
Andy Rathbone posted 09-13-2018 14:30

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


#Ctools
#Pentaho
Duarte Cunha Leao's profile image
Duarte Cunha Leao

Try configuring the chart in this way instead:

function a() {     var d = this.chartDefinition;   d.crosstabMode = false;   d.seriesInRows = false;   d.readers = ['series', 'value', 'code'];   d.clickable = true;   d.clickAction: function(scene) {     alert(scene.firstAtoms.code.value);   }; }

Cheers

Andy Rathbone's profile image
Andy Rathbone

Perfect, thanks.