I am currently working on a windows forms application that has several modules. One of them is responsible for drawing generated simulation data. The idea of the plot is actually simple, but i am struggling to render the data efficiently.
So the questions i have are:
- what is the best way to draw such a large amount of data?
- is drawing on a bitmap the right option?
- am i missing a basic .net framework or so that provides me with this functionality?
The points to draw are provided as a list points in the form of (time, position), i.e. we have two axis.
I tried the following:
I tried drawing the points of all elevators all at once --> is resource intensive and the whole plot is redrawn on resize events. made two tests:
- draw the whole plot within a predefined viewport, but was not a good idea because the graph becomes messy.
- defined how many pixels for the time and position (e.g. 1 second = 1 pixel) and made the panel (picturebox inside it) scrollable. this worked better than the first option, but causes an outofmemory exception if the data is too large.
other possible approaches:
define a range for the drawing (e.g. timeRange = 10 mins) and let only that get painted. i imagine a problem with the scrolling, because i would have to redefine the starting point of the drawing (there where the range startpoint is) when the user scrolls.
I would appreciate your help a lot and any suggestions, ideas, comments...etc.
Edit:
I tried the suggestions of Patrick and TaW regarding using MS Chart. Indeed it is a better and easier option as it is better programmed as my version so far. Though, i provided it of several series of data and i still suffer from performance issues. Namely, i have the following problems:
- it takes around a minitue to draw the data
- when zoomed-in (by enabling the corresponding properties, shown here and the hint found here), scrolling becomes slow. It would be great if it could kinda flow or so...
- i am not able to or don't know how to zoom-out!
Referring to the comment of TaW (see below) regarding the missing information about what i mean with large data - The simulation data to be drawn represent a time period of hours (e.g. 2-3 hours) and the should be viewable in intervals of 60s.
My Main Problem is the performance of the chart!
Some diagnostic data that may help (used stopwatch to measure the DrawChart methode incl. its internal steps):
- chart1.Series.Clear() took: 00:00:00
- filling the chart1.Series.Add(...data..) took: 00:00:03.8230000
- configuring the chart1 took: 00:00:03.8240000
- plotView.DrawChart(points) took: 00:00:03.8290000
That tells me that the drawing in the chart-module is what takes so long...
Thanks for your help and time.