1、可以看官网api的入门例子
使用常见的对象数组的格式
option = { legend: {}, tooltip: {}, dataset: { // 这里指定了维度名的顺序,从而可以利用默认的维度到坐标轴的映射。 // 如果不指定 dimensions,也可以通过指定 series.encode 完成映射,参见后文。
dimensions: ['product', '2015', '2016', '2017'], source: [ {product: 'Matcha Latte', '2015': 43.3, '2016': 85.8, '2017': 93.7}, {product: 'Milk Tea', '2015': 83.1, '2016': 73.4, '2017': 55.1}, {product: 'Cheese Cocoa', '2015': 86.4, '2016': 65.2, '2017': 82.5}, {product: 'Walnut Brownie', '2015': 72.4, '2016': 53.9, '2017': 39.1} ] }, xAxis: {type: 'category'}, yAxis: {}, series: [ {type: 'bar'}, {type: 'bar'}, {type: 'bar'} ] };
第一个默认时x轴,后面是y轴
2、项目应用:
数据格式:
数据:
//5种不同维度
dimensions:[ ['snap_time','active','idle','total'], ['snap_time','commits','rollbacks','transactions'], ['snap_time','inserts','updates','deletes'], ['snap_time','fetched','returned'], ['snap_time','reads','hits'] ], //dataset数据
dataset:{ dimensions:this.lineDime, source:this.lineSeries//source取的全部数据
}, series: this.series //series数据
let _obj = { type:'line' } this.series.length = this.lineDime.length - 1
this.series.fill(_obj)
效果: