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

0
0

I’m trying to adapt the real time with cursors sample to my application, and I am getting the errors:

A first chance exception of type ‘System.InvalidOperationException’ occurred in Abt.Controls.SciChart.Wpf.2.2.dll
SciChartSurface didn’t render, because an exception was thrown:
Message: Could not draw an annotation of type Abt.Controls.SciChart.Visuals.Annotations.CustomAnnotation. YAxis with Id == DefaultAxisId doesn’t exist. Please ensure that the YAxisId property is set to a valid value.

Stack Trace: at Abt.Controls.SciChart.Visuals.Annotations.AnnotationCollection.cdf2bd7561b58306ecd5089a541681211(IDictionary`2 cb584733576aa785c01756f543bd52bbd, IAnnotation c7816e538855bcbae71ae0f6efa624460, String cc81d01f2a94a35bb5f140e91f56aab32, Boolean ce46347a6d5ff6106322b900dd6b47b62)
at Abt.Controls.SciChart.Visuals.Annotations.AnnotationCollection.RefreshPositions(RenderPassInfo rpi)
at A.cda144392e546b245ef5bb1ee71f22b3a.c7f1b2d02c5ccbd19621131cda68e2518(SciChartSurface c17037e8328cd0abc02d2a6957dfa450c, RenderPassInfo c16b8d70d2b6ecad8f9fca7ac3f5177b8)
at A.cda144392e546b245ef5bb1ee71f22b3a.RenderLoop(IRenderContext2D renderContext)
at Abt.Controls.SciChart.Visuals.SciChartSurface.ca065c0b6712A first chance exception of type ‘System.InvalidOperationException’ occurred in Abt.Controls.SciChart.Wpf.2.2.dll
21e0e603d0e9bf2792494()

Can you look at my XAML and tell me what I have wrong? I’m sure it something simple, but I can’t seem to figure it out.

XAML

<UserControl x:Class="Analyze.Controls.LivePlot"
xmlns=" http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
xmlns:x=" http://schemas.microsoft.com/winfx/2006/xaml&quot;
xmlns:mc=" http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
xmlns:d=" http://schemas.microsoft.com/expression/blend/2008&quot;
xmlns:sources="clr-namespace:Analyze.Sources"
xmlns:sc=" http://schemas.abtsoftware.co.uk/scichart&quot;
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="400">
<UserControl.Resources>
<!– Converter used by feedback panel below SciChartSurface–>
<sc:ColorToBrushConverter x:Key="ColorToBrushConverter"/>

    &lt;!-- Common TextBlock style, uses ColorToBrushConverter to convert RenderableSeries.SeriesColor to a brush for textblocks --&gt;
    &lt;Style TargetType=&quot;TextBlock&quot; x:Key=&quot;tbStyle&quot;&gt;
        &lt;Setter Property=&quot;Margin&quot; Value=&quot;2,4&quot;/&gt;
        &lt;Setter Property=&quot;Foreground&quot; Value=&quot;{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}&quot;/&gt;
        &lt;Setter Property=&quot;FontWeight&quot; Value=&quot;Bold&quot;/&gt;
        &lt;Setter Property=&quot;FontSize&quot; Value=&quot;11&quot;/&gt;
    &lt;/Style&gt;

    &lt;sources:DriverLapSignalSource x:Key=&quot;ThrottleSource&quot; 
                                   XSignal=&quot;LapDist&quot; XFactor=&quot;3.2808398950131233595800524934383&quot;
                                   YSignal=&quot;Throttle&quot; YFactor=&quot;100.0&quot; /&gt;
    &lt;sources:DriverLapSignalSource x:Key=&quot;BrakeSource&quot; 
                                   XSignal=&quot;LapDist&quot; XFactor=&quot;3.2808398950131233595800524934383&quot;
                                   YSignal=&quot;Brake&quot; YFactor=&quot;100.0&quot; /&gt;
    &lt;sources:DriverLapSignalSource x:Key=&quot;SpeedSource&quot; 
                                   XSignal=&quot;LapDist&quot; XFactor=&quot;3.2808398950131233595800524934383&quot;
                                   YSignal=&quot;Speed&quot; YFactor=&quot;2.2369362920544022906227630637079&quot; /&gt;
    &lt;sources:DriverLapSignalSource x:Key=&quot;RPMSource&quot; 
                                   XSignal=&quot;LapDist&quot; XFactor=&quot;3.2808398950131233595800524934383&quot;
                                   YSignal=&quot;RPM&quot; YFactor=&quot;1.0&quot; /&gt;
&lt;/UserControl.Resources&gt;

&lt;Grid&gt;
    &lt;sc:SciChartSurface x:Name=&quot;chart&quot; Grid.Row=&quot;0&quot; Grid.Column=&quot;0&quot;
                                Background=&quot;Black&quot; &gt;

        &lt;sc:SciChartSurface.XAxis&gt;
            &lt;sc:NumericAxis AutoRange=&quot;Never&quot; AxisTitle=&quot;Distance&quot; TitleFontWeight=&quot;Bold&quot;
                                    DrawMajorBands=&quot;True&quot; MajorDelta=&quot;1000&quot; MinorDelta=&quot;500&quot;&gt;
                &lt;sc:NumericAxis.VisibleRange&gt;
                    &lt;sc:DoubleRange Max=&quot;0&quot; Min=&quot;5200&quot;/&gt;
                &lt;/sc:NumericAxis.VisibleRange&gt;
            &lt;/sc:NumericAxis&gt;
        &lt;/sc:SciChartSurface.XAxis&gt;

        &lt;sc:SciChartSurface.YAxes&gt;
            &lt;sc:NumericAxis AutoRange=&quot;Never&quot; AxisTitle=&quot;%&quot; TitleFontWeight=&quot;Bold&quot; 
                                    AxisAlignment=&quot;Left&quot;
                                    MajorDelta=&quot;20&quot; MinorDelta=&quot;5&quot; Id=&quot;Percent&quot;&gt;
                &lt;sc:NumericAxis.VisibleRange&gt;
                    &lt;sc:DoubleRange Min=&quot;0&quot; Max=&quot;100&quot; /&gt;
                &lt;/sc:NumericAxis.VisibleRange&gt;
            &lt;/sc:NumericAxis&gt;
            &lt;sc:NumericAxis AxisTitle=&quot;RPM&quot; TitleFontWeight=&quot;Bold&quot; 
                                    AxisAlignment=&quot;Left&quot;
                                    MajorDelta=&quot;20&quot; MinorDelta=&quot;5&quot; Id=&quot;RPM&quot;
                                    AutoRange=&quot;Always&quot; GrowBy=&quot;0.1, 0.1&quot; /&gt;
            &lt;sc:NumericAxis AxisTitle=&quot;MPH&quot; TitleFontWeight=&quot;Bold&quot; 
                                    AxisAlignment=&quot;Left&quot;
                                    MajorDelta=&quot;20&quot; MinorDelta=&quot;5&quot; DrawMajorBands=&quot;True&quot; Id=&quot;MPH&quot;
                                    AutoRange=&quot;Always&quot; GrowBy=&quot;0.1, 0.1&quot; /&gt;
        &lt;/sc:SciChartSurface.YAxes&gt;
        &lt;sc:SciChartSurface.RenderableSeries&gt;
            &lt;sc:FastLineRenderableSeries x:Name=&quot;brakeSeries&quot; ResamplingMode=&quot;MinMax&quot;
                                                 SeriesColor=&quot;OrangeRed&quot; AntiAliasing=&quot;True&quot;
                                                 StrokeThickness=&quot;1&quot; 
                                                 YAxisId=&quot;Percent&quot; 
                                                 DataSeries=&quot;{Binding Source={StaticResource BrakeSource}, Path=Series}&quot;
                                                  /&gt;
            &lt;sc:FastLineRenderableSeries x:Name=&quot;refBrakeSeries&quot; ResamplingMode=&quot;MinMax&quot;
                                                 SeriesColor=&quot;Red&quot; AntiAliasing=&quot;True&quot;
                                                 StrokeThickness=&quot;1&quot;
                                                 StrokeDashArray=&quot;5,5&quot;   
                                                 YAxisId=&quot;Percent&quot;/&gt;
            &lt;sc:FastLineRenderableSeries x:Name=&quot;throttleSeries&quot; ResamplingMode=&quot;MinMax&quot;
                                                 SeriesColor=&quot;LightGreen&quot; AntiAliasing=&quot;True&quot;
                                                 StrokeThickness=&quot;1&quot; 
                                                 YAxisId=&quot;Percent&quot;
                                                 DataSeries=&quot;{Binding Source={StaticResource ThrottleSource}, Path=Series}&quot;
                                         /&gt;
            &lt;sc:FastLineRenderableSeries x:Name=&quot;refThrottleSeries&quot; ResamplingMode=&quot;MinMax&quot;
                                                 SeriesColor=&quot;Green&quot; AntiAliasing=&quot;True&quot;
                                                 StrokeThickness=&quot;1&quot;
                                                 StrokeDashArray=&quot;5,5&quot;   
                                                 YAxisId=&quot;Percent&quot;/&gt;
            &lt;sc:FastLineRenderableSeries x:Name=&quot;speedSeries&quot; ResamplingMode=&quot;MinMax&quot;
                                                 SeriesColor=&quot;LightBlue&quot; AntiAliasing=&quot;True&quot;
                                                 StrokeThickness=&quot;1&quot; 
                                                 YAxisId=&quot;MPH&quot;
                                                 DataSeries=&quot;{Binding Source={StaticResource SpeedSource}, Path=Series}&quot;
                                         /&gt;
            &lt;sc:FastLineRenderableSeries x:Name=&quot;refSpeedSeries&quot; ResamplingMode=&quot;MinMax&quot;
                                                 SeriesColor=&quot;Blue&quot; AntiAliasing=&quot;True&quot;
                                                 StrokeThickness=&quot;1&quot;
                                                 StrokeDashArray=&quot;5,5&quot;   
                                                 YAxisId=&quot;MPH&quot;/&gt;
            &lt;sc:FastLineRenderableSeries x:Name=&quot;rpmSeries&quot; ResamplingMode=&quot;MinMax&quot;
                                                 SeriesColor=&quot;Gold&quot; AntiAliasing=&quot;True&quot;
                                                 StrokeThickness=&quot;1&quot; 
                                                 YAxisId=&quot;RPM&quot;
                                                 DataSeries=&quot;{Binding Source={StaticResource RPMSource}, Path=Series}&quot;
                                         /&gt;
            &lt;sc:FastLineRenderableSeries x:Name=&quot;refRPMSeries&quot; ResamplingMode=&quot;MinMax&quot;
                                                 SeriesColor=&quot;Goldenrod&quot; AntiAliasing=&quot;True&quot;
                                                 StrokeThickness=&quot;1&quot;
                                                 StrokeDashArray=&quot;5,5&quot;   
                                                 YAxisId=&quot;RPM&quot;/&gt;
        &lt;/sc:SciChartSurface.RenderableSeries&gt;

        &lt;sc:SciChartSurface.ChartModifier&gt;
            &lt;sc:ModifierGroup&gt;
                &lt;sc:LegendModifier x:Name=&quot;legendModifier&quot; GetLegendDataFor=&quot;AllSeries&quot;/&gt;
                &lt;sc:RolloverModifier x:Name=&quot;rolloverModifier&quot; ShowAxisLabels=&quot;False&quot; UseInterpolation=&quot;True&quot;/&gt;
            &lt;/sc:ModifierGroup&gt;
        &lt;/sc:SciChartSurface.ChartModifier&gt;

        &lt;!-- A nice technique is to put the rollover legend inside an annotation with relative coordinates, then it is always inside the chart surface --&gt;
        &lt;sc:SciChartSurface.Annotations&gt;
            &lt;sc:CustomAnnotation CoordinateMode=&quot;Relative&quot; X1=&quot;0.01&quot; Y1=&quot;0.02&quot; HorizontalAnchorPoint=&quot;Left&quot; VerticalAnchorPoint=&quot;Top&quot;&gt;
                &lt;sc:CustomAnnotation.Content&gt;
                    &lt;!-- Define a panel to display rollover results --&gt;
                    &lt;Border Grid.Row=&quot;1&quot; BorderBrush=&quot;#55000000&quot; BorderThickness=&quot;2&quot; Background=&quot;#77FFFFFF&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Left&quot; Padding=&quot;5&quot;&gt;
                        &lt;ItemsControl DataContext=&quot;{Binding ElementName=rolloverModifier}&quot; ItemsSource=&quot;{Binding SeriesData.SeriesInfo}&quot;&gt;
                            &lt;ItemsControl.ItemTemplate&gt;
                                &lt;!-- Template will be instantiated for each SeriesInfo in the RolloverModifier.SeriesInfo collection --&gt;
                                &lt;!-- See the SciChart API Documentation for SeriesInfo types, there is a different type for OHLC and XyzDataSeries for instance --&gt;
                                &lt;!-- SeriesInfo is the datacontext for the below. Note you can access the original RenderableSeries via SeriesInfo.RenderableSeries --&gt;
                                &lt;DataTemplate&gt;
                                    &lt;Grid HorizontalAlignment=&quot;Left&quot;&gt;
                                        &lt;Grid.ColumnDefinitions&gt;
                                            &lt;ColumnDefinition/&gt;
                                            &lt;ColumnDefinition/&gt;
                                            &lt;ColumnDefinition/&gt;
                                            &lt;ColumnDefinition/&gt;
                                        &lt;/Grid.ColumnDefinitions&gt;

                                        &lt;Ellipse Fill=&quot;{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}&quot; Width=&quot;9&quot; Height=&quot;9&quot; Margin=&quot;3&quot;/&gt;

                                        &lt;TextBlock Grid.Column=&quot;1&quot; Text=&quot;{Binding SeriesName}&quot; Width=&quot;90&quot; Style=&quot;{StaticResource tbStyle}&quot;/&gt;

                                        &lt;!-- When binding to XValue, YValue of type IComparable, StringFormat is mandatory due to a --&gt;
                                        &lt;!-- XAML bug that cannot convert IComparable to text, even though underlying type is double --&gt;
                                        &lt;StackPanel Orientation=&quot;Horizontal&quot; Grid.Column=&quot;2&quot;&gt;
                                            &lt;TextBlock Text=&quot;X: &quot; Style=&quot;{StaticResource tbStyle}&quot;/&gt;
                                            &lt;TextBlock Text=&quot;{Binding XValue, StringFormat=\{0:0.00\}}&quot; Style=&quot;{StaticResource tbStyle}&quot;/&gt;
                                        &lt;/StackPanel&gt;
                                        &lt;StackPanel Orientation=&quot;Horizontal&quot; Grid.Column=&quot;3&quot;&gt;
                                            &lt;TextBlock Text=&quot;Y: &quot; Margin=&quot;3&quot; Style=&quot;{StaticResource tbStyle}&quot;/&gt;
                                            &lt;TextBlock Text=&quot;{Binding YValue, StringFormat=\{0:0.00\}}&quot; Style=&quot;{StaticResource tbStyle}&quot;/&gt;
                                        &lt;/StackPanel&gt;

                                    &lt;/Grid&gt;
                                &lt;/DataTemplate&gt;
                            &lt;/ItemsControl.ItemTemplate&gt;
                        &lt;/ItemsControl&gt;
                    &lt;/Border&gt;
                &lt;/sc:CustomAnnotation.Content&gt;
            &lt;/sc:CustomAnnotation&gt;
        &lt;/sc:SciChartSurface.Annotations&gt;
    &lt;/sc:SciChartSurface&gt;

    &lt;sc:SciChartLegend x:Name=&quot;legendControl&quot;
                       HorizontalAlignment=&quot;Left&quot;
                       VerticalAlignment=&quot;Bottom&quot;
                       LegendData=&quot;{Binding LegendData, ElementName=legendModifier, Mode=OneWay}&quot;
                       ShowVisibilityCheckboxes=&quot;true&quot; 
                           /&gt;
&lt;/Grid&gt;

</UserControl>

I am very impressed with your product and after having a false start with Visiblox components I am really excited to be using your tool. It’s easy to use, works as advertised with plenty of samples to get almost everything up and running in no time what so ever.

Thanks,
Doug

  • You must to post comments
0
0

Hi Doug,

Thanks for the comprehensive code sample! Ok – the error message alone tells me the AxisId property on the Annotation is not matching an axis id on your axis collection.

By default all Axes have an Id =’DefaultAxisId’ and all Annotations have an XAxisId and YAxisId=’DefaultAxisId’

It looks to me like you’ve customised the Ids of all the axes (e.g. no axis remains with ‘DefaultAxisId’) but have not customised the YAxisId and XAxisId of the annotations.

Two solutions. Either leave one pair of axes as default (do not specify an ID for them) or, set Ids on all your annotations.

Let me know if this helps!

Andrew

  • Doug
    I just got your email after finding another resolution. I added an explicitThis gave the control an axis with a default y axis id, and allowed it to continue on process the remaining axes.My experiance with Visiblox was not one I'd care to repeat, but the more I work with your product the more I like it. It's quick, and incredibly easy to add interesting functionality too. It's saved days if not weeks off my current project.Thanks again.
  • Andrew
    Thank you Doug I appreciate your frank feedback. That's what we want to do - add value by saving time & money. I fear we are not where we want to be, not by a long way, but the encouragement we receive from people such as yourselves means a lot :)Glad you got it working in the end. Ideally it should not throw in this case but should gracefully fail. If you can suggest a way around I'd hear it. Maybe we should specify an AxisId of 'NONE' or null = do not show.Best regards, Andrew
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.