cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to keep Y-axis static in column chart widget

MainYguy
7 - Data Storage
7 - Data Storage

Greetings,

My clients are using a dashboard featuring a column chart widget, displaying gross income across several categories.

Example1.jpg

 They can deactivate or reactivate one of these categories, on the bottom of the chart. When deactivating the first category, it will look like this :

Example2.jpg

We can see that the scales on the Y-axis readapted to the current display (from 35k to 25k on the top left).
However, my clients wish for it not to readapt, and remain at the highest value (in this case, 35k) in order to get a more intuitive understanding of the situation when they add or remove categories.

I tried to use the min and max values in the widget customisation, as well as to use a JS script that would try to set these values in stone, as I saw earlier in this forum.

widget.on('beforeviewloaded', function(widget, args){

var newmaxCharactersPerLabel = 25; //Set length of the line length
args.options.xAxis.labels.useHTML = true;
args.options.xAxis.labels.rotation = -90; //Label Rotation
args.options.xAxis.labels.formatter = function(){
this.value = '<b>'+this.value+'</b>';
return this.value;
}
})

widget.on('ready', function(se, ev){

$(element).css('background-color','#F0A9A3'); //changes the widget's background
$('widget-header' ,element.parent()).css('background-color','AF0A9A3'); //changes the widget's title background
var e = element;
var chart = e.data('hc');

/*Change the Y Axis Scale and Interval*/

chart.yAxis[0].alignTicks =false;
chart.yAxis[0].update({tickInterval:1000, max:300000, min: 0}, true);


/*Change the Secondary Y Axis Scale and Interval*/

chart.yAxis[1].alignTicks =false;
chart.yAxis[1].update({tickInterval:0.005, max:0.08, min: 0.02}, true);
})

Both solutions work when I load the dashboard, but as soon as I test to activate/deactivate a category, these modifications seem to get overriden, and the Y-axis adapts to the new values displayed, ignoring the script.

Do you see a workaround this feature, by any chance ?

Thanks in advance.

Y

0 REPLIES 0