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.

Answered
1
0

As usual the basics of SciChart seem to be eluding me and I can’t get the simplest of features to work (hence the reference to it in the title).

All I want is an annotation in the top left of the screen in which I can dynamically change the text from the code behind – but no matter what I do it just wouldn’t do it. I therefore started a test project to see if I could work out what was going on and have recreated the problem only using XAML.

It would seem the annotation will only appear if the XAxis is defined as a “CategoryDateTimeAxis” AND it’s defined within “SciChartSurface.XAxes” tags. Any other combination and it won’t work.

Anyway – if someone could cast their eye over my test code and explain what’s happening I’d be most grateful.

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.abtsoftware.co.uk/scichart" x:Class="AnnotationTest.MainWindow"
    Title="MainWindow" Height="350" Width="525">
<Grid>

    <s:SciChartSurface HorizontalAlignment="Stretch" VerticalAlignment="Stretch" s:ThemeManager.Theme="Chrome">

        <!-- Works - Slimmed down from the "Annotations are easy" example 
        <s:SciChartSurface.XAxes>
             <s:CategoryDateTimeAxis AxisAlignment="Bottom" AxisTitle="XAxis 1" Id="XAxis1" TextFormatting="0.0#" AutoRange="Always"/>
        </s:SciChartSurface.XAxes> 
        -->
        <!-- Doesn't Work and this is from the "Interactions with Annotations" example 
        <s:SciChartSurface.XAxis>
            <s:CategoryDateTimeAxis AutoRange="Always"/>
        </s:SciChartSurface.XAxis>   
        -->

        <!-- Doesn't Work - Slimmed down from the "Create Annotations Dynamically" example
        <s:SciChartSurface.XAxis>
            <s:CategoryDateTimeAxis/>
        </s:SciChartSurface.XAxis>
        -->

        <!-- Doesn't Work - How our Axis are currently defined and what I would like to put a text annotation on
        <s:SciChartSurface.XAxis>
            <s:DateTimeAxis AxisTitle="Date" Id="XAxis1" AxisAlignment="Bottom"></s:DateTimeAxis>
        </s:SciChartSurface.XAxis>
        -->

        <s:SciChartSurface.YAxis>
            <s:NumericAxis TextFormatting="0.0#" VisibleRange="0, 10"/>
        </s:SciChartSurface.YAxis>

        <s:SciChartSurface.Annotations>
            <s:TextAnnotation HorizontalAnchorPoint="Center" Text="Anchor Center (X1, Y1)" VerticalAnchorPoint="Bottom" X1="5.0" XAxisId="XAxis1" Y1="8.0"/>
        </s:SciChartSurface.Annotations>

    </s:SciChartSurface>

</Grid>

  • You must to post comments
Best Answer
1
0

Hi Stuart,

if you have a DateTimeAxis then X1 Y1 of the TextAnnotation must be of type Datetime.

CategoryDateTimeAxis expects integer values which correspond to data indices and NumericAxis expects numeric values.

If you want to place an annotation always in the top left then you need to check out AnnotationBase.CoordinateMode Relative. This allows you to specify coordinates as fractions from 0.0 to 1.0 regardless of axis type.

Hope this helps,

Best regards,
Andrew

  • Stuart McCullough
    Oh! I told it was a fundamental thing! I was aware of the ability to specify in terms of fractions but I thought that was the default mode :-( Anyway - it's invaluable information you've supplied (as usual) which i'll use in sorting out my moving goalpost - they want the annotation to move with an associated (and dynamically created) VerticalLineAnnotation now. I've read somewhere that this should just be a binding between the two :-)
  • Andrew
    they want the annotation to move with an associated (and dynamically created) VerticalLineAnnotation now. I've read somewhere that this should just be a binding between the two Yeah that should work, why not? No the default mode is CoordinateMode.Absolute. You can see all of them here: https://www.scichart.com/documentation/webframe.html#Abt.Controls.SciChart.Wpf~Abt.Controls.SciChart.Visuals.Annotations.AnnotationCoordinateMode.html So, if you want to bind a text-annotation with a vertical line (BTW, Vertical lines do support labels, I believe, will have to check) then you should use the default CoordinateMode.Absolute and bind the X1 values together.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.