ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Axis labels and time format with fractions of seconds
Posted by Todd on Sep-29-2011 04:03
I'm trying to implement a graph where our data needs to be displayed as hours:minutes:seconds where seconds can have 2 or more decimal places.  Such as 11:59:30.05.

I've been struggling to find a solution, here is what I have tried so far, with comments on why they don't quite work.

// 00:01:51.05 becomes 00:01:51.5 (no zero padding)
chart.xAxis().setLabelFormat("{value|hh:nn:ss}.{={value}*100%100|0}");

// 00:01:51.05 becomes 00:01:51.15 (0.5 is rounded to 1 instead of truncated to 0)
chart.xAxis().setLabelFormat("{value|hh:nn:ss}.{={value}*10%10|0}{={value}*100%10|0}");

// 00:01:51.1 becomes 00:01:51.1-1 (0 -> -0.5 -> -1)
chart.xAxis().setLabelFormat("{value|hh:nn:ss}.{={value}*10%10-0.5|0}{={value}*100%10-0.5|0}");

  Re: Axis labels and time format with fractions of seconds
Posted by Peter Kwan on Sep-30-2011 01:17
Hi Todd,

I think there are quite a few "suggestions" in the forum (many of them are from me), but I eventually found most of them do not work in all cases. I do find a method that work, it is:

{value|hh:nn:}{={value}%60-0.004999999999|2}

Basically, the above displays the "exact seconds" in two decimal places. However, the default method used by ChartDirector is rounding (which means 58.739 will be displayed as 58.74). However, in date/time, it is customary to use truncation (that is, 58.739 should be displayed as 58.73). So it is necessary to subtract 0.004999999999 to change the rounding into truncation.

If your raw data only contains 2 decimal places (that is, there will not be any data with value like 58.739), then you can omit the -0.004999999999 part.

Hope this can help.

Regards
Peter Kwan