I am writing WPF code to show a real-time plot which is a connected line containing about 10,000 points. It takes about 5 seconds to show a picture in my computer. Does anyo
Monogame, based on XNA, is alive. You can use its power to solve some special tasks requiring huge graphics performance and even inject its windows in WPF GUI.
I guess the code sample is 1) a test to try a something that isn't really the sample or 2) a homework.
Try to override the OnRender and do something like:
Pen drawingPen = new Pen(Brushes.Black, 1);
protected override void OnRender(DrawingContext dc)
{
dc.DrawRectangle(Background, null, new Rect(RenderSize));
double x=rand.Next(300);
double y = rand.Next(300);
for (double i = 0; i < 1000; i = i + 0.1)
{
y = 100 + rand.Next(100);
dc.DrawLine(drawingPen, new Point(i, x), new Point(i + 1, y));
x = y;
}
}
or for something with real data, consider if you really need to show every point depending on the resolution of the visual context. ( If your scale is 0-10 and you are producing points 0.0001,0.00015 are they really gone differ on your scale)
Charles Petzold does exactly that. It is even faster on my host (< 0.3 secs), and the point's are even DataBound!! ;)
Tamir Khason does this also, with lines and goes into more depth about Bitmap style performance WPF here.
Rico Mariani has some guidance for 3D high performance graphics, essentially leveraging value types can improve your throughput if well thought out.
Jianzhong Zhang gives my new favourate tutorials on this subject, 3D scatter plot several tens of thousands of data points animated and interactive.
Should the lines be selectable? You can draw lines in the image, then give it as a source to Image control. It will draw faster but you will lose ability to interact with lines.
Have you considered XNA? Using a graphics card will speed up things.