0
votes

I want to compare the data for the same dates but different years.

For example, for the date January 1, I want to display the data for 2016 and 2015 on the same chart, same position on the x-axis but on different line series.

Is this possible?

1
sounds possible, but not sure i follow exactly. can you clarify or provide example image?WhiteHat
Basically, I'm comparing data from the same month and day but different years, and plotting them in the same graph. For example, let's say the data is about sales for the whole month of January. In the x-axis are the days of January, and the y-axis is the sales. I want to plot two line series functions, one that plots for the year 2015, and for the year 2016. If I'm not clear enough, I could try to provide a sample image.something-not-here

1 Answers

0
votes

here is an example of the chart, I think you are describing...

google.charts.load('current', {
  callback: function () {
    var data = new google.visualization.DataTable();
    data.addColumn('date', 'Date');
    data.addColumn('number', '2005');
    data.addColumn('number', '2006');
    data.addRows([
       [new Date('01/01/2016'), 200, 210],
       [new Date('01/02/2016'), 190, 220],
       [new Date('01/03/2016'), 205, 200],
       [new Date('01/04/2016'), 220, 230],
       [new Date('01/05/2016'), 212, 210],
       [new Date('01/06/2016'), 185, 193],
       [new Date('01/07/2016'), 196, 207]
    ]);
    var options = {
      height: 400
    };

    var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
    chart.draw(data, options);
  },
  packages: ['corechart']
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>