首页 前端知识 Echarts 图表通用属性

Echarts 图表通用属性

2024-02-14 09:02:31 前端知识 前端哥 666 486 我要收藏

Echarts 图表通用属性

  • 1. 隐藏坐标轴和刻度
  • 2. 图例(legend)位置
  • 3.图例(legend)和图表的间距
  • 4. 左侧y轴文字左对齐
  • 5. 图表位置调整

1. 隐藏坐标轴和刻度

//同时隐藏坐标轴(xAxis,yAxis)和刻度:
xAxis: {
show: false
}
//单独隐藏坐标线:
axisLine: {
show: false,
lineStyle: {
...
} // 样式
}
//单独隐藏刻度线:
axisTick: {
show: false
}
//坐标轴文字倾斜:
axisLabel: {
interval: 0,
rotate: 45 // 角度
}
//label数据展示:
label: {
show: true, //开启显示
position: 'top', //在上方显示
textStyle: { //数值样式
color: 'aqua',
fontSize: 15
}
}
复制

2. 图例(legend)位置

legend: {
orient: 'vertical',
x:'right', //可设定图例在左、右、居中
y:'center', //可设定图例在上、下、居中
padding:[0,50,0,0], //可设定图例[距上方距离,距右方距离,距下方距离,距左方距离]
data: ['王者荣耀','微信','天天向上','穿越火线','网页']
},
复制

3.图例(legend)和图表的间距

grid:{
top:'25%',//距上边距
left:'25%',//距离左边距
right:'25%',//距离右边距
bottom:'25%',//距离下边距
},
复制

4. 左侧y轴文字左对齐

axisLabel:{//坐标轴刻度标签的相关设置。
interval:0,//横轴信息全部显示
rotate:0,//-15度角倾斜显示
color: '#7AB9FF',
fontSize: 12,
margin: 220,//刻度标签与轴线之间的距离。
left: -8,//整个echart位置
textStyle: {
align: 'left' //**
}
},
复制

5. 图表位置调整

center: [x,y]
复制
转载请注明出处或者链接地址:https://www.qianduange.cn//article/2015.html
标签
ecmascript
评论
还可以输入200
共0条数据,当前/页
会员中心 联系我 留言建议 回顶部
复制成功!