`baseline` option for date values does not work in Google Visualization

匿名 (未验证) 提交于 2019-12-03 09:05:37

问题:

I am trying to draw a baseline on a chart that uses date values to chart. Here is the code, and here is what the chart looks like:

function drawVisualization() {   // Create and populate the data table.   var data = new google.visualization.DataTable();   data.addColumn('string', 'Assignment');   data.addColumn('date', 'Dummy');   data.addRows([     ['A', new Date(2011,1,1)],     ['B', new Date(2012,1,1)],      ['C', new Date(2013,1,1)],   ]);    // Create and draw the visualization.   new google.visualization.BarChart(document.getElementById('visualization')).       draw(data,            {              width:600, height:400,              hAxis: {baseline: new Date(2012,6,1), baselineColor: 'red'}            }       ); } 

This is not the expected behavior -- the baseline is set to be on July 1st, 2012, yet it is appearing all the way to the left (January 1st, 2011).

If you do this with a non-date Axis chart, the behavior is different:

function drawVisualization() {   // Create and populate the data table.   var data = new google.visualization.DataTable();   data.addColumn('string', 'Assignment');   data.addColumn('number', 'Dummy');   data.addRows([     ['A', 1],     ['B', 2],      ['C', 3],   ]);    // Create and draw the visualization.   new google.visualization.BarChart(document.getElementById('visualization')).       draw(data,            {              width:600, height:400,              hAxis: {baseline: 1.5, baselineColor: 'red'}            }       ); } 

What the heck is going on here? Is it impossible to set the baseline of a date-axis chart?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!