Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
Echarts: resize is not a function

What I am trying to do is resize my echarts whenever my grid-item changes it layout. So according to react-grid-layout documentation, I call my chart.resize in the react grid layout callback function.

I initialize my chart instance in my NewvsReturnVisitors object and pass back that chart instance to index.js, below is the code

 function renderChart() {
    const renderInstance = echarts.getInstanceByDom(chart.current);

    if (renderInstance) {
      chartInstance = renderInstance;
    } else {
      chartInstance = echarts.init(chart.current, null, {
        width: 500,
        height: 300
      });
      props.value(chartInstance);
    }
    chartInstance.setOption(option);
  }

This is my onLayoutChange function inside index.js

 onLayoutChange(val) {
    // this.props.onLayoutChange(layout);
    // console.log("yc ", val);
    this.setState({ val: val.resize() });
  }


Then I pass it to the callback function inside ReactGridLayout component

...

  render() {
    return (
      <div className="DetailLocationContainer">
        <button onClick={this.onAddItem}>Add Item</button>
        <button onClick={this.onChartItem}>Add Chart</button>
        <ReactGridLayout
          onBreakpointChange={this.onBreakpointChange}
          onLayoutChange={this.onLayoutChange.bind(this)}
          {...this.props}
        >
          {_.map(this.state.items, (el) => this.createElement(el))}
          {_.map(this.state.charts, (el) => this.createChart(el))}
        </ReactGridLayout>
      </div>
    );
  }
}

The expected result:

chart.resize get call and resize my chart accordingly

Actual result:

error message resize is not a function

Click my codesandbox for the full code

Edit reactgridlayout-warning-failed-prop-type-duplicate-child-key-0-found

Really not sure where i am doing it wrong, really appreciate any help

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!