//<div style="width: 100%;height: 220px" id="chart1"></div>
var myChart = echarts.init(document.getElementById('chart1'));
option = {
xAxis: {
type: 'category',
data: ["三月","四月","五月"]
},
yAxis: {
type: 'value'
},
grid:{//图表上下左右边距
x:50,
y:30,
x2:30,
y2:30
},
tooltip: {
trigger: 'axis' //点击展示点
},
dataZoom: [{
type: 'inside',
show: false,
realtime: true,
start: 0,//缩放条从0开始
end: 50 //缩放结束的百分比0-100
}],
series: [{
data: yAxis,
type: 'line',
smooth: true, //true 为平滑曲线,false为直线
itemStyle: {
normal: {
color: '#ff6600'
}
}
}],
formatter: function (params) {//处理自定义展示的数值
var res = params[0].value+"mA";
return res;
}
};
// 使用刚指定的配置项和数据显示图表。
window.onresize = myChart.resize;
myChart.setOption(option);