Hi,
I have a sales revenue chart with values in millions that currently display as QAR 1,000,000, QAR 2,000,000 etc. with incremental step of one million. The problem is it’s taking too much space from the chart width to display all those zeros on the y-axis, so i wonder if there’s a way to format values so that they display like QAR 1M, QAR 2M, etc. instead.
Thanks
Hi,
Put the following code into Dashboard -> Advanced tab.
window.FormatLongNumber = function(value) {
if(value == 0) {
return 0;
}
else
{
// hundreds
if(value <= 999){
return value;
}
// thousands
else if(value >= 1000 && value <= 999999){
return (value / 1000) + 'K';
}
// millions
else if(value >= 1000000 && value <= 999999999){
return (value / 1000000) + 'M';
}
// billions
else if(value >= 1000000000 && value <= 999999999999){
return (value / 1000000000) + 'B';
}
else
return value;
}
}
Then, set the template property of the appropriate axis in:
#= FormatLongNumber(value) #
Thanks a lot, works fine.
I wonder how would i do the same thing for a linear gauge, i tried the same code for one linear gauge chart, however it didn’t work out.
A Linear gauge displays a single value. So, how do you want to bind a drop-down to a linear gauge? Do you want to visualize a field value of the selected item?
I have a vertical linear gauge showing the actual sales vs target, where the ranges represent the target and the green bar indicating the actual sales as opposed to the target ranges. and values of the ranges are all in millions with 6 zeros, so i want the values to read M instead of 6 zeros likewise i did for other charts.
Hi,
define the same function (FormatLongNumber)
and insert the following code into preRender handler in Dashboard -> Advanced tab:
config.scale.labels.template = '#= FormatLongNumber(value) #';
Thanks a lot, works fine.