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

[Chart] Scrolling problems with live data #1457

Closed
TannerGilbert opened this issue Aug 6, 2020 · 4 comments
Closed

[Chart] Scrolling problems with live data #1457

TannerGilbert opened this issue Aug 6, 2020 · 4 comments
Labels
bug A broken behaviour that was working previously needs discussion P4 Low-priority issue that needs to be resolved

Comments

@TannerGilbert
Copy link

Bug Report

Expected Behavior

Scrolling should not be influenced by live graph.

Current Behavior

Bar Chart with live data creates problems with scrolling.

Steps to Reproduce

Used Versions:

  • typescript:3.8.3
  • @angular/cdk: 9.2.4
  • @dynatrace/barista-components: 7.6.0

Attachments

scroll-bug

@TannerGilbert TannerGilbert added the bug A broken behaviour that was working previously label Aug 6, 2020
@tomheller tomheller changed the title Scrolling problems with live data [Chart]: Scrolling problems with live data Aug 7, 2020
@tomheller
Copy link
Collaborator

tomheller commented Aug 7, 2020

This probably is again related to the things outlined in #1410.

When the series data is being set, the charts update function is called:

if (series instanceof Observable) {
this._dataSub = series.subscribe((s: DtChartSeries[]) => {
this._currentSeries = s;
this._update();
});

In this update function, we need to destroy the current chart object and reinstantiate it again. Highcharts has an update function, although this will not let the consumer update all properties of the series or chart options. This has been leading to problems in the past, which is why we implemented the re-instantiation functionality in 6df1df8.

Before the change, the update function looked like this, where the new series and options were passed to the Highcharts.update function.

private _updateChart(xAxisHasChanged: boolean): void {
if (this._chartObject) {
this._ngZone.runOutsideAngular(() => {
if (xAxisHasChanged) {
this._chartObject!.update({ series: [] }, false, true);
}
this._chartObject!.update({ ...this._highchartsOptions }, true, true);
});
this.updated.emit();
}
}

For a brief period of time during it's reconstruction, the chart element will have a height of 0, which causes the rescrolling.
@TannerGilbert as a workaround, this can be circumvented by setting a height on the container or the chart itself to prevent the reflow:
https://stackblitz.com/edit/scroll-bug-mvactj?file=src%2Fapp%2Fapp.component.scss

@ffriedl89 @lukasholzer One solution to this problem would be to read the current height of the chart in the update method and setting it onto the host element, and removing it again after the update. But I fear this could cause some side-effects. What do you think?

@tomheller tomheller added P4 Low-priority issue that needs to be resolved needs discussion labels Aug 7, 2020
@tomheller tomheller changed the title [Chart]: Scrolling problems with live data [Chart] Scrolling problems with live data Aug 7, 2020
@lukasholzer
Copy link
Contributor

Yea regarding the side effects I'm not sure as we always check for the this._chart._afterRender for example in the selection area (This Subject should be triggered) after resetting the height.

I think the best approach would be to test it out to gain insights on how it improves.

@TannerGilbert do you want to contribute this fix to the library? For sure we can assist you even with a pair programming session.

@TannerGilbert
Copy link
Author

@lukasholzer I'd like to assist in fixing the bug, but my knowledge of the barista codebase and highcharts is quite limited. Also the pair programming session sounds good to me. Maybe lets discuss a time for in on Slack.

@ffriedl89
Copy link
Collaborator

Moved to internal issue tracking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A broken behaviour that was working previously needs discussion P4 Low-priority issue that needs to be resolved
Projects
None yet
Development

No branches or pull requests

4 participants