A plurality of adaptive screen size echarts FIG.

When a echarts FIG, can do so

// The following my_charts html is in the ID echarts
  var myChart= echarts.init(document.getElementById("my_charts"));
  myChart.setOption(option);
// assumed name is myChart example, after completion echats configuration example, the following lines can be arranged
  window.onresize = function () {
    myChart.resize();
  }

When there are a plurality of FIG echart, but at different respective instance of js function, you need to define a global object, then each instance of an object into an instance id and echart global object, then adaptive unified

was chartJson;
func1 () {
    var myChart = echarts.init(document.getElementById('id1'));
...
    myChart.setOption(option);
    chartJson['id1'] = myChart;
}
func2(){
...
}
func3(){
...
}
// unified adaptive 
$ (function () {
  func1 ();
  func2 ();
  func3 ();
   window.onresize = function() {
      chartJson['id1'].resize();
      chartJson['id2'].resize();
      chartJson['id3'].resize();
   };
})

 

Guess you like

Origin www.cnblogs.com/HexUha/p/11141705.html