SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
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>
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
Please login first to submit.