带有正负限制的javascript flot阈值(+/-)

时间:2014-07-08 05:22:13

标签: jquery flot

我需要用红色突出显示比标称值高100%或低100%的任何值,即0 +/- 100。

$.plot($("#right"),[{
    data:tot.fdat,
    color:'red',
    threshold:{below:100,color:'green'},
  }]
 })

以上方法可以突出显示高于+100的值,但是如何突出显示小于-100的值呢?

修改

根据@Kasyx的建议 - 这适用于轻微的mod:

$.plot($("#right"),[{
    data:tot.fdat,
    color:'red',
    threshold:[
      {below:100,color:'green'},
      {below:-100,color:'red'},
    ]
  }]
 })

1 个答案:

答案 0 :(得分:1)

在github页面上,您可以找到jquery.flot.threshold.js

An array can be passed for multiple thresholding, like this:

threshold: [{
    below: number1
    color: color1
},{
    below: number2
    color: color2
}]

所以在你的情况下它应该是这样的:

$.plot($("#right"),[{
    data:tot.fdat,
    color:'red',
    threshold:[
        {below:-100,color:'red'},
        {above:100,color:'red'},
    ],
  }]
 })