Pre loader

SciChart.Charting.Visuals.Annotations.AddLabel returns null

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
 var annotationMax = new HorizontalLineAnnotation () {
                            Stroke = new SolidColorBrush (Colors.DarkRed),
                            HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                            Y1 = item.MaxBandwith,
                            Y2 = item.MaxBandwith,
                            X1 = item.FromWavelength,
                            X2 = item.ToWavelength,
                        };
                        var label = annotationMax.AddLabel ();

after last line label is null
???

Version
5.4.0.12119 .net 4.6
  • You must to post comments
0
0

What are you trying to do?

This is the preferred way to add a label to the HorizontalLineAnnotation:

https://www.scichart.com/documentation/v5.x/The%20HorizontalLineAnnotation%20Type.html

Best regards,
Andrew

  • You must to post comments
0
0

Sorry for long delay. I have my annotations databound to viewmodel’s AnnotationCollection, hence I am creating them there, not in XAML. I am trying to add label to HorizontalLineAnnotation, this annotation later is added to AnnotationCollection. Your example does not show such scenario and I do not understand why AddLabel method returns null.
Anyway, I solved this problem by simply modifying AnnotationLabels collection.

    var annotationMin = new HorizontalLineAnnotation () {
                        Stroke = new SolidColorBrush (Colors.DarkRed),
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                        Y1 = item.MinBandwith,
                        Y2 = item.MinBandwith,
                        X1 = item.FromWavelength,
                        X2 = item.ToWavelength,
                    };
                    var label = new AnnotationLabel {
                        Text = "Min Spectral Bandwidth: " + item.MinBandwith.ToString ("0."),
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                    };
                    annotationMin.AnnotationLabels.Add (label);
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.