-
December 2nd, 2012, 09:43 PM
#1
.NET 2010 Chart control scrolling issue
G'day Guys,
I have an issue with the auto scrolling of the chart control my code displays the speed of a machine over a set period of time. This starts by expanding the X axis out to represent the timespan which is in the settings, at this point the graph moves along deleting the first point and adding a new point.
The problem is that when the time span is up it seems to be added the point but not displaying it and at the same time deleting the oldest data but the graph isn't scrolling along. This worked fine till I changed the Datatimeintervaltype to minutes and the chartvaluetype to time. Below is an image of what it is currently looking like after it reaches the set time period
Attachment 30705
The Code relating to this is as follows:
Code:
If Me.Histograph_time_in_mins <= 20 Then
With Chart1.ChartAreas("ChartArea1")
.AxisX.IntervalType = DataVisualization.Charting.DateTimeIntervalType.Minutes
.AxisX.LabelStyle.Interval = 1
.AxisX.LabelStyle.Format = "mm:ss"
End With
ElseIf 120 <= Me.Histograph_time_in_mins Then
With Chart1.ChartAreas("ChartArea1")
.AxisX.IntervalType = DataVisualization.Charting.DateTimeIntervalType.Minutes
.AxisX.LabelStyle.Interval = 15
.AxisX.LabelStyle.Format = "hh:mm"
End With
ElseIf 3600 < Me.Histograph_time_in_mins Then
With Chart1.ChartAreas("ChartArea1")
.AxisX.IntervalType = DataVisualization.Charting.DateTimeIntervalType.Minutes
.AxisX.LabelStyle.Interval = 30
.AxisX.LabelStyle.Format = "hh:mm"
End With
ElseIf 21600 < Me.Histograph_time_in_mins Then
With Chart1.ChartAreas("ChartArea1")
.AxisX.IntervalType = DataVisualization.Charting.DateTimeIntervalType.Hours
.AxisX.LabelStyle.Interval = 1
.AxisX.LabelStyle.Format = "hh"
End With
ElseIf 43200 > Me.Histograph_time_in_mins Then
With Chart1.ChartAreas("ChartArea1")
.AxisX.IntervalType = DataVisualization.Charting.DateTimeIntervalType.Hours
.AxisX.LabelStyle.Interval = 6
.AxisX.LabelStyle.Format = "hh"
End With
End If
scroll_enable_counter = scroll_enable_counter + 1
If scroll_enable_counter > FormatNumber((Me.Histograph_time_in_mins * 60) / (Timer1.Interval / 1000), 0) Then
Chart1.Series("Line_Speed").Points.RemoveAt(0)
Chart1.Series("Required_speed").Points.RemoveAt(0)
End If
TextBox12.Text = FormatNumber((Me.Histograph_time_in_mins * 60) / (Timer1.Interval / 1000), 0)
TextBox11.Text = Chart1.Series("Line_Speed").Points.Count
Chart1.ChartAreas("ChartArea1").AxisX.ScrollBar.Enabled = True
Chart1.Series("Line_Speed").Points.AddXY(DateTime.Now, TextBox1.Text)
Chart1.Series("Required_speed").Points.AddXY(DateTime.Now, TextBox2.Text)
End Sub
If anyone can suggest away around this problem that would be great. I want to use the
Code:
DateTimeIntervalType
as this allows for the labels to sit on the minutes, hour, day etc..
Cheers,
Robbo99
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
|