您无法直接实现此目的,因为生成折线图的线段需要颜色改变的起点和终点,因此阈值插件必须添加这些点。
但是你可以用一种变通方法来实现它:添加两个数据系列(使用相同的数据),以图表,一个与线和一个与点(updated fiddle):
var d1 = [];
for (var i = 0; i <= 10; i += 1) {
d1.push([i, parseInt(Math.random() * 30 - 10)]);
}
$.plot("#placeholder", [{
data: d1,
threshold: {
below: 5,
color: "rgb(200, 20, 30)"
},
lines: {
show: true,
fill: true
},
points: {
show: false
},
color: "rgb(200, 200, 130)"
}, {
data: d1,
threshold: {
below: 5,
color: "rgb(200, 20, 30)"
},
points: {
show: true
},
color: "rgb(200, 200, 130)"
}]);
谢谢你解释和解决方法! – Gunnar