开发者

How to chart graph with many points on small graph

I have 100 000 x/y points (altitude over distance) to chart on a graph with height 400px and width 600px.

How do I create an "estimated" curve so that 100 000 points l开发者_如何学运维ooks like a graph and not a lot of bunched up lines?

Is there a chart control that can do this for me with zooming?


I did this once by dividing the data into pixel segments (in your case 400) along the x axis. I would find the max and min value within each set and the draw a vertical line on that x point. It is very simple and you'll be amazed by the result. It only works when you have more datapoints than x cordinates within the plot area. But that is the time when you need the optimization, anyhow.

For example within x offset 233 you have the following datapoints.

(1000202, 40) (1000203, 43) (1000204, 47) (1000205, 43) (1000206, 38) (1000208, 35)

This would result in one single vertical line drawn from point (233,35) to (233,47)


I don't know if you found an answer to your question, but I developed a control which does Nyquist resampling of input data (so you only render what you can see) and immediate mode rendering (so you get best performance). The result is, it can render 100,000 xy points smoothly at 30FPS.

The answer proposed by Tormod will work for a line chart - dividing the input data into bins and finding the min/max, then drawing those, however for other chart types you need more advanced techniques. Another effect you will see is aliasing. To get around this, you can a.) resampling to more bins (e.g. 2x pixelWidth, 4x pixelWidth), b.) use antialiasing when drawing or c.) use a resampling algorithm that low-pass filters the data before down-sampling. These techniques are common in Digital Signal Processing and are applicable to 2D drawing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜