Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Chart Label Format
GaidenFocus
<p>I am creating a chart that deals with hours and minutes. I have converted the times to int which returns the overall minutes.</p>
<p> </p>
<p>On the chart labels, instead of displaying the total minutes I would like to format it as Hour:Minutes which would be something like:</p>
<p> </p>
<p></p><pre class="_prettyXprint _linenums:0">SQL Command
CONVERT(INT, LEFT(time_stamp, 2)) / 60 + CONVERT(INT, LEFT(time_stamp, 2)) % 60
Javascript
row["time_stamp"] / 60 + ":" + row["time_stamp"] % 60
</pre>
<p> </p>
<p>I'm not sure where to put that, since it is summing these together based on timespan selection. Have any of you done something like this in the past?</p>
Find more posts tagged with
Comments
mwilliams
In the chart script's beforeDrawAxisLabel function, you could grab the axis label, do your computation, then set the label text to the new value.
GaidenFocus
<p>Ok I'll check that out. Do you know the commands? My thing is that I know what must be done, just no idea what the functions are called.</p>
mwilliams
To just change the labels, all you'd need to do is put this script in your chart script area:<br> <br><pre class="_prettyXprint _lang-auto _linenums:0">function beforeDrawAxisLabel( axis, label, icsc )
{
if(axis.getOrientation() == "Horizontal"){
oldVal = parseInt(label.getCaption().getValue());
newVal = Math.floor(oldVal/60) + ":" + oldVal%60;
label.getCaption().setValue(newVal);
}
}
</pre>
GaidenFocus
<p>Sorry, I must be using the wrong terminology. I have a label on the actual bar showing the value. Not the label on the bottom, those need to stay the same. The value on the bar displays the hours, I need it to be accurate down to the minute.</p>
mwilliams
Ah. My mistake. I just assumed incorrectly. You'd just need to do a similar thing for the beforeDrawDataPointLabel script. Let me know if you need help with it, but it'll be VERY similar.