Google AnalyticsDataChart - 如何将月份索引显示为月份名称?

时间:2016-08-12 21:34:20

标签: google-analytics google-visualization

我有一个显示每月流量的分析DataChart。问题是,x轴显示月份指数,我希望它显示月份名称标签(例如1月,2月,3月等)。有没有办法将月轴格式化为月份名称?

  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

1 个答案:

答案 0 :(得分:1)

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

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