尝试根据表格数据显示统计信息。 我想使用谷歌图表,但有一个谷歌未定义错误。仅显示 HTML 部分中的数据。不显示必要的条形图。 代码在jsfiddle上运行正常。代码如下:
google.charts.load('current',{'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Days','Service','Incident','Others'],['1-10 Days',10,6,4],['11-20 Days',2],['21-30 Days',4,4]
]);
var options = {
chart: {
title: 'TAT CHART',subtitle: 'Service,Incident,and Others',},bars: 'vertical',vAxis: {format: 'decimal'},height: 300,colors: ['#1b9e77','#d95f02','#7570b3']
};
var chart = new google.charts.Bar(document.getElementById('chart_div'));
chart.draw(data,google.charts.Bar.convertOptions(options));
google.visualization.events.addListener(chart,'select',function () {
var selection = chart.getSelection();
if (selection.length) {
var row = selection[0].row;
document.querySelector('#myValueHolder').innerHTML = data.getvalue(row,1);
var view = new google.visualization.DataView(data);
}
});
}
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
<br/>
<div id="disp_table">
<table class="display" style="width:50%;">
<thead>
<th>Days</th>
<th>Service</th>
<th>Incident</th>
<th>Others</th>
</thead>
<tbody>
<?php
for ($i = 0; $i < count($plot); $i++) {?>
<tr>
<td><?php echo $plot[$i][0]['days']; ?></td>
<td><?php echo $plot[$i][0]['service']; ?></td>
<td><?php echo $plot[$i][0]['incident']; ?></td>
<td><?php echo $plot[$i][0]['other']; ?></td>
</tr>
<?php }
?>
</tbody>
</table/>
尝试根据表格数据显示统计信息。 我想使用谷歌图表,但有一个谷歌未定义错误。仅显示 HTML 部分中的数据。不显示必要的条形图。 代码在jsfiddle上运行正常。代码如下: