我正在使用flot来绘制图表。我想实现这样的功能,以便我能够在图表中突出显示 10% 的增长,以与我现在使用的颜色不同的颜色显示。 我正在使用的代码是:
var options_blue = {
series: {
color: 'blue',
threshold: { above: 5, color: 'green' },
bars: { show: true, barWidth: 20 * 20 }
},
xaxis: { show: false, min: 1 },
yaxis: { show: false, min: 1, max: max_value }
};
var options_red = {
series: {
color: '#ff0000',
threshold: { above: 10, color:'green' },
bars: { show: true, barWidth: 20 * 20 }
},
threshold: { above: 5, color: "yellow" },
xaxis: { show: false, min: 1 },
yaxis: { show: false, min: 5, max: max_value }
};
我正在使用jquery.flot.threshold.js,但图形颜色没有超出阈值的变化。
最佳答案
您正在使用“above”,但阈值插件仅支持“below”。因此,您只需交换系列和阈值颜色,并使用“下方”即可。
另请注意,在 options_red 中,您在系列选项之外还有第二个阈值选项。阈值插件仅查找系列选项中的选项,因此第二个选项将被忽略。
关于jquery - 使用 flot api 实现条形图的阈值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16439464/