这些东西要是有精力和时间可以通读echarts文档,里面都有配置详细介绍。该博客只是把自己使用echarts遇到的问题记录下,并不全,加深印象,抛砖引玉而已,完整学习的请移步官方文档
1、legend设置单选
legend: {
data:['db block gets', 'consistent gets'],
selectedMode: 'single',
},
2、添加缩放滚动
加上dataZoom配置
dataZoom: [
{
show: true,
realtime: true,
start: 65,
end: 85
},
{
type: 'inside',
realtime: true,
start: 45,
end: 85
}
],
需要配合grid配置给dataZoom留出底部位置
grid: {
top: 30,
bottom: 60
},
3、视图里面添加多个线条:在series数组里面继续加对象即可
series: [
{
name:'db block gets',
type:'line',
xAxisIndex: 1,//加这个dataZoom对该对象不起作用,需要去掉这个属性
smooth: true,//代表平滑曲线,如需要折线,则去掉即可
data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
},
{
name:'consistent gets',
type:'line',
smooth: true,
data: [3.9, 5.9, 11.1, 18.7, 48.3, 69.2, 231.6, 46.6, 55.4, 18.4, 10.3, 0.7]
}
]