var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var option = {
legend: {
data: ['波长', '物理量']
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
xAxis: {
type: 'category',
data: ['12:03:04', '12:03:05', '12:03:06', '12:03:07', '12:03:08', '12:03:09', '12:03:10']
},
yAxis: [
{
"type": "value",
"name": "波长(单位,BM)",
"axisLabel": {
"show": true,
},
axisLine: {lineStyle: {color: 'rgba(0,0,0,.4)'}},
splitLine: {show: true, lineStyle: {color: 'rgba(0,0,0,.2)'}}
},
{
"type": "value",
"name": "物理量(单位,CM)",
"show": true,
"axisLabel": {
"show": true,
},
axisLine: {lineStyle: {color: 'rgba(0,0,0,.4)'}},
splitLine: {show: false}
},
],
series: [{
name: '波长',
yAxisIndex: 0,
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
smooth: true
}, {
name: '物理量',
yAxisIndex: 1,
data: [120, 232, 301, 434, 590, 630, 700],
type: 'line',
smooth: true
}]
};
if (option && typeof option === "object") {
myChart.setOption(option, true);
}
Done!