Resize highcharts using react-grid-layout not working

后端 未结 2 545
再見小時候
再見小時候 2021-02-06 15:14

I am working in react and using highcharts with react-grid-layout to resize the elements in div. Somehow resizable feature is working for images but not with highchart. Grid.js

2条回答
  •  没有蜡笔的小新
    2021-02-06 15:20

    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) {
        super(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 (
          
            
    b
    c
    ); } } export default MyFirstGrid;

提交回复
热议问题