Related to #6707.
Description of the feature
Right now, charts gets reflowed on window resize. Because of that, there's no automatic reflow on layout shifts. It would be nice to get reflow on changes to the dimensions of a chart's container instead.
Library related to the feature
Highcharts
Proof of Concept/Live example for the feature
Instead of listening for window resize here:
|
public setReflow(reflow?: boolean): void { |
|
const chart = this; |
|
|
|
if (reflow !== false && !this.unbindReflow) { |
|
this.unbindReflow = addEvent(win, 'resize', function ( |
|
e: Event |
|
): void { |
|
// a removed event listener still runs in Edge and IE if the |
|
// listener was removed while the event runs, so check if the |
|
// chart is not destroyed (#11609) |
|
if (chart.options) { |
|
chart.reflow(e); |
|
} |
|
}); |
|
addEvent(this, 'destroy', this.unbindReflow); |
|
|
|
} else if (reflow === false && this.unbindReflow) { |
|
|
|
// Unbind and unset |
|
this.unbindReflow = this.unbindReflow(); |
|
} |
|
|
|
// The following will add listeners to re-fit the chart before and after |
|
// printing (#2284). However it only works in WebKit. Should have worked |
|
// in Firefox, but not supported in IE. |
|
/* |
|
if (win.matchMedia) { |
|
win.matchMedia('print').addListener(function reflow() { |
|
chart.reflow(); |
|
}); |
|
} |
|
//*/ |
|
} |
We could use a ResizeObserver and listen for dimensions changes of the chart.renderTo element.
You can vote for this feature by adding a thumbs-up reaction to this post.
Related to #6707.
Description of the feature
Right now, charts gets reflowed on window resize. Because of that, there's no automatic reflow on layout shifts. It would be nice to get reflow on changes to the dimensions of a chart's container instead.
Library related to the feature
Highcharts
Proof of Concept/Live example for the feature
Instead of listening for window resize here:
highcharts/ts/Core/Chart/Chart.ts
Lines 1815 to 1847 in 561e76d
We could use a ResizeObserver and listen for dimensions changes of the
chart.renderToelement.You can vote for this feature by adding a thumbs-up reaction to this post.