2011-10-25 78 views
1

我遇到了jqplot的问题,并将数据标签放置在堆叠图表上。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} 
     } 
    } 
+0

很没用过jqplot。但是,两个指针:1.为什么你有一个负边容差? 2.你可以尝试jqplot – Raghav

+0

的渲染器的“dataLabelNudge”属性Hi Srini - 我在边缘容忍中玩耍,这就是为什么它的消极。它并不会真正影响事物,因为数据标签是靠近图表边缘的。 – user1013543

+0

我认为“dataLabelNudge”属性仅适用于饼图和甜甜圈图表。 – user1013543

回答

2

记住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]];  

希望这会有所帮助,或者至少让您指出正确的方向。

1

试试这个dataLabelPositionFactor特性