我需要在我的项目上实现谷歌图表,但它返回错误,因为我说..我的视图代码 字符串像几个月以及不工作的日子,数字很好..
我从codeigniter控制器和模型获得了这些数据,希望得到答案。
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1.1", {packages: ['bar', 'timeline']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
[{type: 'string', label: 'Days'}, {type: 'number', label: 'Viewers'}],
<?php
foreach ($chart_data as $data) {
$date = strtotime($data->view_time);
$day = date('D',
$date); //mon,tue
echo '[' . $day . ',' . $data->id . '],';
}
?>
]);
var options = {
chart: {
title: 'App viewers',
subtitle: 'Viewers: <?php echo 'Sun' . '-' . 'Sat'; ?>',
}
};
var chart = new google.charts.Bar(document.getElementById('columnchart_material'));
chart.draw(data, options);
}
</script>