定义图标框
<div id="main" style="width: 1200px;height:600px;"></div>
定义表结构
var myChart = echarts.init(document.getElementById('main'));
option = {
title: {
text: '服装销售'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
toolbox: {
feature: {
dataView: {
show: true,
readOnly: false
},
magicType: {
show: true,
type: ['line', 'bar']
},
restore: {
show: true
},
saveAsImage: {
show: true
}
}
},
legend: {
data: ['shirt', 'cardigan', 'Chiffon shirt', 'trousers', 'high-heeled shoes', 'Socks', ]
},
xAxis: [{
type: 'category',
data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月', ],
axisPointer: {
type: 'shadow'
}
}],
yAxis: [{
type: 'value',
name: '价格',
min: 0,
max: 50,
interval: 10,
axisLabel: {
formatter: '元'
}
},
{
type: 'value',
name: '价格',
min: 0,
max: 25,
interval: 5,
axisLabel: {
formatter: '元'
}
}
],
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
加入数据
{
name: 'shirt',
type: 'bar',
tooltip: {
valueFormatter: function(value) {
return value + ' 元';
}
},
data: [
5, 6, 12, 20, 21, 21, 15, 17, 8, 7, 22, 12
]
},
柱状图

折线图
