2012-04-27 77 views
1

我的jqPlot圖形包含200個垂直條。我用短短的條紋染成綠色,最長的是紅色,其他是黃色。jqPlot - 有沒有辦法只標註特定的條形圖?

如果我做

pointLabels: { 
    show: true 
} 

然後我得到200個標籤,這些都擠壓在一起,無法讀取。

是否可以標記最短和最長的條?

我讀過這個頁面,但一直無法找到一個解決方案:

http://www.jqplot.com/docs/files/plugins/jqplot-pointLabels-js.html#$.jqplot.PointLabels.seriesLabelIndex

回答

2

你爲什麼不通過時,「滴答」的圖表設置一些蜱空字符串""。 此外,我建議你使用這個設置旋轉蜱您的標籤:

tickRenderer: $.jqplot.CanvasAxisTickRenderer, 
tickOptions: { 
    angle: -45 
} 
+0

再次感謝:)我相信你的意思在這裏是什麼 '標籤' 而不是 '滴答'。但是你的建議對實現我想要的非常有幫助。 – jpen 2012-04-27 16:41:21

+0

是的,你是對的。您也可以將空字符串應用於相同方法以指向標籤。思考什麼時候旋轉我一直在使用這個渲染器的酒吧下方的滴答。 – Boro 2012-04-27 17:18:50

1

如果有人有興趣,這是我做的:

var shortest = 5; // find shortest somehow 
var longest = 10; // find longest somehow 

var myLabels = []; 
for (var i = 0; i < histogramData.length; i++) { 
    myLabels[i] = ""; 
} 

myLabels[shortest] = shortest; 
myLabels[longest] = longest;  

,然後設置以下jqPlot選項:

pointLabels: { 
    show: true, 
    labels: myLabels, 
    hideZeros: true 
} 

唯一的缺點是,這使得變焦有點慢,當你有很多x軸條目像我的情況。

+0

+1,讓您的解決方案可用。 – Boro 2012-04-28 09:03:34

0

據說jqplot不支持智能軸渲染,這意味着要截斷標籤,以便相鄰標籤不會發生衝突。但是你可以使用角度選項,這樣標籤就不會發生衝突。但是對於大量的數據,它也不會起作用。 jqplot只計算必要的座標軸,而不管圖表將要繪製的容器大小。

If you have worked with Google chart or like thing you can see they are not prioritizing axis ticks or something, they calculate the axis according to data and the plot area both. So the answer is even if you angle the tick labels you will come up with a limit. I'm not saying cheers! for this 

對不起!..

相關問題