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

Answered
0
0

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 AxisCollection

Stack 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?

Version
5.3.0.11954
  • You must to post comments
Best Answer
1
0

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:

  1. A custom style on NumericAxis which is overriding the Id binding or just not setting the Id binding
  2. A binding error of some kind so that the NumericAxis does not bind to NumericAxisViewModel

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

  • bbmat
    @Andrew, thanks, I guess I leave it as is then. The chart and axes work perfectly fine, the error is just thrown during the surface initialization.
  • Andrew
    Due to the need to show errors to users who do things wrong, it’s unavoidable I’m afraid. Maybe as an improvement we could have a flag”: SciChartSurface.ReportWarningsErrors and allow you to disable it?
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.