highchart.js无效。错误13

时间:2016-09-30 06:01:29

标签: javascript jquery highcharts

这是错误的图像:

enter image description here

此错误13始终显示。我只是找不到highchart.js无效的原因。任何人都可以帮我解决这个问题吗?谢谢

<?php 
    $q = $this->db->query("select * from scli_tbl_services");

    foreach ($q->result() as $row) {
       $data[] = $row->service_id;
    }
?>

<script type="text/javascript">
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'chart_sample'
        },
        series: [{
            data: [<?php echo join($data, ',') ?>],
            pointStart: 0,
            pointInterval: 10
        }]
    });
</script>

<span id="chart_sample" class="chart_sample"></span>

这是我即将运行的代码。所以我不知道我的代码是否也正常工作。

1 个答案:

答案 0 :(得分:-1)

HighChart.Js解决方案:

<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 300px"></div>

<?php
$newArray = array(
    "Valvo" => Array(10,15,20),
    "ACBUS" => Array(25,30,15),
    "SchoolBus" => Array(25,30,15),
    "MiniBus" => Array(25,30,15),
    "CityBus" => Array(25,30,15)
);

$json_array_form = array();
$data = '';
foreach ($newArray as $key => $value){
   $json_array_form['name'] = $key;
   $json_array_form['data'] = $value;
   $data    .= json_encode($json_array_form).',';
}
$data = substr($data, 0, -1);
?> 

// HighChart Js功能启动

<script>
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Fruit Consumption'
        },
        xAxis: {
            categories: ['Apples', 'Bananas', 'Oranges']
        },
        yAxis: {
            title: {
                text: 'Fruit eaten'
            }
        },
        series: [<?php echo $data;?>],
    });
});
</script>