2014-11-05 32 views
2

当我在Calendar Chart包中使用Google Chart API时,它不会在11月或12月的日期绘制数据。Google Chart日历不会在十一月和十二月运行

我使用的是https://developers.google.com/chart/interactive/docs/gallery/calendar上的Google代码示例。

而且,即使使用谷歌示例,如果我将月份更改为11月或12月(索引10或11),则数据不会被绘制,但其他月份都可以。从谷歌

示例代码:

<html> 
    <head> 
    <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
    <script type="text/javascript"> 
     google.load("visualization", "1.1", {packages:["calendar"]}); 
     google.setOnLoadCallback(drawChart); 

    function drawChart() { 
     var dataTable = new google.visualization.DataTable(); 
     dataTable.addColumn({ type: 'date', id: 'Date' }); 
     dataTable.addColumn({ type: 'number', id: 'Won/Loss' }); 
     dataTable.addRows([ 
      [ new Date(2012, 3, 13), 37032 ], 
      [ new Date(2012, 3, 14), 38024 ], 
      [ new Date(2012, 3, 15), 38024 ], 
      [ new Date(2012, 3, 16), 38108 ], 
      [ new Date(2012, 3, 17), 38229 ], 
      // Many rows omitted for brevity. 
      [ new Date(2013, 9, 4), 38177 ], 
      [ new Date(2013, 9, 5), 38705 ], 
      [ new Date(2013, 9, 12), 38210 ], 
      [ new Date(2013, 9, 13), 38029 ], 
      [ new Date(2013, 9, 19), 38823 ], 
      [ new Date(2013, 9, 23), 38345 ], 
      [ new Date(2013, 9, 24), 38436 ], 
      [ new Date(2013, 9, 30), 38447 ] 
     ]); 

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

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

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

这仍然是一个错误在2015年 – Khrys 2015-12-07 14:22:41

回答

0

你肯定问题不是几个月没有由于尺寸显示? 以上面的示例代码并将月份更改为10(11月)和11(12月),它工作正常。

查看结果为jsfiddle。你可能会注意到你必须滚动才能看到最近几个月。我怀疑你对你的css有一些限制,这会限制以后的几个月。

代码中的jsfiddle:

<html> 
    <head> 
    <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
    <script type="text/javascript"> 
     google.load("visualization", "1.1", {packages:["calendar"]}); 
     google.setOnLoadCallback(drawChart); 

    function drawChart() { 
     var dataTable = new google.visualization.DataTable(); 
     dataTable.addColumn({ type: 'date', id: 'Date' }); 
     dataTable.addColumn({ type: 'number', id: 'Won/Loss' }); 
     dataTable.addRows([ 
      [ new Date(2012, 10, 13), 37032 ], 
      [ new Date(2012, 10, 14), 38024 ], 
      [ new Date(2012, 10, 15), 38024 ], 
      [ new Date(2012, 11, 16), 38108 ], 
      [ new Date(2012, 11, 17), 38229 ], 
      // Many rows omitted for brevity. 
      [ new Date(2013, 10, 4), 38177 ], 
      [ new Date(2013, 10, 5), 38705 ], 
      [ new Date(2013, 10, 12), 38210 ], 
      [ new Date(2013, 10, 13), 38029 ], 
      [ new Date(2013, 11, 19), 38823 ], 
      [ new Date(2013, 11, 23), 38345 ], 
      [ new Date(2013, 11, 24), 38436 ], 
      [ new Date(2013, 11, 30), 38447 ] 
     ]); 

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

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

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

的例子并不没有表现出来的工作。我同意那个。 11月和12月不适用于Google日历。 – Khrys 2015-12-07 14:22:26

+0

这是否意味着您在示例jsfiddle中看不到它们?请详细说明,我看到的日期标记为11月和12月。 – guival 2015-12-10 11:16:25

+1

是的。我从Google Vis与Daniel联系,他意识到这个问题。它与时区有关。我在GMT -3的巴西。他告诉我很快就会有解决办法。 – Khrys 2015-12-10 14:16:40

相关问题