如何自定义Google Chart日历?

时间:2016-04-25 13:37:28

标签: javascript php charts calendar

我想在Google图表中添加评论(日历图表)。

但是,我不了解Google图表的选项以及如何使用。

当我添加addcolumn时,这项工作不能。

请给我一些帮助..

enter image description here

<<<source code>>>>
<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load("current", {packages:["calendar"]});
      google.charts.setOnLoadCallback(drawChart);

   function drawChart() {
       var dataTable = new google.visualization.DataTable();

       dataTable.addColumn({ type: 'date', id: 'Date' });
       dataTable.addColumn({ type: 'number', id: 'Won/Loss' });
      // dataTable.addColumn({ type: 'string', id:'comment'});  // Error 
       dataTable.addRows([

          [ new Date(2015, 3, 11), 4],  // I want to add comment
          [ new Date(2015, 3, 12), 3],
          [ new Date(2015, 3, 10), 8],
          [ new Date(2015, 1, 13), 5],
          [ new Date(2015, 3, 14), 7]

          ]);

       var chart = new google.visualization.Calendar(document.getElementById('calendar_basic'));

       var options = {
         title: "Red Sox Attendance",
         height: 1050,
       };

       chart.draw(dataTable, options);
   }
    </script>
  </head>
  <body>
    <div id="calendar_basic" style="width: 1000px; height: 350px;"></div>
  </body>
</html>

    enter code here

1 个答案:

答案 0 :(得分:0)

您是否尝试将评论显示在工具提示中?您希望如何呈现评论信息?