Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"hasGroupedData" with multiple series does not return the right status #17141

Closed
ernstfabian opened this issue Mar 31, 2022 · 1 comment · Fixed by #17164
Closed

"hasGroupedData" with multiple series does not return the right status #17141

ernstfabian opened this issue Mar 31, 2022 · 1 comment · Fixed by #17164

Comments

@ernstfabian
Copy link

ernstfabian commented Mar 31, 2022

Expected behaviour

Returning "true" or "undefined" when calling "hasGroupedData" on a series, depending if the data is currently beeing grouped.

Actual behaviour

When two or more series are displayed, it always returns "true" once it returned "true" at least once.
When there is only one series inside the graph it works as expected - returns "true" when the data is beeing grouped and "undefined" when zoomed in far enough where grouping is not applied. Also returns back to "true" when you reset the zoom and back to "undefined" when zoomed in again.

Live demo with steps to reproduce

Stackoverflow
https://jsfiddle.net/Itsearnest/ho0a4zw9/

Product version

Highstock v10.0.0

Affected browser(s)

Tested on Firefox, Chrome and Edge

@ernstfabian ernstfabian changed the title "hasGroupedData" when multiple series does not return the right status "hasGroupedData" with multiple series does not return the right status Mar 31, 2022
@karolkolodziej
Copy link
Contributor

Works well in version 9.1.2: https://jsfiddle.net/BlackLabel/jfg1zh8a/

Internal note:
Bisected to commit 2f23d6a

The getGroupPixelWidth in the applyGrouping method returns a value greater than zero when it shouldn't.
Then based on that knowledge the grouping is being applied.

Before the getGroupPixelWidth the groupPixelWidth is reset but only for the current series.
Because of that getGroupPixelWidth falsely take the groupPixelWidth from the previously calculated series.
Where previously means previous extremes and different arrangement of points unrelated to the current state of chart and series.

if (
series[i].groupPixelWidth ||
(
dataLength >
((this.chart.plotSizeX as any) / groupPixelWidth)
) ||
(dataLength && dgOptions.forced)
) {
doGrouping = true;
}

The suggested fix is to apply code from the snippet below before the group pixel calculation.

series.forEach(function(series) {
   series.groupPixelWidth = void 0;
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants