How to show axis in days instead of date using Google timeline chart

Viewed 96

I have a google time line chart with number type date.

      google.load("visualization", "1", {packages:["timeline"]});
      google.setOnLoadCallback(drawChart);

      function drawChart() {
        let container = document.getElementById('timeline');
        let chart = new google.visualization.Timeline(container);
        let dataTable = new google.visualization.DataTable();

        const dayInMilSec = 24*60*60*1000;

        dataTable.addColumn({ type: 'string', id: 'Name' });
        dataTable.addColumn({ type: 'number', id: 'Start' });
        dataTable.addColumn({ type: 'number', id: 'End' });
        dataTable.addRows([
          [ 'Value1', 1 * dayInMilSec, 15 * dayInMilSec ],
          [ 'Value2', 8 * dayInMilSec, 70 * dayInMilSec ]
          ]);

        chart.draw(dataTable);
      }

The X axis shows Jan 4 Jan 11 .. Feb 8

How can setup the axis so it shows in day 1 .. day 70s instead of dates?

Code example

0 Answers
Related