|
-
March 13th, 2012, 09:41 PM
#1
Chart Control Axis Label
Hello All,
I had a question regarding an issue I've been having that's driving me crazy. I basically have a line graph chart control and a timer loop that updates the content every "x" seconds. I only record 200 data points and remove previous data points so that there is a fixed number (200) of data displayed on the graph.
My issue is as follows: The x-axis is basically a time stamp. As new data is entered, the x-axis labels are updated. However, the labels move with the graph, and for the duration of the application's run time there is an annoying sideways moving of the x-axis labels from right to left.
Is it possible to pin the x-axis labels to the plot area so there will constantly be, for example, five labels and the text is simply updated along with the data? Any assistance is greatly appreciated.
Thank you,
HSidky
-
March 14th, 2012, 09:19 AM
#2
Re: Chart Control Axis Label
I'm not sure you can have the tick marks and labels fixed without having some calculations done inbetween and changing you Axis settings. You can have a fixed number of labels, and if the time span of the chart is constant, it might not move at all... I'm not sure.
I'd suggest to at least set a fixed interval for your X Axis so that you will have constant spacing.
Here are some chart setting pointers that might be useful for you:
Code:
localChartArea.CursorX.Interval = 1;
localChartArea.CursorX.IntervalType = DateTimeIntervalType.Minutes;
localChartArea.CursorX.IsUserEnabled = true;
localChartArea.CursorX.IsUserSelectionEnabled = true;
localChartArea.CursorX.SelectionColor = Color.LightBlue;
localChartArea.AxisX.MinorGrid.Enabled = false;
localChartArea.AxisX.MajorGrid.Enabled = true;
localChartArea.AxisX.MinorTickMark.Enabled = true;
localChartArea.AxisX.LabelStyle.Format = "dd. HH:mm"; // day. 24Hour:minutes
localChartArea.AxisX.LabelStyle.Interval = 0; // Automatic
localChartArea.AxisX.LabelStyle.IntervalType = DateTimeIntervalType.Minutes;
localChartArea.AxisX.Interval = 0; // Automatic
localChartArea.AxisX.IntervalType = DateTimeIntervalType.Hours;
localChartArea.AxisX.IntervalOffsetType = DateTimeIntervalType.Minutes;
You can change the 'Interval' values to something other than 0 and test how it works.
Take into account that MSCharts can't handle DateTime and TimeSpan variables. What they use is the OADate version of them. It's a bit confusing sometimes when you start adding and substracting dates to get your min/max scale values, so keep track of what you do.
Code:
double nowAsOADate = DateTime.Now.ToOADate();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|