我在jqplot和在堆叠图上定位数据标签时遇到了问题。
我为每列绘制了三个数据值。问题是当其中一个数据值非常小时,例如1%,数据标签与相邻数据值的标签重叠。
我在这里上传了一张图片:http://img84.imageshack.us/img84/1305/capturell.jpg
我想要做的是能够将数据标签定位在每个栏的中间。这个是可能的吗?
下面是我使用的代码:
plot1 = $.jqplot(id, data, {
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {
fillToZero: true,
highlightMouseOver: false,
highlightMouseDown: false,
highlightColor: null,
barDirection: 'horizontal'
},
pointLabels: { show: true, location: 'e', edgeTolerance: -15 }
},
title:{text: title,fontSize: 16},
series:[
{label: data_labels[0] },
{label: data_labels[1]}
],
seriesColors: [ "#4879a6", "#d9321d"],
// Rotate the bar shadow as if bar is lit from top right.
shadowAngle: 135,
axes: {
xaxis: {
min: 0,
max: 100,
tickInterval: 20,
tickOptions: {formatString: '%d\%' ,fontSize: 14}
},
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks,
tickOptions: {fontSize: 14}
}
}发布于 2011-10-28 23:28:00
请记住,seriesDefaults只是将相同的值传递给序列中尚未定义的每个实例。所以..。
seriesDefaults:{pointLabels: {show: true, stackedValue: false, location:'s'}}, 等同于
series:[
{pointLabels: {show: true, stackedValue: false, location:'s'}},
{pointLabels: {show: true, stackedValue: false, location:'s'}},
{pointLabels: {show: true, stackedValue: false, location:'s'}}
] 在jqplots网站上,他展示了这个例子。http://www.jqplot.com/deploy/dist/examples/point-labels.html
这显示了一个名为y-padding值,该值被传递给pointLabels,这应该可以完成此任务。该示例展示了如何在传递给jqplot的数据数组中传递自定义点值标记。如果你能在边上加上一些html来设置数据标记的样式,我不会感到惊讶的。
var data = [[x,y,tooltipValue],[x,y,null]]; 希望这对你有所帮助,或者至少让你找到正确的方向。
发布于 2012-04-13 16:10:06
尝试此dataLabelPositionFactor属性
https://stackoverflow.com/questions/7895951
复制相似问题