- SciChartSurface created with category x and numeric y axes
- ZoomPanModifier, ZoomExtentsModifier, MouseWheelZoomModifier, RolloverModifier added.
- Any series and dataSeries are initialized and added to the surface, but not filled with values yet.
- 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
- Sergey Chernyakov asked 3 years ago
- You must login to post comments
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,
Andrew
- Andrew Burnett-Thompson answered 3 years ago
-
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.
-
Hi Sergey, I logged a bug here as I can see some problems with this solution: https://abtsoftware.myjetbrains.com/youtrack/issue/SCJS-1061 there’s basic code to repro here: https://github.com/ABTSoftware/SciChart.JS.Examples/tree/dev_v2.x/Sandbox/CustomerExamples/CategoryAxisNoData. We will look at this and get back to you
-
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 login 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,
Andrew
- Andrew Burnett-Thompson answered 3 years ago
-
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.
-
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.
-
Hello, Andrew. I’ve consulted with colleagues and we are OK with all the option you have provided. But first one looks more preferable.
-
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 login to post comments
Please login first to submit.