为什么这张图表不能炒?

时间:2017-10-21 13:34:57

标签: javascript html charts

<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>

1 个答案:

答案 0 :(得分:1)

关闭导入库的第一个脚本标记:

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js" ></script>

并准备好你的脚本 - 它将运行!