var mychar2=echarts.init(document.getElementById('line'));
var option2={
title:{
text:'折线图'
},
xAxis:{
type:'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis:{},
series:[
{
type:'line',
data: [820, 932, 901, 934, 1290, 1330, 1320]
},
{
type:'bar',
data: [80, 93, 91, 94, 190, 130, 120]
}
]
};
mychar2.setOption(option2);
var mychar=echarts.init(document.getElementById('bar'));
var option={
title:{
text:'柱形图'
},
legend:{},
xAxis:{
name:'星期',
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis:{},
series:[
{
data:[
120, 20, 150, 80, 70, 110, 130
],
type:'bar',
name:'2017年'
},
{
data:[
120, 20, 150, 80, 70, 110, 130
],
type:'bar',
name:'2018年'
}
]
};
mychar.setOption(option);
通过dataset上面的option代码可以简化为
var option={
title:{
text:'使用dataset管理数据'
},
legend: {},
tooltip: {},
dataset:{
source:[
['product','2017','2018'],
['Mon','120','123'],
['Tue','110','173'],
['Wed','100','113'],
['Thu','90','103'],
['Fri','80','113'],
['Sat','80','133'],
['Sun','125','128']
]
},
xAxis:{type:'category'},
yAxis:{},
series:[
{type:'bar'},
{type:'bar'}
]
};