0
SQL 테이블에서 데이터를 가져 와서 json 인코딩 테이블에 추가하는 php 파일이 있습니다. 그런 다음 Dashboard/Control/Chart Wrapper 클래스를 사용하여 Google 차트 표 시각화로 읽습니다. 그러나 filterColumnlabel을 PHP/json 코드에서 내 열의 레이블 중 하나에 설정하려고하면 "하나 이상의 참가자가 그릴 수 없습니다"및 "잘못된 열 레이블 : 자동차"오류가 발생합니다.Google 차트 차트 래퍼 filterColumnLabel
제발 도와주세요, 제 json 테이블은 올바른 형식으로되어 있으며 오류의 원인을 파악할 수 없습니다.
$rows = array();
$flag = true;
$table = array();
$table['cols'] = array(
array('label' => 'Date', 'type' =>'string'),
array('label' => 'Car', 'type' =>'string'),
array('label' => 'Total Cost', 'type' =>'number'),
array('label' => 'Mileage', 'type' =>'number')
);
// $table = array(
// array('Date', 'Sales'),
// array('June 25', 12.25),
// array('June 26', 8.00)
//);
for ($x = 0; $x < $count; $x++)
{
$temp = array();
$temp[] = array('v' => (string) $dateComplete[$x]);
$temp[] = array('v' => (string) $Car[$x]);
$temp[] = array('v' => (float) $TotalCost[$x]);
$temp[] = array('v' => (float) $mpgAverage[$x]);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="Description" content="Basic Gray">
<title>Gas Log</title>
<link rel="stylesheet" href="stylesheets/default.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="javascripts/behavior.js"></script>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the controls package.
// Packages for all the other charts you need will be loaded
// automatically by the system.
google.load('visualization', '1.0', {'packages':['controls']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawDashboard);
function drawDashboard() {
// Everything is loaded. Assemble your dashboard...
var table = <?php echo json_encode($table);?>;
var data = new google.visualization.arrayToDataTable([table]);
console.log(table);
var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard_div'));
// Create a range slider, passing some options
var StringSlider = new google.visualization.ControlWrapper({
'controlType': 'StringFilter',
'containerId': 'control_div',
'options': {
'filterColumnLabel': 'Car'
}
});
// Create a pie chart, passing some options
var Chart = new google.visualization.ChartWrapper({
'chartType': 'ColumnChart',
'containerId': 'chart_div',
'options': {
'width': 300,
'height': 300,
'pieSliceText': 'value',
'legend': 'right'
}
});
// Establish dependencies, declaring that 'filter' drives 'pieChart',
// so that the pie chart will only display entries that are let through
// given the chosen slider range.
dashboard.bind(StringSlider, Chart);
// Draw the dashboard.
dashboard.draw(data);
}
</script>