2012-05-09 1 views
1

막대 그래프와 원형 차트를 렌더링하는 데 다음 코드가 있습니다. A : : 115.00 B : 55.00 C : 0.00 D : 다음과 같이 두 서버에서 JSON 데이터의 동일한 세트를 수신 29.04JQPlot 막대 차트 OK이지만 원형 차트가 좋지 않음 - 동일한 입력 데이터 사용

을 몇 가지 이유를 들어, 막대 차트를 렌더링 할 수 있습니다. 그러나 원형 차트에는 아무 것도 표시되지 않습니다.

var AjaxDataRenderer = function(url, plot, options) { 
    var ret; 
    $.ajax({ 
     async: false, // Needed 
     url: "getData.php", 
     dataType:"json", 
     success: function(data) { 
      ret = data; 
     } 
    }); 
    return ret; 
}; 

var plot = $.jqplot('id-BarChart', [],{ 
    title: "TRIAL", 
    dataRenderer: AjaxDataRenderer, 
    seriesDefaults:{ 
     renderer:$.jqplot.BarRenderer, 
     rendererOptions: {fillToZero: true} 
    }, 
    series:[{color:'#5FAB78',label:"Actual"}], 
    legend: { 
     show: true, 
     placement: "insideGrid", 
     rendererOptions: { 
      textColor: "#FFFFFF", 
      fontSize: "10pt" 
     }}, 
    axes: { 
     xaxis: { 
      renderer: $.jqplot.CategoryAxisRenderer, 
      tickRenderer: $.jqplot.CanvasAxisTickRenderer , 
      tickOptions: { 
       angle: -30, 
       fontSize: '10pt' 
      } 
     }, 
     yaxis: { 
      min: 10, 
      max: 300, 
      tickOptions: { 
       formatString: '$%d' 
      } 
     } 
    } 
}); 

var plot = $.jqplot('id-PieChart', [],{ 
    dataRenderer: AjaxDataRenderer, 
    title: 'Expenditure pattern for this session', 
    seriesDefaults: { 
     renderer: jQuery.jqplot.PieRenderer, 
     rendererOptions: { 
      padding: 8,   
      showDataLabels: true 
      } 
    }, 
}); 

아무도 도와 줄 수 있습니까?

+0

: 원형 차트이 필요

$current = $category['ExpenditureCurrent']; $toDate = $category['ExpenditureToDate']; 

동안 JSON 형식으로 사용중인 JSON이 어떻게 보이는지에 대한 답변을 편집하십시오. – Boro

답변

0

일부 디버깅을 수행했는데 다음 작업을 발견했습니다.

내가 가지고있는 PHP 코드입니다 : 몇 가지 이유를 들어

$rows = array(); 
$rows1 = array(); 
$j = 1; 
while($category = mysql_fetch_assoc($allCategories)) 
{ 
$current = 0 + $category['ExpenditureCurrent']; 
$toDate = 0 + $category['ExpenditureToDate'];  
$j += 1;  
$rows[] = array($category['Name'], $toDate); 
$rows1[] = array($category['Name'], $current); 
} 
echo json_encode(array($rows,$rows1)); 

, 막대 차트는 이러한 작동 :

$current = 0 + $category['ExpenditureCurrent']; 
    $toDate = 0 + $category['ExpenditureToDate'];  
관련 문제