*前言:最近的项目需求中,要求在水球图中加一条标准线(作为报警提示线)。
1、效果如下:
2、思路:
注意:如果是直接在水球图上画标线 是实现不了的。
所以我们换种思路(大佬指点了一下),在折线图上加,然后隐藏x,y轴。
3、代码如下:
const data = [0.68, 0.30]
option = {
// x轴
xAxis: {
show: false, // 不显示
},
// y轴
yAxis: {
show: false, // 不显示
},
grid: {
top: '2.5%',
right: '40',
bottom: '2.5%',
left: 0,
},
series: [{
type: 'liquidFill',
// shape: 'pin',
radius: '96%', // 半径大小
center: ['50%', '50%'], // 布局位置
data, // 水球波纹值
amplitude: 0,
waveAnimation: false,
outline: { // 轮廓设置
show: true,
borderDistance: 2, // 轮廓间距
itemStyle: {
borderColor: '#294D99', // 轮廓颜色
borderWidth: 4, // 轮廓大小
shadowBlur: 'none', // 轮廓阴影
}
},
}, {
type: 'line', // 折线图
markLine: {
silent: true, // 不触发鼠标事件
symbol: '', // 标线两端样式
lineStyle: { // 标线样式
color: '#f00',
type: 'solid'
},
data: [{ // 标线数据
yAxis: data[1], // y 轴
}]
}
}]
};
4、可根据基础代码继续延伸。欢迎大家来评论