Pentaho

 View Only

 Replace base axis text with image

  • Pentaho
  • Ctools
  • Pentaho
Andy Rathbone's profile image
Andy Rathbone posted 08-06-2019 14:29

Hi,

I am a little stuck with a horizontal bar chart I am creating.  I need to replace the base axis text with an image but it is not working.

function a() {

var d = this.chartDefinition; d.orientation = 'horizontal'; d.plotFrameVisible = false;d.baseAxisLabel_text = function(a){ var str = a.atoms.category.label; if(str == 'Email'){return '<img id="logo" src=" https://reporting.mbc-posinfocentre.com/pentaho/api/repos/:public:MercedesReporting:reference:images:logo-mb.png/content" style="width:50px">'; } };}

Any help would be great.


#Ctools
#Pentaho
Joana Carvalho's profile image
Joana Carvalho

First you need to add the image that you want on the baseAxisLabel, then you control its visibility by using visible attribute.

d.baseAxisLabel_add = function(event){

return new pv.Image()

.width(30).height(30) // comment for "stretch" effect .fillStyle("#def") .visible(function(event){ var str = event.atoms.category.label;console.log(str); if(str === 'Email'){ return true;} return false;}) .url(" http://vis.stanford.edu/protovis/ex/stanford.png"); }

Afterwards, you need to control the text displayed on the baseAxisLabel

d.baseAxisLabel_text = function(a){

var str = a.atoms.category.label;

if(str == 'Email'){

return '';}

return str;

};

I hope that this helps.

Thanks,

Joana