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


Hello scichart developers. đŸ™‚
I am developing some chart app with scichart for WPF.
And I added AnnotationCreationModifier object in chart, but I don’t know how can I apply the LabelFormatter into AnnotationCreationModifier.
I want to modify the label of AnnotationCreationModifier label same as the XAxis’s label.
( Actually in my project, the XAxis’s values are double and customized, so I have to convert this values to DateTime string value. )

This is codes that the LabelFormatter is applied into the XAxis.

var formatter = this.GraphObj.XAxis.LabelFormatter as DateTimeRangeAdoptiveFormatter;

if (formatter == null)
    formatter = new DateTimeRangeAdoptiveFormatter();
    this.GraphObj.XAxis.LabelFormatter = formatter;

This is my screenshot that have troubles with showing the unformatted double value s into Vertical Annotation.

  • You must to post comments

Thank you for your answer Yuriy
I fix my code as you guided.
It works great. đŸ™‚

This is my fixed code:

/// <summary>
/// This is the callback function which is called at creating new Annotation.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _AnnotationCreationModifierObj_AnnotationCreated(object sender, EventArgs e)
    var newAnnotation = (this.AnnotationCreationModifierObj.Annotation as AnnotationBase);

    if (newAnnotation != null)
        newAnnotation.IsEditable = true;

        if (newAnnotation is HorizontalLineAnnotation)
            var hAnnotation = (HorizontalLineAnnotation)newAnnotation;
            // This is main codes that I fixed.
            // I binded the Y1 value of HorizontalLineAnnotation object with DoubleToPrettyStrConverter.
            BaseUtil.BindDataToView(hAnnotation, LineAnnotationWithLabelsBase.LabelValueProperty, hAnnotation, "Y1", BindingMode.OneWay, new DoubleToPrettyStrConverter());
        else if (newAnnotation is VerticalLineAnnotation)
            var vAnnotation = (VerticalLineAnnotation)newAnnotation;
            BaseUtil.BindDataToView(vAnnotation, LineAnnotationWithLabelsBase.LabelValueProperty, vAnnotation, "X1", BindingMode.OneWay, new StockDoubleToDateTimeStrConverter(_converter));

    var vm = this.DataContext as SciChartViewModel;
    vm.LineAnnotationTypeObj = SciChartViewModel.LineAnnotationType.None;

I attach my screen shots.

  • Yuriy Zadereckiy
    Hi, Glad that the issue is resolved and thank you for posting the code - I'm sure it will be useful to the others who are confronted with similar issues! :) Best regards, Yuriy
  • You must to post comments


The screenshot is missed for some reason…could you re-attach it? As for the question, LabelFormatter was intended to work with axes, but you can apply it to annotation’s label too. Just use it inside a value converter for the label, like the following:

                <s:VerticalLineAnnotation VerticalAlignment="Stretch"
                                          LabelValue="{Binding X1, Converter={StaticResource FormatLabelConverter}}"
                                          ShowLabel="True" />

And in the FormatLabelConverter just pass a value into a LabelFormatter instance.

Does this make sense for you?

Best regards,

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.