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

Message ListMessage List     Post MessagePost Message

  Issue with time format with decimals
Posted by Todd on Dec-05-2012 03:51
We use time as our x-asix as a MM:SS.DD format.  Because this format isn't directly supported I used a suggestion from these forums to come up with this format string.

chart.xAxis().setLabelFormat("{value|nn}:{={value}%60/10-0.4999999999|0}{={value}%60%10-0.004999999999|2}");

This seems to work most of the time, but occasionally I see this:

8:28.00, 8:29.00, 8:310.00, 8:31.00, 8:32.00

Note the 8:310.00 which is where 8.30.00 should be.  This happens at specific numbers, such as 510 (8:30).

What seems to be happening is the second part {={value}%60%10-0.004999999999|2} is returning 10.00 when I would expect it to return 0.00.

Any suggestions on how to resolve this would be greatly appreciated.

Below is a code example that reproduces the problem.  I'm running on win7 with the .NET version of the control.



ChartDirector.XYChart chart = new ChartDirector.XYChart(1135, 360);
chart.setPlotArea(45, 35, 1055, 290, -1, -1, 0x00cc00, -1, -1);

int start = 500;
double[] data = { 1,2,1,3,2,3,2,4,3,4,3,5,4,5,4,6,5,6,5,7 };

chart.xAxis().setLinearScale(start, start + data.Count());
chart.xAxis().setLabelFormat("{value|nn}:{={value}%60/10-0.4999999999|0}{={value}%60%10-0.004999999999|2} [{value}]");

List<double> xData = new List<double>();
for (int i = 0; i < data.Length; i++)
    xData.Add(i + start);

chart.addLineLayer(data, 0x0000ff, "Values").setXData(xData.ToArray());

winChartViewer1.Chart = chart;

  Re: Issue with time format with decimals
Posted by Peter Kwan on Dec-05-2012 23:47
Hi Todd,

The sub-second format is already support in ChartDirector 5.1. It is:

{value|nn:ss.ff}

Hope this can help.

Regards
Peter Kwan