flutter_echarts icon indicating copy to clipboard operation
flutter_echarts copied to clipboard

How to use box plot echarts for flutter

Open srishalu opened this issue 5 years ago • 3 comments

Hi Team,

I have implemented echart boxplot in flutter, i am stuck in providing data to the boxplot. there is no datatool in echarts configuration. If i provide set of array directly to data, only lines are drawing which is wrong.How to get instance of echarts to apply echarts.datatool.prepareboxplot for data.

Expected:

 data : echarts.datatool.prepareBoxplotData([
      [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980, 930, 650, 760, 810, 1000, 1000, 960, 960],
    ]);

Any help is really appreciated

srishalu avatar Dec 04 '20 06:12 srishalu

The instance is named chart :

data: chart.datatool.prepareBoxplotData

entronad avatar Dec 04 '20 07:12 entronad

That chart instance only not coming. how you will get chart instance and also datatool is not a property of chart in flutter. if you have any sample for boxplot in flutter please provide .

srishalu avatar Dec 04 '20 08:12 srishalu

I get your point now. The JavaScript loading order is:

await _controller?.evaluateJavascript('''
      $echartsScript
      $extensionsStr
      var chart = echarts.init(document.getElementById('chart'), $themeStr);
      ${this.widget.extraScript}
      chart.setOption($_currentOption, true);
    ''');

So I think you can add your data preparation in extraScript and give it a name:

var myData = echarts.datatool.prepareBoxplotData([
      [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980, 930, 650, 760, 810, 1000, 1000, 960, 960],
    ]);

and use it in option:

data: myData,

The disadvantage is that the data will not change when flutter widget state updates. You know echarts is a JavaScript object, we can't use it in flutter.

entronad avatar Dec 04 '20 08:12 entronad