我正在将Google图表与Codeigniter一起使用,但出现错误,我不知道为什么
这是我的JavaScript
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
[{type: 'string', label: 'Name'}, {type: 'number', label: 'Count'}],
<?php
if ($results) {
foreach ($results as $result) {
echo '[' . $result->maquina . ' , ' . $result->contador. '],' ;
}
}
?>
]);
var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
},
bars: 'horizontal' // Required for Material Bar Charts.
};
var chart = new google.charts.Bar(document.getElementById('barchart_material'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
</script>
我收到此错误。
SyntaxError: missing ] after element list[Aprender más]
verEstado:299:19
note: [ opened at line 299, column 8
在开发人员工具中,我可以看到这些数据。