0
我想制作一个图表,我有数据库省份,并且我想将它作为Highcharts上的xAxis。查询从数据库中获取数据更改为数组
我的数据库
<?= \dosamigos\highcharts\HighCharts::widget([
'clientOptions' => [
'chart' => [
'type' => 'spline'
],
'title' => [
'text' => 'Fruit Consumption'
],
'xAxis' => [
'categories' => [
'Jabodetabek',
'Banten',
'Jawa Tengah',
'Jawa Timur',
'Medan',
'Riau',
'Bangka Belitung',
'Lampung',
'Kalimantan Selatan',
'Kalimantan Barat',
'Kalimantan Timur',
'Kalimantan Tengah',
'NTB',
'NTT',
'Papua']
],
'yAxis' => [
'title' => [
'text' => 'Fruit eaten'
]
],
'plotOptions' => [
'line' => [
'dataLabels' => [
'enabled'=> true
]
]
],
'series' => [
['data' => [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
],
'responsive' => [
'rules' => [[
'condition' => [
'maxWidth' => 500
],
'charOptions' => [
'legend' => [
'align' => 'center',
'verticalAlign' => 'bottom',
'layout' => 'horizontal'
],
'yAxis' => [
'labels' => [
'align' => 'left',
'x' => 0,
'y' => 0
],
'title' => [
'text' => null
]
]
]
]]
]
]
]);
如何使省表的内容为数组?我希望所有数据都由各省统计。
请帮帮我
如果您选择使用PDO,则可以使用http://php.net/manual/fr/pdostatement.fetchall.php将结果集转换为数组 – Paul