lourens
Posts: 12
Joined: Sun Aug 01, 2021 7:11 pm

possible bug in getOverscrollPositions (in OrdinalAxis.ts)

First, I did not manage to lookup occurrences of getOverscrollPositions in this forum, I got a complaint that getOverscrollPositions occurs too often.

I am trying to start debugging my application from within typescript.
My knowledge of debugging javascript/typescript is limited,
so it may well be I should ignore/disable some error messages in Chrome.

I may be working from a somewhat older version of the highchart sources (~ 2 months old).
Somewhere a call is done to Axis.setScale() in my application.
In debug mode chrome barfs on
OrdinalAxis.ts:1402 : "Uncaught TypeError": Assignment to constant variable.
With my limited experience with typescript, I do seem to understand that the code (which I pasted from github):

Code: Select all

public getOverscrollPositions(): Array<number> {
            const ordinal = this,
                axis = ordinal.axis,
                extraRange = axis.options.overscroll,
                distance = ordinal.overscrollPointsRange,
                positions = [],
                max = axis.dataMax;

            if (defined(distance)) {
                // Max + pointRange because we need to scroll to the last

                while (
                    (max as any) <= (axis.dataMax as any) + (extraRange as any)
                ) {
                    (max as any) += (distance as any);
                    positions.push(max);
                }

            }

            return positions as any;
        }
would be problematical if distance is defined, as the

Code: Select all

const max
value is being changed.
I could try to find out whether distance in practice should always be undefined here, but could you have a look whether this is a bug?
I somehow suspect, that I should disable exceptions that are thrown in debug mode (chrome) by highcharts code.
If debug mode is off, my chart loads.
I also notice other exceptions being thrown in debug mode under slightly different conditions
(i.e. Uncaught TypeError: Cannot read properties of null Point.js:249)

Thanks,
Lourens
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: possible bug in getOverscrollPositions (in OrdinalAxis.ts)

Hi,
Thanks for your message.

This is descriptions from our core code (/highcharts/ts/Core/Axis/OrdinalAxis.ts)
* Get ticks for an ordinal axis within a range where points don't
* exist. It is required when overscroll is enabled. We can't base on
* points, because we may not have any, so we use approximated
* pointRange and generate these ticks between Axis.dataMax,
* Axis.dataMax + Axis.overscroll evenly spaced. Used in panning and
* navigator scrolling.

To report this like a bug I need to replicate it, could you create a simple online version where I can check it?

Best regards.
Sebastian Hajdus
Highcharts Developer

Return to “Highcharts Usage”