2016-02-24 52 views
2

我看到flotchart閾值add-in允許我使用帶點的線樣式進行圖示,如jsfiddle所示。jQuery flot圖表閾值

請注意,當您將點屬性從false切換爲true時,當線在零點處穿過x軸時會出現點。對於我的場景,我只想顯示對應於實際數據值的點,而不是當線恰好與x軸相交時。

points: { show: true } 

我讀過儘可能多的網上找到這個加載項,但似乎無法找到正確的配置參數。任何指針讚賞。

回答

2

您無法直接實現此目的,因爲生成折線圖的線段需要顏色改變的起點和終點,因此閾值插件必須添加這些點。

但是你可以用一種變通方法來實現它:添加兩個數據系列(使用相同的數據),以圖表,一個與線和一個與點(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)" 
}]); 
+0

謝謝你解釋和解決方法! – Gunnar