SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components
We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!
I have a chart which has its YAxes and Series bound to a view Model. When I try to add an axis in real time I get an “InvalidOperationException” –
“Could not draw an annotation of type Abt.Controls.SciChart.Visuals.Annotations.AxisMarkerAnnotation. YAxis with Id == DefaultAxisId doesn’t exist. Please ensure that the YAxisId property is set to a valid value.”
I believe this might be because I don’t have an axis set up at start. Here are my Chart Modifiers <s:SciChartSurface.ChartModifier>
<s:AnnotationCreationModifier x:Name="annotationCreation" AnnotationCreated="OnAnnotationCreated" YAxisId="Y1"/>
<s:XAxisDragModifier ClipModeX="None" />
<s:YAxisDragModifier IsEnabled="True" ReceiveHandledEvents="True" AxisId="Y1"/></s:ModifierGroup>
Can you tell me what I need to do to avoid this exception. Also, I don’t see the Series Values Modifier working, I’m sure its related to this problem.
Please let me know,
You are right, the issue happens because of empty axes collection. To workaround it, try binding the Annotations collection to ViewModel and initializing it right after the axes collection. The same for modifiers, you need to bind ChartModifier and initialize it in the ViewModel.
Also, in the case of multiple axes, there are the YAxisId, XAxisId properties in IAnnotation, which allows you to determine which axis the annotation will be bound to/measured against(refer to the Annotations Are Easy example).
Hope this helps! Please, don’t hesitate to ask if you need more info or any assistance.
The YAxisId property has been added to SeriesValueModifier.
Please login first to submit.