Pre loader

Several errors when DataSeries is not filled yet.

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

  1. SciChartSurface created with category x and numeric y axes
  2. ZoomPanModifier, ZoomExtentsModifier, MouseWheelZoomModifier, RolloverModifier added.
  3. Any series and dataSeries are initialized and added to the surface, but not filled with values yet.
  4. Value streaming started with delay.

The first error occurs when trying to zoom on empty surface :

Uncaught TypeError: Cannot read properties of undefined (reading 'width')
at MouseWheelZoomModifier2.ChartModifierBase2D2.growBy (ChartModifierBase2D.js:121:48)

And the other one when trying to drag:

Uncaught Error: category x axis with id=DefaultAxisId should have data series count > 0
at CategoryAxis2.CategoryAxisBase2.getCurrentCoordinateCalculatorInternal (CategoryAxisBase.js:95:19)

I have seen errors similar to the second one in other scenarios and sometimes it is fatal.
E.g i have tried to add annotation right after first value was added and first line raised similar error:

    const xCalc = this.surface.xAxes.get(0).getCurrentCoordinateCalculator() as CategoryCoordinateCalculator;
    const realX = xCalc.transformDataToIndex(time);
    const target = this.getOrAddAnnotation();
    target.x1 = realX;
    target.y1 = value;

Also getCurrentCoordinateCalculatorInternal error occurs when empty series & seriesData added without suspend.
I would appreciate any help and clarification

  • You must to post comments
Best Answer

Hi Sergey

Can you try getting v2.1 of SciChart.js and applying these properties:

Set these when you create your CategoryAxis.

defaultXStart should be the unix timestamp you want to appear at the bottom-left of the axis when there is no data
defaultXStep should be the timeframe for your candlestick chart. E.g. if it’s a daily timeframe then put the unix timestamp for 1 day

Try that. Does it work?

Once data has been loaded on the CategoryAxis it should behave as normal

Best regards,

  • Sergey Chernyakov
    Hello, Andrew. I apologize for the delay. I have tried those properties set ( defaultXStart=1644339972 , defaultXStep=60) and here is what I observed: 1. If there is at least one empty series added to surface everything works fine, but first x axis label always started from 1st Jan 1970 (no matter what was set to defaultXStart). 2. If there is no series added x axis label is valid but I am getting errors after few actions on scroll and drag: CategoryAxisBase.js:189 Uncaught RangeError: Invalid array length at CategoryAxis2.CategoryAxisBase2.setBaseXValues (CategoryAxisBase.js:189:46) at CategoryAxis2.CategoryAxisBase2.getCurrentCoordinateCalculatorInternal (CategoryAxisBase.js:150:14) at CategoryAxis2.AxisCore2.getCurrentCoordinateCalculator (AxisCore.js:969:40) The first case is totally suitable for me, I can remove some strange Suspender stuff I made and I don’t see coordinator errors anymore. Just wanted you to know that may be something went wrong. Thanks scichart team for great work.
  • Andrew Burnett-Thompson
    Hi Sergey, I logged a bug here as I can see some problems with this solution: there’s basic code to repro here: We will look at this and get back to you
  • Daniel madore
    Hi Sergey, a further fix s coming in build v2.1.2290 of SciChart.js. This is going through our build process now and should be published to npm in about an hour. Please test it when the new version is published on npm and let us know if all is resolved. Best regards, Andrew
  • You must to post comments

Hi Sergey,

Because of the way CategoryAxis works, it’s impossible to measure (draw) the chart without data, because category axis by its very definition is using the indexes to data to measure values and perform zooming, panning operations.

Obviously SciChart.js shouldn’t crash or throw errors, so let’s discuss what should be an acceptable solution when the chart is shown but no data on a category axis.

Which sounds more correct:

  • Blank the chart (no axis, gridlines) and stop throwing errors until CategoryAxis has data. Do not allow panning yet.
  • Show axis, gridlines and allow panning when there is no data. Have normal CategoryAxis behaviour resume after that

Best regards,

  • Sergey Chernyakov
    Hello, Andrew. Thanks for the reply. I need to discuss those options with my team and I will be back with response shortly. Just to clarify, if we are talking about stock charts, it looks like blank chart is a mandatory feature not only because of streaming/network delay, but also there are some regulations preventing any predefined security to be set as value source.
  • Andrew Burnett-Thompson
    we’re also going to have a chat here in the team to see what we can do. Potentially we can do an internal workaround where we treat the axis is a NumericAxis before adding data (would allow charts + scaling, panning). Ive created a task in our task-tracker for investigation & prioritisation.
  • Sergey Chernyakov
    Hello, Andrew. I’ve consulted with colleagues and we are OK with all the option you have provided. But first one looks more preferable.
  • Andrew Burnett-Thompson
    Hi Sergey, we have a solution, in progress now. It will involve sending a default start time & spacing to the axis, so that when there is no data we can perform calculations and allow zooming/panning of an empty chart. Will update you soon
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.