SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

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.

SciChart WPF v6 BETA released! Note pricing/licensing changes are coming. Contact us to beat the rise!Read more
+