Array无法在highchart php上显示数据

问题描述 投票:0回答:1

我正在尝试使用hightchar.js创建条形图我的代码如下所示:使用数组推无法在图表上插入数据获取数据

<?php
        $data_suhu = array();
        foreach($resultAll as $result){
            array_push($data_suhu,array(strtotime($result['waktu']),$result['suhu']));
        }
        die (json_encode($data_suhu));
        ?>

php获取有关图表数据的数据

<script>
                var chart = new Highcharts.Chart({
                      chart: {
                         renderTo: 'container1'
                      },
                      title: {
                            text: 'Grafik Data Suhu'
                        },

                    xAxis: {
                        title: {
                           enabled: true,
                           text: 'Hours of the Day'
                           },
                           type: 'datetime',
                           showFirstLabel:true,
                           showLastLabel:true,
                           dateTimeLabelFormats : {
                               hour: '%I %p',
                               minute: '%I:%M %p',
                               month: '%e. %b',
                                year: '%b'
                               }
                    },
                    series: [{
                            name: "Suhu",
                            data: [
                                [Date.UTC(<?php echo json_encode($data_suhu);?>)]
                            ]
                        }],

                        responsive: {
                                    rules: [{
                                        condition: {
                                            maxWidth: 500
                                        },
                                        chartOptions: {
                                            legend: {
                                                layout: 'horizontal',
                                                align: 'center',
                                                verticalAlign: 'bottom'
                                            }
                                        }
                                    }]
                            }
               });
             </script>


您可以在github https://github.com/bellabeen/simon-server上获得我的项目>

我正在尝试使用hightchar.js创建条形图。我的代码如下:使用数组推无法在图表上插入数据获取数据

javascript php
1个回答
0
投票

尝试使用

© www.soinside.com 2019 - 2024. All rights reserved.