chart.setSize无法正常工作?

时间:2017-08-28 06:46:29

标签: javascript jquery html css highcharts

It is working only on window resize when on div(container) resize the chart is getting resized

从下面的代码中,您可以检查reactgridlayout的组件是否为draggable而不是文章中的图表。在窗口调整大小它工作正常我需要div调整大小(在纸张组件的draf)。

  onLayoutChange(layout) {
   console.log(layout);
   //chart.setSize(null, null);
   }

_loadSavedChart(){
   return (
      <ResponsiveReactGridLayout layouts={this.state.layout} 
        onLayoutChange={this.onLayoutChange}
        className={this.state.className}            
        rowHeight={this.state.rowHeight}
        cols={this.state.cols}
        initialLayout= {this.state.layout}
        initialWidth={this.state.initialWidth}
        width={this.state.width}
        verticalCompact={false}
        listenToWindowResize={false}
        currentBreakpoint= 'sm'
        >
      {this.state.savedChartinDashboard.map((data, i) => 
      <Paper key={i} className="c3chart" style={style.chartPaperStyle} zDepth={1}>{this._renderChart(data)}
      </Paper>
      )} 
    </ResponsiveReactGridLayout> )
  }

我需要在react组件中使用它而不是在jquery中。我有一个布局改变如何使用它。

$('#resizer').resizable({
// On resize, set the chart size to that of the
// resizer minus padding. If your chart has a lot of data or other
// content, the redrawing might be slow. In that case, we recommend
// that you use the 'stop' event instead of 'resize'.
resize: function () {
    chart.setSize(
        this.offsetWidth - 20,
        this.offsetHeight - 20,
        false
    );
}

});

0 个答案:

没有答案