Hi :
I use annotation to write text on the Surface ,but there is a problem . If it have a large amount annotations ,it will cost many time and CPU. How to draw the graph like my expmple?
I hope that have a good performance at large amount points which have a number on each point.
Thanks for any help!
- JiaRong Kang asked 8 years ago
- You must login to post comments
Hi there,
Please see our FAQ Performance with Lots of Annotations
The Annotations feature in v1.5 uses UIElements. These are very flexible (as they are WPF elements) but are also very slow compared to the bitmap rendering that we employ in SciChart.
Another option for you to draw numeric values at points is to create a custom PointMarker. Take a look at Insane WPF Scatter Chart performance with Parallel Rendering which has an example how to create a custom BasePointMarker derived type.
Next, have a look at our documentation on CustomRenderableSeries / RenderContext2D. There is a method IRenderContext2D.DrawText which allows you to draw text using our (very fast) raster bitmap engine.
So putting it all together, try a Custom PointMarker which draws text, and apply the pointmarker to your chart. It should work, and should be very very fast.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 8 years ago
- You must login to post comments
Hi :
I follow the code in FAQ Performance with Lots of Annotations. I found that SuspendUpdates in my code is useless. It didn’t improve performance.
Do I have anything wrong in my code?
And there is another problem ,that UI have 5~10 second dely since my Debug.WriteLine done.
Have suspend :
using (sciChart.SuspendUpdates())
{
var myAnnotations = new AnnotationCollection();
for (int i = 0; i < 100000; i++)
{
var a = new BoxAnnotation
{
XAxisId = "XAxis1",
YAxisId = "YAxis1",
X1 = i,
X2 = i + 1,
Y1 = i,
Y2 = i + 1,
Background = Brushes.Yellow,
Foreground = Brushes.Black,
};
myAnnotations.Add(a);
}
sciChart.Annotations = myAnnotations;
}
No suspend :
var myAnnotations = new AnnotationCollection();
for (int i = 0; i < 100000; i++)
{
var a = new BoxAnnotation
{
XAxisId = "XAxis1",
YAxisId = "YAxis1",
X1 = i,
X2 = i + 1,
Y1 = i,
Y2 = i + 1,
Foreground = Brushes.Black,
Background = Brushes.Brown,
};
myAnnotations.Add(a);
}
sciChart.Annotations = myAnnotations;
I use Stopwatch to measure time. Suspend’s time is similiar to No-Suspend.
There are two image to prove it.
Thank for any help.
Best Regards
- JiaRong Kang answered 8 years ago
- last edited 8 years ago
-
Hi Xuan, maybe I wasn’t clear. What I was trying to say was that Annotations are going to be 10x – 100x slower than using our Bitmap engine to draw text. You can use our bitmap engine by creating a custom PointMarker. Please take a look at my answer again above and follow the links to the Custom PointMarker/ CustomRenderableSeries API. Best regards, Andrew
-
Hi Andrew, I got it. I will try custom PointMarker to draw text. Thanks for your answer!!!
- You must login to post comments
Please login first to submit.