Patrick Finnigan
Patrick Finnigan

Reputation: 1947

Google Analytics DataChart - how to display month index as month name?

I have a an analytics DataChart which displays monthly traffic. The problem is, the x-axis is showing month indices and I want it to show month name labels (e.g. January, February, March, etc.). Is there a way I can format the month axis as the month name?

  var pastYearChart = new gapi.analytics.googleCharts.DataChart({
    query: {
      'ids': my_ID,
      'start-date': '365daysAgo',
      'end-date': 'today',
      'metrics': 'ga:sessions,ga:users',
      'dimensions': 'ga:month'
    },
    chart: {
      'container': 'traffic-past-year-container',
      'type': 'COLUMN',
      'options': {
        'width': '100%'
      }
    }
  });

data chart

Upvotes: 0

Views: 1190

Answers (1)

user6599592
user6599592

Reputation:

var month = [
    "January",
    "February",
    "etc"
];

for(var i = 0, len = month.length; i < len; i++) {
    // month[i] contains your month based on your index
}

Upvotes: 1

Related Questions