Change my json variable to allow for all month intervals on line chart?

Okay so I am gathering data from a database and using it to create a google visualization line chart. The user can select year intervals and a month. I have a json variable that gathers the data in an array. For example, if the user selects 1990-1992 and January, the json array variable will look like this:

Then I import the json variable into my javascript:

<script type="text/javascript">

var inputData = [[1990,157894],[1991,173725],[1992,181227]] ;
var month = "January" ;

  google.load("visualization", "1", {packages:["corechart"]});
  function drawChart() {    
var data = new google.visualization.DataTable();
  data.addColumn('number', 'Year');
  data.addColumn('number', month);

    var formatter = new google.visualization.NumberFormat({groupingSymbol: ',', fractionDigits: '0'});
    formatter.format(data, 1);  

    var options = {
      title: 'Unemployed Statistics',
      hAxis: {title: 'Year', format: '####'},
   vAxis: {title: 'Number of Unemployed'},

    var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
    chart.draw(data, options);

And from there I am able to create my graph. The issue comes when a user selects all months instead of one month. Say a user selects 1990-1992 and all months. Then the array will look like this:

[[1990,157894],[1990,161642],[1990,155422],[1990,146588],[1990,139732],[1990,131337],[1990,129894],[1990,139529],[1990,126164],[1990,124355],[1990,141208],[1990,146554], [1990,141693],[1991,173725],[1991,189556],[1991,196588],[1991,157444],[1991,160583],[1991,160256],[1991,150932],[1991,144383],[1991,134035],[1991,136319],[1991,142753],[1991,152923],[1991,158291],[1992,181227],[1992,190536],[1992,183923],[1992,171126],[1992,180363],[1992,188129],[1992,180816],[1992,176638],[1992,165608],[1992,151023],[1992,158695],[1992,164348],[1992,174369]]

The first 1990 is January’s value, 2nd is February, … 13th is the annual average. See, there is no difference between each 1990 value. In reality though, January 1990 < February 1990 < December 1990. I don’t need the annual average values. I guess my question is how do I go about changing the year values instead of all being the same (1990 for all) to now having different values based on the month (January 1990 < February 1990 < December 1990)?

Sponsor our Newsletter | Privacy Policy | Terms of Service