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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

1
0

I need to put a text box annotation that is located in the top left of the chart. It should remain at the top left even when the chart is zoomed, moved, etc. This should likely be some sort of anchor?

Version
5.2.1.11718
  • You must to post comments
1
0

I figured it out. Use a custom TextAnnotation and then set the Horizontal and Vertical Alignment properties.

    <Style x:Key="TextAnnotationTopLeft" TargetType="s:TextAnnotation">

        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Top" />


        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="s:TextAnnotation">
                    <Border x:Name="PART_TextAnnotationRoot"
                        Margin="{TemplateBinding Margin}"
                        Background="White"
                        BorderBrush="Purple"
                        BorderThickness="0"
                        CornerRadius="{TemplateBinding CornerRadius}">
                        <TextBox x:Name="PART_InputTextArea"
                                 Margin="10"
                                 VerticalAlignment="{TemplateBinding VerticalAlignment}"
                                 AcceptsReturn="True"
                                 Background="White"                                    
                                 FontFamily="{TemplateBinding FontFamily}"
                                 FontSize="{TemplateBinding FontSize}"
                                 FontWeight="Bold"
                                 Foreground="Black"                                     
                                 IsTabStop="{TemplateBinding IsEditable}"
                                 Text="{Binding Text,
                                            RelativeSource={RelativeSource TemplatedParent},
                                            Mode=TwoWay}"
                                 TextAlignment="{TemplateBinding TextAlignment}"
                                 TextWrapping="Wrap" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
  • You must to post comments
0
0

Hey Chris,

I’m glad you figured it out, however this is also a feature native to SciChart.

See usage of Annotation.CoordinateMode = CoordinateMode.Relative.

In this mode, the X1,Y1 coordinates are from 0.0 to 1.0 where 0.0 is the left (or bottom) edge of the chart, and 1.0 is the right (or top) edge of the chart.

Furthermore, TextAnnotation can be anchored to the left / top (controlling where the X,Y coordinate operates from) using the HorizontalAnchorPoint and VerticalAnchorPoint properties.

Best regards,
Andrew

  • Chris Kirkman
    Thanks Andrew. This might actually work better for me since I’ve yet to be able to get a text box to pin up to the top right. I have had success on the top left, just not the top right. I’ll give that a try.
  • Andrew
    So use CoordinateMode.Realtive. Set x1,y1 to 0.98 and set HorizontalAnchorPoint = right and VerticalAnchorPoint=top. It’ll work!
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.