echarts javascript 前端 echart之dataZoom数据区域缩放组件 - })),
';
return tooltipContent;
}
},
axisPointer: {
link: { xAxisIndex: 'all' }
},
xAxis: Array.from({ length: 5 }, (_, index) => ({
gridIndex: index,
type: 'category',
boundaryGap: false,
show: index === 4,
axisLine:
index === 4
? { show: true, lineStyle: { type: 'dashed', color: 'red' } }
: null,
data: index === 4 ? daysOfWeek : null
})),
legend: {},
grid: [
{ top: '3%', left: 50, right: 120, height: '16%' },
{ top: '26%', left: 50, right: 120, height: '16%' },
{ top: '49%', left: 50, right: 120, height: '16%' },
{ top: '72%', left: 50, right: 120, height: '16%' },
{ top: '92%', left: 50, right: 120, height: '4%' }
],
dataZoom: [
{
type: 'inside',
xAxisIndex: [0, 1, 2, 3]
},
{
type: 'slider', // 滑块形式的滚动条
xAxisIndex: [0, 1, 2, 3], // 应用于哪个X轴(如果有多个的话)
bottom: '3%', // 滚动条距离图表底部的距离
height: '6%', // 滚动条的高度
showDataShadow: false // 不显示数据走势阴影
}
],
yAxis: Array.from({ length: 5 }, (_, index) => ({
gridIndex: index,
splitLine: { show: false },
type: 'value',
axisLabel: index === 4 ? { show: false } : null
})),
series: seriesData.map((data, index) => ({
name: String.fromCharCode(65 + index), // 'A', 'B', 'C', ...
xAxisIndex: index,
yAxisIndex: index,
data,
type: 'line',
areaStyle: index === 4 ? {} : null
})) 拼多多帮助力入口
};
效果图:
至于缩放条组件的样式修改及配置,可以参照官方文档
好文推荐