highcharts - php中highchart中的data赋值了,然后没显示什么,代码如下,谢谢
PHP中文网
PHP中文网 2017-04-10 17:34:21
0
0
376
<script src="assets/highcharts/highcharts.js"></script>
<script src="assets/highcharts/modules/exporting.js"></script>

<p class="row">
    <p id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></p>
</p>
<script>


    $(document).ready(function () {
        var options = {
            chart: {
                renderTo: 'container',
                type: 'line'
            },
            title: {
                text: '内存占用信息图',
                x: -20 //center
            },
            xAxis: {
                title: {
                    text: '时间'
                }
            },
            yAxis: {
                title: {
                    text: '单位:kb'
                }
            },
            legend: {
                enabled: false
            },
            series: []
        };
        $.getJSON("<?php echo $jsonUrl; ?>", function (json) {
            //console.log(json['data']);
            //options.xAxis.categories = json[0]['data']; //xAxis: {categories: []}

            var temp = json['data'];
            var data = [];
            for (i = 0; i < temp.length; i++) {

                date = temp[i].start_time;
                value = parseFloat(temp[i].memusg);
                data.push([
                    date,
                    value]);
            }

            //console.log(data);
            options.series[0] = data;
            chart = new Highcharts.Chart(options);
        });
    });
</script>

下面是data的值

PHP中文网
PHP中文网

认证0级讲师

Antworte allen(0)
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage