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

0
0

Hi,

I would like to implement a Circle / Old style annotation just like how the box annotation works.
I presume one has to override the box annotation to this.

Can you kindly show me how to do this? 🙂

Thanks!

  • You must to post comments
0
0

Hi Azrin,

You can draw an oval (Ellipse) annotation by templating the BoxAnnotation type to create any custom annotation.

Please see the following FAQ for instructions: Resizing a custom annotation

Best regards,
Andrew

  • You must to post comments
0
0

Hi Andrew,

Thanks for the reply. I’m just confused with the example given.Normally to create a custom annotation one would need to override the class

You have specified the following code:

<!--  Annotations  -->
<Style x:Key="AnnotationBaseStyle" TargetType="a:AnnotationBase">
    <Style.Setters>
        <Setter Property="IsTabStop" Value="False" />
    </Style.Setters>
</Style>

<!--  BoxAnnotation  -->
<Style BasedOn="{StaticResource AnnotationBaseStyle}" TargetType="a:BoxAnnotation">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="a:BoxAnnotation">
                <Border x:Name="PART_BoxAnnotationRoot"
                        Margin="{TemplateBinding Margin}"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding CornerRadius}" />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Sounds it’s a bit far from getting an ellipse or circle from here.

can you help?

thanks

  • Andrew
    Hi Azrin, the above code is an example to template the BoxAnnotation to make it look how you want. If you want an ellipse, simply put an ellipse in the template, e.g.<Style BasedOn="{StaticResource AnnotationBaseStyle}" TargetType="a:BoxAnnotation"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="a:BoxAnnotation"> <Border x:Name="PART_BoxAnnotationRoot" Margin="{TemplateBinding Margin}"> <!-- Any UI can go here! --> <Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType=Border}}" Height="{Binding ActualHeight, RelativeSource={RelativeSource FindAncestor, AncestorType=Border}}" StrokeThickness="1" /> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style>
  • You must to post comments
0
0

Thanks Andrew,

It’s work perfectly fine.

I was using it in a drawing palette so I had to create a derived class

Cheers!

  • You must to post comments
0
0

I’m confused as to where these lines of code should go. You can’t really put a Style container directly in a <Scichart.Annotations> container. Why is the “BasedOn” property necessary?

I have a rudimentary code here just trying to make an ellipse within a box template:

<s:SciChartSurface>

    <s:SciChartSurface.Resources>
    </s:SciChartSurface.Resources>

    <s:SciChartSurface.XAxis>
        <s:NumericAxis AxisTitle="Time (s)" AutoRange="Always" Id="XAxis1"/>
    </s:SciChartSurface.XAxis>

    <s:SciChartSurface.YAxis>
        <s:NumericAxis AxisTitle="Temperature (C)" TickTextBrush="DarkOrange" Id="LeftAxis" AutoRange="Once" AxisAlignment="Right"/>
    </s:SciChartSurface.YAxis>

    <s:SciChartSurface.Annotations>
        <s:BoxAnnotation X1="1" X2="9" XAxisId="XAxis1" YAxisId="LeftAxis" Y1="1" Y2="9">
            <Style TargetType="s:BoxAnnotation">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="s:BoxAnnotation">
                            <Border x:Name="PART_BoxAnnotationRoot" Margin="0">
                                <Ellipse Fill="Red" Stroke="Blue" Width="20" Height="20" StrokeThickness="1"/>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </s:BoxAnnotation>
    </s:SciChartSurface.Annotations>

    <s:SciChartSurface.ChartModifier>
        <s:ModifierGroup>
            <s:RubberBandXyZoomModifier IsEnabled="True" IsXAxisOnly="False" ZoomExtentsY="False" IsAnimated="True"/>
            <s:ZoomExtentsModifier ExecuteOn="MouseDoubleClick"/>
        </s:ModifierGroup>
    </s:SciChartSurface.ChartModifier>
</s:SciChartSurface>

The box template itself will show up, but nothing inside it. Can you please advise?

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.