I'm trying to extend my usage of HighCharts and MySQL/PHP to the pie charts,
But I'm not sure how to add the series data.
My SQL query produces a table like:
group value
south 34532
east 23411
west 23422
north 23421
Then I write the fetch_array (maybe my value is a string and should be int?)
while($row = mysql_fetch_array($result))
{
extract($row);
$data[] = "[$group, $value]";
}
mysql_close($connId);
?>
Then try to put the series into the HighCharts js:
series: [{
type: 'pie',
name: 'Test Data',
data: [<?php echo '[' .join($data, ','). ']' ?>]
}]
It doesn't produce a pie chart, no error, just blank DIV.
I solved it like this:
while($row = mysql_fetch_array($result))
{
extract($row);
$datapie[] = array($group, intval($val));
}
mysql_close($connId);
$data = json_encode($datapie);
?>
And the series JS data like:
series: [{
type: 'pie',
name: 'Test Data',
data: <?php echo $data; ?>
}]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.