Jump to content
Software FX Community

Issue adding basic chart X/Y data (slows down as it loads...)


Plink
 Share

Recommended Posts

I am adding data to a chart. Number with a datestamp. Every series will have about 100 points, and there could be thousands of series on one graph. My issue (the current way I'm doing it) ... as the graph loads all my data (I'm inputting using chart1.data.Y(i,i)...and chart1.data.X(i2,i2)...) the loading process takes longer and longer for each series I add. Presumably because the chart is reloading and refreshing the graph display every time I add the next series. I would like it to only do a graph refresh AFTER all the loading is done. This way the load will take a much shorter time.

 Do you have a function that simply turns off the graphs 'draw' ability. (so I could disable it before I start loading, and then re-enable after?) Or something similair?

Can I get some help on how to do this?

 thanks!

Link to comment
Share on other sites

Like most WindowsForm controls, painting only occurs when the message queue is proceessed, that is when the UI thread is "idle". Multiple serialized calls to multiple APIs, in the same thread, will NOT generate multiple re-paints.

You need to measure whether the time is being spent setting the data or draing it by measuring the time spent from when you start setting the data to when you finish. This time is not related to the Paint time. You can either use a profiler or some good-old time APIs like System.Diagnostics.StopWatch.

Paint time is harder to measure because painting is not started by your (user) code but by the WM_PAINT event sent by Windows. The PrePaint and PostPaint event mayu help you measure this time.

The approach for improving these is very different:

For the first case, the performance can be improved by either improving the speed at which your data is retrieved or by minimizing the time Chart FX takes to process it. The only think here that Chart FX does that can have an inpact in the performance is the reallocation of memory. This can be dramatically improved by simply telling the chart how many series and points are there going to be in the chart in advance.

 Improving painting time will involve some compromises on how the chart looks. Some graphics elements like circles and lines are inherently slower than others like rectangles. Reducing the number of graphics elements drawn, like borders, etc will also have a big impact.

Link to comment
Share on other sites

Yeah, I understand what you are saying. I guess I just need some advice on the best way I should go about entering in data to my graph. I am only able to access one 'series' at a time, and when I load this series into memory I do it on a background thread, that in turn passes the data to the graph on the UI thread. When its done, the UI thread is refreshing the graph. The problem is... this refresh takes far too long. (not really anyones fault)...

 (So in other words, the graph is being redrawn by the UI thread after every series is added. Thus the more series I have the longer it takes to update. I simply want to stop the UI thread from doing this. Is it possible to add all the points and series to the graph FROM the background thread?)

 So I'm wondering what I should be doing to maybe que all the series up in one data bundle, and then update(draw) the graph all at once? Any suggestions?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...