score:1

Accepted answer

from highcharts api:

reflow([e])

reflows the chart to its container. by default, the chart reflows automatically to its container following a window.resize event, as per the chart.reflow option. however, there are no reliable events for div resize, so if the container is resized without a window resize event, this must be called explicitly.

as a solution, call reflow method after width change.

  useeffect(() => {
    const chart = chartcomponent.current?.chart;

    if (chart) chart.reflow(false);
  }, [width]);

live demo: https://stackblitz.com/edit/react-zydh8m?file=index.js

api reference: https://api.highcharts.com/class-reference/highcharts.chart#reflow


Related Query

More Query from same tag