Google 可视化图表时间轴 - 工具提示日期格式不起作用

时间:2021-07-15 09:04:46

标签: charts google-visualization tooltip timeline dateformatter

我正在尝试更改 Google 图表时间轴中的日期格式工具提示。由于某种原因,它根本不起作用。我已经尝试过这种模式 'dd.MM, yyyy' 通过工作得很好的选项来更改 hAxis,但工具提示没有改变。

google.charts.load('current', {'packages':['timeline']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
  var dataTable = new google.visualization.DataTable();

  dataTable.addColumn({ type: 'string', id: 'Name' });
  dataTable.addColumn({ type: 'string', id: 'City' });
  dataTable.addColumn({ type: 'date', id: 'Start' });
  dataTable.addColumn({ type: 'date', id: 'End' });
  dataTable.addRows([
     // some php code to echo Rows that look like this
     ['Mike', 'London', new Date(2021,4,25), new Date(2021,5,18)],
     ['Peter', 'Berlin', new Date(2021,3,10), new Date(2021,6,20)]
  ]);

var formatter = new google.visualization.DateFormat({ pattern: 'dd.MM, yyyy' });
formatter.format(dataTable, 2);
formatter.format(dataTable, 3);

var chart = new google.visualization.Timeline(document.getElementById('timeline'));
chart.draw(dataTable);
}

Timeline still shows this

0 个答案:

没有答案
相关问题