1
我有一個從json獲取數據的谷歌條形圖。它是月度客戶流程圖,它顯示所有月份的日期和相應的客戶流量。現在,我想要顯示最大客戶流量的酒吧以藍色着色,其餘的酒吧都是灰色的。 如:谷歌條形圖中的顏色個別酒吧
^
| ...
|-----Grey--------
|-----Blue------------
|-----Grey----------
|-----Grey--------
|-----Grey----------
| ...
|__________________________________>
這是JSON的一部分:這樣做的
$table = array();
$table['cols'] = array(
/* define your DataTable columns here
* each column gets its own array
* syntax of the arrays is:
* label => column label
* type => data type of column (string, number, date, datetime, boolean)
*/
// I assumed your first column is a "string" type
// and your second column is a "number" type
// but you can change them if they are not
array('label' => 'Dates as in '.$mon, 'type' => 'string'),
array('label' => 'Revenue', 'type' => 'number')
);
$rows = array();
while($r = mysql_fetch_assoc($query)) {
$temp = array();
// each column needs to have data inserted via the $temp array
$temp[] = array('v' => $r['date']);
$temp[] = array('v' => (int) $r['amount']); // typecast all numbers to the appropriate type (int or float) as needed - otherwise they are input as strings
// insert the temp array into $rows
$rows[] = array('c' => $temp);
}
// populate the table with rows of data
$table['rows'] = $rows;
// encode the table as JSON
$jsonTable = json_encode($table);