Click here to Skip to main content
15,888,022 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to show data on Chart (Windows Forms, VS2010, C++, .NET) with axisX labels showing it's x-value with milliseconds.
Using X-data type: DateTime.
I set chart properties to
C++
chartArea1->AxisX->LabelStyle->Format = L"HH:mm:ss.fffffff";

C++
chartArea1->AxisX->LabelStyle->IntervalType = System::Windows::Forms::DataVisualization::Charting::DateTimeIntervalType::Milliseconds;

I'm adding milliseconds to DateTime structure like
C++
dt = dt->AddMilliseconds(1345768.0);

so by
C++
dt->ToString("HH:mm:ss.fffffff")

i'm seeing a correct "00:22:25.7680000" value
and chart displays several points correctly separated according to milliseconds value.
But the axisX labels show x-value like this "00:22:25.0000000" that are the values of segments.

What else should I do to make chart show labels correctly with milliseconds??? Maybe more segments of axisX?

UPDATE:
I found the solution of the interval problev (see sol.1 to this question) but there appear another one problem!
Now I have labels every 250ms as AxisX->Interval is set to 250
C++
chartArea1->AxisX->Interval = 250;

but labels appear only on round values like 22:25.000 - 22:25.250 - 22:25.500 - 22:25.750
Though my axisX minimum and maximum are dynamically changed and start from not round value that leads to labels moving.

What I need is 5 or 6 labels on X axis in same places: one at the start, one at the end, and 3-4 in the middle.
How to???
Posted
Updated 6-Jul-15 2:31am
v5

1 solution

Well, I made a clear task and found a solution =))
The point is that the chart displays axisX labels for its segments only, not for each point (though it is possible to make label for each point).
So, simply by setting interval to not Auto value
chartArea1->AxisX->Interval = 250;

it makes axisX labels to be every 250 milliseconds, so I got labels like
00:22:25.0000000 00:22:25.2500000 00:22:25.5000000 etc...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900