2012-08-26 66 views
0

OK,這應該是比較簡單的:添加圖例,以圓環圖 - jqPlot

enter image description here

  • 我加入了圓環圖,它不工作
  • 然而, '傳奇'(如Head (+)以及相應的顏色)不顯示。

代碼:

$(document).ready(function(){ 
    var s1 = [['Head (+)',<?php echo $headScore; ?>], ['Head (-)',<?php echo 6-$headScore; ?>]]; 
    var s2 = [['Body (+)',<?php echo $totalScore-$headScore; ?>], ['Body (-)',<?php echo 7-$totalScore+$headScore; ?>]]; 

    var plot3 = $.jqplot('linkchart', [s1,s2], { 
     title:"Score Profile", 
    seriesDefaults: { 
     // make this a donut chart. 
     renderer:$.jqplot.DonutRenderer, 
     rendererOptions:{ 
     // Donut's can be cut into slices like pies. 
     sliceMargin: 3, 
     // Pies and donuts can start at any arbitrary angle. 
     startAngle: -90, 
     showDataLabels: false 
     }, 
     legend: { show:true, location: 'e' } 
    } 
    }); 
}); 

我在做什麼錯?

回答

4

Kameleon,

看起來你犯了一個愚蠢的錯誤。 :)

首先結束seriesDefaults屬性,然後定義圖例。

您已將圖例置於seriesDefaults中。

var plot3 = $.jqplot('linkchart', [s1,s2], { 
    title:"Score Profile", 
     seriesDefaults: { 
      // make this a donut chart. 
      renderer:$.jqplot.DonutRenderer, 
      rendererOptions:{ 
       // Donut's can be cut into slices like pies. 
       sliceMargin: 3, 
       // Pies and donuts can start at any arbitrary angle. 
       startAngle: -90, 
       showDataLabels: false 
      } // Not here... 
     }, 
     //Place the legend here.... 
     legend: { show:true, location: 'e' } 
    }); 
}); 

我還沒有測試過它。但我認爲它應該起作用。

謝謝。 OMG!

+0

OMG!阿尼希,非常感謝!這真是一個非常愚蠢的人,但是......我實在無法真正發現自己! :-) –