2012-08-26 2 views
0

확인이 비교적 간단해야한다 :도넛 차트에 범례 추가 - 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

카메론,

어리석은 실수를 한 것처럼 보입니다. :)

먼저 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' } 
    }); 
}); 

아직 테스트하지 않았습니다. 그러나 그것이 효과가 있다고 생각합니다.

감사합니다.

+0

OMG! Anish, 정말 고마워! 이것은 정말로 어리석은 사람이었다. 그러나. .. 내가 나 자신을 실제로 발견 할 수 없었던 사람! :-) –

관련 문제