1

我的 jqPlot 图包含 200 个垂直条。我将短路的条涂成绿色,最长的条涂成红色,其他的涂成黄色。

如果我做

pointLabels: {
    show: true
}

然后我得到 200 个点标签,它们都被压在一起,不可读。

是否可以只标记最短和最长的条形?

我已阅读此页面但无法找到解决方案:

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

4

3 回答 3

2

为什么不将 'ticks' 传递给图表时将一些刻度设置为空字符串""。我还建议您使用此设置来旋转刻度标签:

tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: {
  angle: -45
}
于 2012-04-27T16:20:51.653 回答
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 轴条目时,这会使缩放速度变慢。

于 2012-04-28T07:20:44.593 回答
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

对不起!..

于 2012-04-30T08:59:47.563 回答