echarts 增加x轴的缩放与滚动

该文章介绍了如何在Echarts中配置x轴的缩放和滚动功能,通过设置dataZoom属性,包括inside类型的内嵌滑动条以及外部滑动组件,调整start和end参数控制显示范围,并展示了相关的系列(series)配置,如line类型图表、标记线(markLine)等。
摘要由CSDN通过智能技术生成
echarts 增加x轴的缩放与滚动

主要属性 dataZoom
`
let initDom = null
const initChart = () => {
let option = {}
if (powerDate.value.length && powerVal.value.length) {
option = {
// echarts 图的位置
grid: {
top: 40,
left: 45,
right: 40,
bottom: 40,
},
// 提示框
tooltip: {
trigger: ‘item’,
},
left: ‘right’,
top: ‘5%’,
show: true,
legend: {
show: true,
top: ‘0’,
right: ‘50%’,
textStyle: {
color: ‘#B6D3EB’,
},
},
xAxis: {
type: ‘category’,
boundaryGap: false,
data: powerDate.value, // x轴数据
axisLine: {
show: false, // 隐藏x轴线
},
axisTick: {
show: false, // 隐藏x轴刻度
},
axisLabel: {
show: true,
margin: 20,
textStyle: {
fontSize: 16,
},
interval: ‘auto’,
},
},
yAxis: {
type: ‘value’,
axisLabel: {
show: true,
margin: 5,
textStyle: {
fontSize: 16,
},
},
splitLine: {
lineStyle: {
color: ‘#192B3C’,
type: ‘dashed’,
},
},
boundaryGap: [0, ‘100%’],
},
dataZoom: [
{
type: ‘inside’,
start: 0,
end: 30,
show: false, // 是否显示下面的滑动组件
},
{
start: 0,
end: 30,
show: false,
},
],
series: [
{
name: ‘右上角title’,
type: ‘line’,
symbolSize: 6, // 拐点大小
label: {
show: true,
position: ‘top’,
textStyle: {
color: ‘#fff’,
fontSize: 16,
},
},
data: [], // y轴数据
lineStyle: {
color: ‘#0099FF’,
},
markLine: {
data: xAxlist.length
? [
{
name: ‘标记线’,
yAxis: 1,
},
]
: [],
silent: true,
},
},
],
}
} else {
option = {
title: {
text: ‘暂无数据’,
x: ‘center’,
y: ‘center’,
textStyle: {
fontSize: ‘30px’,
fontWeight: ‘600’,
color: ‘#00cfff’,
},
},
}
}
nextTick(() => {
// 不要使用ref 包装echarts !!!
initDom = echarts.init(document.getElementById(‘consumptionEcharts’))
initDom.setOption(option, true)
})
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

九亿少女无法触及的梦ى

您的赞赏,对我来说意义非凡

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值