I think the reason why the functionality of resizing highchrts is not working you can find it from the documentation of 'reflow' from hightcharts

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.

The situation matches what you did now: you tried to resize the div itself but not the window size, so it doesn't work as you expected.

What I did to make my charts resizable in grid as following:

  1. Create a function to do reflow
const onLayoutChange = () => {
    for (let i = 0; i < Highcharts.charts.length; i += 1) {
      if (Highcharts.charts[i] !== undefined) {
        Highcharts.charts[i].reflow(); // here is the magic to update charts' looking
  1. Use onLayoutChange provided by react-grid-layout
    onLayoutChange={() => onLayoutChange()}

And then...BANG! you got resizable charts controlled by the resize button in react-grid-layout.

Make it easy to understand, you can view my playground here:


Here is the sample solution to make it fit in the Grid....

import React from 'react';
import './App.css';
import '/node_modules/react-grid-layout/css/styles.css';
import '/node_modules/react-resizable/css/styles.css';
import GridLayout from 'react-grid-layout';
import Highcharts from "highcharts/highstock";
import HighchartsReact from "highcharts-react-official";

const options = {
  series: [
      data: [1, 2, 3]

class MyFirstGrid extends React.Component {
  constructor(props) {
    this.myRef = React.createRef();
    this.conRef = React.createRef();

  render() {
    // layout is an array of objects, see the demo for more complete usage
    var layout = [
      { i: "a", x: 0, y: 0, w: 5, h: 5 },
      { i: "b", x: 1, y: 0, w: 3, h: 2 },
      { i: "c", x: 4, y: 0, w: 1, h: 2 }
    return (
        onResizeStop={function(event) {

          console.log('hello', event);
        <div ref={this.conRef}  style={{ backgroundColor: "#00000000" }} key="a">
            ref= {this.myRef}
            containerProps={{ style: { width: '100%', height: '100%' } }}

        <div style={{ backgroundColor: "red" }} key="b">
        <div style={{ backgroundColor: "blue" }} key="c">

export default MyFirstGrid;


So, I was struggling with the same issue using highcharts-react-official and react-grid-layout.

Here is how I finally got it working.


  1. Give height 100% to all of your chart's parents up to the grid item.
  2. There is an annoying div that highcharts creates by himself. Find a way to identify it and give it height 100%.
  3. Give height 100% to the chart itself.
  4. Use the react highcharts callback to get your chart object.
  5. When your component updates reflow your chart.

Below is my responsive grid layout, just to give some context.

// Component/Grid/Grid.js
    { =>
        <Card key={widget.DWG_ID}>

Now, inside the Widget Component, set the height of any div that will be a parent of your highchart to 100%.

// Component/Widget/Widget.js
<CardBody className="widgetContent">
    <CardTitle className="widget-title">{this.props.widget.DWG_LABEL}</CardTitle>

For the jsx above I only needed to do this for the element CardBody with class widgetContent, so

// Component/Widget/Widget.css
.widgetContent { height: 100%; }

Now, in the chart component (where all the fun was), I had to create a very ugly div just to be able to identify the outer-most div that highcharts creates.

elements created by highcharts

The infamous div in question can be seen in the image above, right under the div with class highchartsWrapper, with the property data-highcharts-chart . This div was the only parent of my chart that I could not identify directly to give 100% height. So I created the wrapper to be able to identify it unequivocally. Note that in the chart options we passed a class name as well, to be able to give the chart itself the css height property.

If anybody has a neater idea of how to identify this problematic div please let me know.

// Component/Chart/Chart.js
options = {
    chart: { className: 'chart' }
<div className="highchartsWrapper">
        callback={(chart) => this.setChart(chart)}

So I could give it the css

// Component/Chart/Chart.css
.highchartsWrapper > div {
    height: 100%;
.chart {
    height: 100%;

Now your highchart would ideally assume the correct width and height. But there was another complication: when the highchart renders for the first time and checks his parent's height, react-grid-layout isn't yet done with his resizing magic. This means your chart will be teeny-tiny. Moreover, when you resize your grid items you want your highchart to resize to its new parent size. But wait, I've worked with highcharts before, I know how to do this! The good old chart.reflow() ! Unfortunately this ended up not being that easy.

To start with, just getting the chart object on which I can call reflow wasn't very straightforward. If you notice, I gave my HighchartsReact a callback

(chart) => this.setChart(chart)

This is just to store the chart object as a property of my class component. My setChart function does only the following:

setChart(chart) {
    this.chart = chart;

It might seem stupid to do it like this. Why not just give setChart directly to the callback property of HighchartsReact? Well because if you do, as per the highcharts-react-official documentation, your this inside the setChart function would be your chart object... All very confusing, but it seems to work like this.

Again, if somebody has a neater solution, let me know

Finally, we can call our this.chart.reflow() when our Chart Component is updated. what I did was something like

constructor() {

    this.firstResize = true;

componentDidUpdate(prevProps) {

    if (this.didWidgetSizeChange(prevProps) || this.isFirstResize) {
        this.isFirstResize = false;

When the component updates we call the chart reflow. On the componentDidMount the grid item doesn't have his final size yet, so I used a flag to figure out the first update (that would be exactly that: grid item has finished first resize). Then for any other update I wrote a function that basically compares the previous layout for this grid item with the new to decide if the size or width have changed. If so, we reflow again to resize the highcharts to the new grid item size.

Hope this helps!


Related Query

More Query from same tag