SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Am encountering the following runtime error despite explicitly adding a numeric y-axis with Id “DefaultAxisId” to the AxisCollection in my view model that is bound to YAxes:
Exception thrown: ‘System.InvalidOperationException’ in SciChart.Charting.dll
SciChartSurface didn’t render, because an exception was thrown:
Message: AxisCollection.GetAxisById(‘DefaultAxisId’) returned no axis with ID=DefaultAxisId. Please check you have added an axis with this Id to the AxisCollectionStack Trace: at SciChart.Charting.Model.AxisCollection.GetAxisById(String axisId, Boolean assertAxisExists)
at A.IJ.M(ISciChartSurface D, RenderPassInfo I, IRenderContext2D J)
at A.IJ.RenderLoop(IRenderContext2D renderContext)
at SciChart.Charting.Visuals.SciChartSurface.DoDrawingLoop()
To test, I added the following Y-Axis within my view model constructor:
YAxes.Add(new NumericAxis()
{
Id = "DefaultAxisId",
Visibility = Visibility.Hidden
});
Why is this error still thrown?
Hi Matt,
I’m aware of some timing issues that can occur where this message AxisCollection.GetAxisById(‘DefaultAxisId’) returned no axis with ID=DefaultAxisId is shown in the Visual Studio output momentarily during chart initialisation.
This occurs due to WPF bindings not being evaluated immediately, so when the AxisViewModel is inserted into the chart, an Axis is instantiated and inserted into the chart BEFORE wpf bindings are evaluated. In this case, the chart works as expected once the bindings have evaluated.
Not much we can do about that without you providing default values to bindings, or us removing the error / warning. We have to include the warning message however, or people contact us with support requests ‘Why is my chart blank‘.
If you are seeing the chart always blank / the error not going away despite setting AxisId in the view model then one of two problems could be the cause:
Either way, do some investigation, if you are able to narrow down the problem, send over some code and we can investigate and provide a solution.
Best regards,
Andrew
Please login first to submit.