|
-
Nov 21st, 2012, 12:31 AM
#1
Thread Starter
Member
Updating a charts points during runtime
Hi guys,
Big thanks to everyone who has helped me over the past couple of weeks.
I am currently creating a line graph in one form using an array that I have stored in a module, the array is configured in another form. As a value is added to the array I would like the graph to recognize this and plot the new point.
To make this clearer, on a click event a number is stored in the array, that array is then used by the chart. The chart then plots the new point in front of the user.
Below is my code and in bold is how I am using my array with the chart.
Code:
With RChart.ChartAreas(0)
.AxisX.Minimum = 1
.AxisX.Maximum = 10
.AxisY.Minimum = 0
.AxisY.Maximum = 30
.AxisY.Interval = 10
.AxisX.Title = "Samples"
.AxisY.Title = "Range"
End With
RChart.Series("Range").MarkerStyle = MarkerStyle.Circle
RChart.Series("Range").MarkerColor = Color.Black
RChart.Series("Range").MarkerSize = 5
RChart.Series("Range").ChartType = DataVisualization.Charting.SeriesChartType.Line
RChart.Series("Range").Points.DataBindXY(pNumofSamples, pRange2)
So far I have tried:
Looping through the above code until the form is closed with application.doEvents() - this didn't work.
Calling a procedure that did the same as above, Setting a timer to iterate through the above code. For these I get the error "Enumeration already finished." Pointing to ----> RChart.Series("Range").Points.DataBindXY(pNumofSamples, pRange2)
I have also tried multi-threading, using Me.CheckForIllegalCrossThreadCalls = False.. This also failed. I have had a search across the forum and can't seem to find a solution. I have read a bit about delegates and this could be a possible solution, however I'm wondering if anyone knows where I am going wrong or a way to solve my problem?
Again, appreciate the help.
Cheers.
-
Nov 21st, 2012, 01:00 PM
#2
Re: Updating a charts points during runtime
Try releasing the binding and reapplying it. Also where do pNumofSamples, pRange2 get set? If they do not change then you will indeed get the enumeration finished error (been there, done that, in other words!)
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Nov 21st, 2012, 06:28 PM
#3
Thread Starter
Member
Re: Updating a charts points during runtime
 Originally Posted by dunfiddlin
Try releasing the binding and reapplying it. Also where do pNumofSamples, pRange2 get set? If they do not change then you will indeed get the enumeration finished error (been there, done that, in other words!)
How would I go about releasing the binding, I have tried creating a sub that runs on each click event but after the data is stored in the arrays that are used to plot the data.
Code:
Sub refreshChart()
If ControlCharts.Created = True Then
ControlCharts.RChart.DataBindings.Clear()
ControlCharts.RChart.Series("Range").Points.DataBindXY(totalSamples, pRanges)
End If
I still get the same error "Enumeration already finished." The arrays definitely changes, they are set in the main form. They will contrain one new number each time the sub is called.. Any Ideas ?
-
Nov 22nd, 2012, 03:44 PM
#4
Thread Starter
Member
Re: Updating a charts points during runtime
Hi just a quick update,
I have the above working somewhat. What I have done is put the charts on the main form (they were on a separate form using arrays from the main form). From there I loaded the charts in form load, basically the code in my first post except I used RChart.Series("Range").Points.DataBindY pRange) As the chart doesn't need the X axis if its just a the number of the sample.. it can keep track of that pretty well..
From here, on the click event mentioned above that assigns a value into the array pRanges, I simply use RChart.Series("Range").Points.DataBindY pRange) again. No clearing of the data binding needed/Releasing. This was essentially what I first tried to do when I had the charts in a separate form. So its not exactly a proper fix as it wasn't what I initially wanted, but will suffice. Hopefully this helps anyone else with a similar problem.
Tags for this Thread
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
|