15,936,897 members
See more: , +
I'm plotting a graph using PictureBox. To fit all the points in the control width, I'm using normal averaging technique. I want to understand is this the only way to do so, or there's any other formula.

I feel like loosing the data trend (I can visualize that when I've large number of points to be plotted in small area) with this technique.

Can anyone share me the pointers for further research, such as which data reduction/compression/calculation technique I can use, so that I can fit 50K of data points in 100 pixel control without loosing the data trend.

What I have tried:

Normal averaging method.

To explain it better, lets say I've to plot 1000 values on the PictureBox of width 100 Pixels. I calculate the ratio of count of values to be plotted to the PictureBox width, i.e 1000/100 = 10. That means, each pixel on the graph will represent the average of 10 value. With this I plot the graph of average of every 10 values resulting to show average of 1000 values on the PictureBox. This works fine with small set of data points.
Posted
[no name] 29-Jan-23 14:49pm
You make the "actual" scrollable. Host it in a WPF ScrollViewer; which can also zoom.
TejasviniMK 30-Jan-23 12:51pm
Can't use scrollable solution as need to display/fit the entire graph in a single view. That's the base requirement.
[no name] 30-Jan-23 14:15pm
If it's a straight line, fine; you just need the end points. More detail, you'll have to figure out the number of highs and lows "to keep" (trending); if you want to fit in 100x100.

## Solution 1

Consider this algorithm Implementation Downsampling Algorithm in MSChart Extension[^] to plot large data size without loosing details of trends and performance impact.