Pre loader

How to create an annotation lively in a thread?

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

HI,

After reading the example annotation code and articles in the forum, I still can’t find a way to achieve my purpose: My app has a thread to receive data sent by a server, the data may trigger an annotation created lively. My app also need to maintain all created annotations and change their properties like X/Y values or remove them later. So far I only see the way of creating annotation by clicking some button. I tries different ways but failed.

Please help me out with some detailed guides. I am a beginner for WPF.

regards
Chunxi

I try to do this in user thread:

LineAnnotation annotationBase = new LineAnnotation();
change annotationBase properties.

But get this exception:

2014-11-09 13:42:20,623 [11] ERROR WpfApplication2.MainWindow [(null)] – at System.Windows.Input.InputManager..ctor()
at System.Windows.Input.InputManager.GetCurrentInputManagerImpl()
at System.Windows.Input.KeyboardNavigation..ctor()
at System.Windows.FrameworkElement.FrameworkServices..ctor()
at System.Windows.FrameworkElement.EnsureFrameworkServices()
at System.Windows.FrameworkElement..ctor()
at System.Windows.Controls.Control..ctor()
at System.Windows.Controls.ContentControl..ctor()
at Abt.Controls.SciChart.ChartModifiers.ApiElementBase..ctor()
at Abt.Controls.SciChart.Visuals.Annotations.AnnotationBase..ctor()
at Abt.Controls.SciChart.Visuals.Annotations.LineAnnotationBase..ctor()
at Abt.Controls.SciChart.Visuals.Annotations.LineAnnotation..ctor()
at WpfApplication2.InstrumentViewModel.addZone() in c:\Users\jokeslala\Documents\Visual Studio 2013\Projects\WpfApplication2\WpfApplication2\InstrumentViewModel.cs:line 134
at WpfApplication2.InstrumentViewModel.addMA20(Int32 barIdx, Double ma) in c:\Users\jokeslala\Documents\Visual Studio 2013\Projects\WpfApplication2\WpfApplication2\InstrumentViewModel.cs:line 128
at WpfApplication2.MainWindow.processEMA(String str) in c:\Users\jokeslala\Documents\Visual Studio 2013\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml.cs:line 222
at WpfApplication2.MainWindow.consumeQueue() in c:\Users\jokeslala\Documents\Visual Studio 2013\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml.cs:line 155

  • You must to post comments
0
0

Hi Chunxi,

Thank you for your question & comment. I think the problem you are seeing is that you are creating Annotations on a non UI thread (guessing?). If so, sorry, you have to create Annotations on the UI thread.

Why? Because Annotations are WPF FrameworkElements, and require that they are created on the UI thread.

In your comment you suggest another way and talk about performance. You can try using our PointMarker API and the XyScatterRenderableSeries. This allows rendering of many more points.

For tooltips / mouse-over, please see the TooltipModifier.

Best regards,
Andrew

  • chunxi
    HI Andrew, Thanks for your reply. Basically I try to find a way to draw a segment (x1, y1) to (x2, y2). The x-Axis is type of CategoryDateTimeAxis. I can't find an example for XyScatterRenderableSeries. looks it is not parameter-based, I can't create a class like XyScatterRenderableSeries<DateTime, double>. How to add the pointers (x1, y1) to the series?
  • Andrew Burnett-Thompson
    If you want to add a segment from (x1, y1) to (x2, y2), I suggest using our LineAnnotation type. Please see the article Annotations Are Easy! for guidance. https://www.scichart.com/annotations-are-easy/ Best regards, A
  • chunxi
    HI, performance will be bad if use LineAnnotation right? I will have many many these items.
  • Andrew Burnett-Thompson
    Depends, If you have up to 1000 LineAnnotations it will be ok. 10,000 it will not be so fast. I suggest trying it. The Annotation API is the most easy API to use for line segments. The only other way is to use FastLineRenderableSeries. You can declare one series and have many segments by using double.NaN for a 'null value'. Take a look at our Gaps In Series example which uses double.NaN to display a gap between two points. https://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/CreateMultiseriesChart/GapsInSeries.xaml Best regards, Andrew
  • chunxi
    Thanks Andrew. I will be trying it.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies