【前言】
Echarts----折线图 demo
//数据
var XName= ["周一","周二","周三","周四","周五","周六","周日"]
var data1 = [
[123,154, 234, 321,120,390, 634],
[63,194, 234, 321,278,110, 534],
[53,254, 234, 321,118,240, 434],
[23,354, 334, 221,178,190, 234],
]
var Line = ["云篆山水路线","昕博朗学校路线","新华小学路线","云锦五路路线"];
var img = [
'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABRCAYAAABFTSEIAAAACXBIWXMAAAsSAAALEgHS3X78AAAEp0lEQVR42u3cz4sjRRTA8W9Vd3Vn8mMmjj9WQWSRZQ+CsH+B7MnDIgiCd0E8CYJ/gOAIelo8ehUP/gF6WLw5/gMueFP2sIcF0dHd2Z1kknR11fOQZJJJMtlZd03H7HtQpNOTnpn+8Lrm1etmjIig8e/DKoECKqACKqCGAiqgAiqghgIqoAIqoIYCKqACKqCGAiqgAiqghgIqoAJudKTr+osZMNPvBUQBHwHsPF9fB9R0DeHMOQ6T6WOrhEzXBM4swDOL0M6CrArRVoq3t2dGUIb9fTvatg8ZZup1PDBgzPmy98mey6qfzjLz2WaWjEUZKEvGyi9nWyneMOvGIyFQo2Sbg4MUSChpU9IeTTUpJdsEajPZOJeJG5uBZj7rLLduWS5dGm6XNLEELOFUFj54ACJCaychkpDSASK3bwsXL0YgVpWJKwM0iy9Zy8HdGru7jvt3Pbu7w0wES7drTwAbjTHMGCsQcIAnYTC1/wRx0wEnl27JNgZI8HQ6Kc1mQq83RNzaMjPzXqDbjTQaJRFLxIyyMSxAXEkWrhrQzAAmo5HOjCQf7jflILxOkohL+aUPgV4vEGNJo+E5PAy02+UIMEwBxo0CPDP7Dg5SnEtpt1PA0e87XO25FOoh8IYIH2Y5b45RzGAQBiIltZoHxqMcjbksXAVgdc2EQMYzzzdotyeZWKuleULXJtwT4SODfC2QCWR+IF9KnjuX1Xbo99Op7LVE8iXlz0YBTk5SyLEEjo5OLuccEoFUvHfO+reuUPx4zftXAIcx1hdcF+/TvFab4A0Bs0Vwqy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GUAQrOn3p2lOYlTzFxpdcr1k0xclOYV14jp1esm7jSlzyF10uT/OkMboimdDpXfR3dvz7vZvZ1Oj3a3QW6WFVVNClBnwwaRGGYgNN0YMsJAFhPlUysgioK0cvlxRb8FEfyBC+507mYGM9/G37OD4AubmxfDndbArTkCV7yNsADFDxBj9/Sy7mzw7MMhc9QeGvykbPDs7f0cj5BjwcoeBu4bKqHC4JbQOa9noHnWYge7WL2vHbnfJrbxdFlmSdoymySPXt+2wGwe62Pmz/cAvHedMRi/xKrg5uL+xnWZVm5voJZzE0s/KzKTcTZu3a7TdibjTB7e3vy+nBwG86r0G367xafd+DnthzwuZV4dy3i4caIF/EiXsSLEfEiXsSLeDEiXsSLeBEv4sWIeBEv4kW8GBEv4kW8iBcj4v0f4l+bPQ5YnMn04QAAAABJRU5ErkJggg==',
];
var color =['#00f8ff','#00f15a','#0696f9','#dcf776'];
//数据处理
var datas = [];
Line.map((item,index)=>{
datas.push(
{
symbolSize: 150,
symbol: img[index],
name: item,
type: "line",
yAxisIndex: 1,
data: data1[index] ,
itemStyle: {
normal: {
borderWidth: 5,
color: color[index],
}
}
}
)
})
option = {
backgroundColor: '#0e2147',
grid: {
left: '5%',
top: '5%',
bottom: '5%',
right: '5%',
},
legend: {
type: "scroll",
data:Line,
itemWidth:18,
itemHeight:12,
textStyle: {
color:"#00ffff",
fontSize:14
},
},
yAxis: [
{
type: 'value',
position: 'right',
splitLine: {
show: false
}
,
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: false
}
},
{
type: 'value',
position: 'left',
nameTextStyle: {
color: '#00FFFF'
},
splitLine: {
lineStyle: {
type: 'dashed',
color: 'rgba(135,140,147,0.8)'
}
},
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
formatter: '{value}',
color: '#fff',
fontSize: 14
}
},
],
xAxis: [
{
type: 'category',
axisTick: {
show: false
},
axisLine: {
show: false,
lineStyle: {
color: '#6A989E',
}
},
axisLabel: {
inside: false,
textStyle: {
color: '#fff',// x轴颜色
fontWeight: 'normal',
fontSize: '14',
lineHeight: 22
}
},
data: XName,
},
{
type: 'category',
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: false
},
splitArea: {
show: false
},
splitLine: {
show: false
},
//-----
data: ['1月', '2月', '3月', '4月', '5月', '6月'],
},
],
series: datas,
};
//当点击legend选项时折线上的小图片会消失,为避免这种情况,可以采取以下初始化方法 使用svg
//var myCharts = echarts.init(document.getElementById('AnalysisChartLine'), null, {renderer: 'svg'});
//myCharts.clear();
//myCharts.setOption(option)
感谢 Thanks!!!