如何翻译Google Analytics信息中心?

时间:2012-12-05 15:21:08

标签: javascript google-analytics google-analytics-api dashboard google-visualization

我正在使用gadash library,我无法弄清楚如何翻译图表图例标签。

this example demo我得到“访客,访问次数,浏览量”。我想要翻译的那些。

我的代码:

  <script>
    var dataOverTime = new gadash.Chart({
        'last-n-days': 30,
        'chartOptions': {
            width: 700
        },
        'divContainer': 'dataOverTimeConfig',
        'type': 'LineChart',
        'query': {
          'dimensions': 'ga:date',
          'sort': 'ga:date',
          'metrics': 'ga:visitors, ga:visits, ga:pageviews',
          'ids' : TABLE_ID    
        },
        'chartOptions': {
            height: 300,
            legend: {position: 'bottom'},
            hAxis: {title:'Data'},
            curveType: 'function'
        }
    }).render();
  </script>

我可以添加到查询中的“locale”属性吗?

1 个答案:

答案 0 :(得分:0)

答案是自定义onSuccess功能:

        'onSuccess': function(resp) {              
            var dataTable = gadash.util.getDataTable(resp);
            // customized part
            dataTable.z[1].label = "First custom label";
            dataTable.z[2].label = "Second custom label";
            dataTable.z[3].label = "Third custom label";
            // end of customized part
            var chart = gadash.util.getChart(this.config.divContainer, this.config.type);
            gadash.util.draw(chart, dataTable, this.config.chartOptions);
            gadash.onSuccess();
        }