<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js">
var arrayMaterias =<?php echo json_encode($arrayMaterias); ?>
alert(arrayMaterias.toString());
google.charts.load('current', {'packages': ['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Materias', 'Programacion I', 'Fisica', 'Mate', 'Proyectos'],
['Grado I', 100, 60, 60, 60]
]);
// var data = google.visualization.arrayToDataTable([
// ['materia',arrayMaterias[0],arrayMaterias[1]],
// ['Grado',100,50]
// ]);
var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017'
}
};
var chart = new google.charts.Bar(document.getElementById('columnchart_material'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
</script>
</head>
<body>
<div id="columnchart_material" style="width: 800px; height: 500px;"></div>
</body>
</html>
答案 0 :(得分:1)
关闭导入库的第一个脚本标记:
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js" ></script>
并准备好你的脚本 - 它将运行!