Hello!
Tell me what I’m doing wrong?
The error does not always appear (floating error).
In my code, along the stack, it will go to your product
- Roman Gavrilow asked 3 years ago
- last edited 3 years ago
- You must login to post comments
AxisBase2D.js. if !this.parentSurface or visibleSeries is an empty array or !xVisibleRange or !range, then maxRange will also be undefined
The static code analyzer will sound an alarm that there will probably be an attempt to use an uninitialized variable. Do you use static code analyzers?
- Roman Gavrilow answered 3 years ago
- last edited 3 years ago
- You must login to post comments
the problem went away when I commented out yAxis.growBy = new NumberRange (0.35, 0.15)
javascript
createMainYAxis () {
const yAxis = new NumericAxis(this.wasmContext)
yAxis.drawMinorTickLines = false
yAxis.majorGridLineStyle = {
strokeThickness: 1,
color: 'rgba(238, 238, 238, 0.1)'
}
// yAxis.growBy = new NumberRange(0.35, 0.15) // by commenting out this line the error disappears
yAxis.autoRange = EAutoRange.Always
this.mainYAxis = yAxis
this.chartSurface.yAxes.add(yAxis)
},
- Roman Gavrilow answered 3 years ago
- You must login to post comments
Hi Roman
Thank you for your feedback on this. It’s a strange error as AxisBase.getWindowedYRange() should not be called unless axis is in a Parent SciChartSurface, but the error only occurs when parent SciChartSurface is undefined.
I’m curious what exact set of circumstances you have in code to get this bug? We never saw it in tests or development.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 3 years ago
- You must login to post comments
In JavaScript almost everything is an object, null and undefined are exceptions. This error occurs when a property is read or a function is called on an undefined variable. Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.
If you are not sure a variable that will always have some value, the best practice is to check the value of variables for null or undefined before using them. To avoid getting these types of errors, you need to make sure that the variables you are trying to read do have the correct value. This can be done in various ways. You can do if checks before dealing with objects whose values are bound to change:
if (myVar !== undefined) {
...
}
Or
if (typeof(myVar) !== 'undefined') {
...
}
- hlipper john answered 2 years ago
- You must login to post comments
Please login first to submit.