2012-10-12 34 views
1

我想創建一個圖表上的兩個系列和閾值選項的flot折線圖。 我知道如何啓用閾值,當我只有1系列(如http://people.iola.dk/olau/flot/examples/thresholding.html)。jquery flot閾值與多個系列

問題是我不能用多個serie做到這一點。我的代碼:

var options = { 
       grid: { 
        hoverable: true, 
        borderWidth: 1, 
       }, 
       yaxis: { 
        min: 0, 
        max: 100 
       }, 
       xaxis: { 
        mode: "time", 
        timeformat: "%y-%m-%d", 
       }, 
       colors: ["rgb(44,55,66)","rgb(90,2,100)"] 

      }; 
      $.plot($('#chart' + i),[lang,reg], options); 

lang and reg是我的系列。我試圖把閾值選項options
threshold: { below: 90, color: "rgb(200, 20, 30)" } ..但它沒有工作,此外我想設置更多的一個顏色的閾值,所以它將是多個系列與多個顏色級別。
你知道如何解決嗎?謝謝。

回答

3

您需要做的是將您的系列從數組更改爲對象。

現在,你有你的數據是這樣的:

[lang,reg] 

你需要的是:

[{ 
    data:lang, 
    threshold: ... 
}], 
[{ 
    data:reg, 
    threshold: ... 
}] 

你可以看到它的外觀在這裏一個例子:http://jsfiddle.net/ryleyb/WXrJX/

+0

謝謝非常,這就是它! –