Pre loader

Combine BoxAnnotation with VerticalLine Annotation

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

Answered
1
0

How to create custom annotation which has BoxAnnotation with a VerticalLine Annotation at one end.

At present I’m achieving this by creating both annotations and synchronizing them in ChartModifier.
Look at the attached image where you can see two BoxAnnotations both having a VerticalLineAnnotation at one end. I’m disabling editing for BoxAnnotation and enabling editing only for VerticalLineAnnotation.

When VerticalLineAnnotation is dragged in X-Direction, I get the X1 value from it and manually set it to BoxAnnotations X2.

This is not good implementation. I can see lag between sync events. Is it possible to create a custom annotation which incorporates both Box and Vertical line annotations ? Or is it possible to set IsEditing for BoxAnnotations One End only ?

Images
  • You must to post comments
Best Answer
1
0

Hi Jerome,

There is no way in SciChart to create a Composite Annotation e.g. combine two or more annotations into one annotation.

However, you can achieve what you want by using bindings between annotation properties. For instance, I have modified our existing Drag Horizontal Threshold example with the following code:

    <s:SciChartSurface Grid.Column="1"
                        s:ThemeManager.Theme="Electric"
                        SeriesSource="{Binding ChartSeries, Mode=OneWay}"
                        ViewportManager="{Binding ViewportManager, Mode=OneWay}" >

        <s:SciChartSurface.Annotations>
            <s:HorizontalLineAnnotation 
            x:Name="horizLine" 
            HorizontalAlignment="Stretch"
            IsEditable="True"
            LabelPlacement="Axis"
            LabelTextFormatting="0.00"
            ShowLabel="True"
            Stroke="Orange"
            StrokeThickness="2"
            Y1="{Binding Threshold, Mode=TwoWay}" />

           <!-- Binds to VerticalLineAnnotation and Axis properties -->
           <!-- to create a filled area below the threshold --> 
            <s:BoxAnnotation CoordinateMode="RelativeX" X1="0" X2="1" 
                            Background="#33FFA500"                                 
                            Y1="{Binding ElementName=horizLine, Path=Y1, Mode=OneWay}"
                            Y2="{Binding ElementName=yAxis, Path=VisibleRange.Min, Mode=OneWay}" 
                            IsEditable="False"/>
        </s:SciChartSurface.Annotations>

        <s:SciChartSurface.XAxis>
            <s:NumericAxis  VisibleRange="0.0, 10.0" AutoRange="Always"/>
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxis>
            <s:NumericAxis x:Name="yAxis" VisibleRange="-1.0, 1.0" AxisAlignment="Left" AutoRange="Always"/>
        </s:SciChartSurface.YAxis>

        <s:SciChartSurface.ChartModifier>
            <s:LegendModifier ShowLegend="True" Margin="10" LegendTemplate="{StaticResource LegendTemplate}"/>
        </s:SciChartSurface.ChartModifier>
    </s:SciChartSurface>

This results in this behaviour below. I can’t see any lag between the drag of the HorizontalLineAnnotation and position of the BoxAnnotation.

enter image description here

Best regards,
Andrew

  • WOOKUN LEE
    I’m looking for custom event for annotation which has BoxAnnotation with a horizontal Line Annotation for android and i found this page. but ‘Drag Horizontal Threshold example’ page is not found =( you guys have any sample for android?
  • 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