2012-04-23 62 views
1

我使用flotr2,我在這裏寫了一個測試。 http://jsfiddle.net/yKqXM/如何在flotr2酒吧棧上添加標記(標籤)?

如果我想在每個條形堆棧上顯示標籤,我應該使用「標記」類型嗎?以及如何使用它。 我是flotr2的新手,你能否給我一份好的學習文章或文檔,以便我可以研究它。 對不起,如果這個問題很愚蠢,但我很沮喪尋找這個例子。

馬特

回答

2

是的,你可以使用 '標記' 屬性。實際上,你可以只需將條型後這個片段(您可以同時使用一次):

markers: { 
    show: true, 
    position: 'ct', 
}, 

然而,有一個小問題,與此有關。 Flotr2不尊重標記的堆疊位置,因此標記標籤將以錯誤的位置出現。

爲了解決這個問題,創建一些虛擬的數據集,其是堆的總和,並移動「酒吧」和「標誌」,在單獨的數據源直接指定。列出數據後的位僅是每個數據源的「默認」模式。

0

標記有很多非常有用的選擇。查看圖書館的來源。

Flotr.addType('markers', { 
    options: { 
     show: false,   // => setting to true will show markers, false will hide 
     lineWidth: 1,   // => line width of the rectangle around the marker 
     color: '#000000',  // => text color 
     fill: false,   // => fill or not the marekers' rectangles 
     fillColor: "#FFFFFF", // => fill color 
     fillOpacity: 0.4,  // => fill opacity 
     stroke: false,   // => draw the rectangle around the markers 
     position: 'ct',  // => the markers position (vertical align: b, m, t, horizontal align: l, c, r) 
     verticalMargin: 0,  // => the margin between the point and the text. 
     labelFormatter: Flotr.defaultMarkerFormatter, 
     fontSize: Flotr.defaultOptions.fontSize, 
     stacked: false,  // => true if markers should be stacked 
     stackingType: 'b',  // => define staching behavior, (b- bars like, a - area like) (see Issue 125 for details) 
     horizontal: false  // => true if markers should be horizontal (For now only in a case on horizontal stacked bars, stacks should be calculated horizontaly) 
    }