I'm useing gadash library and I can't figure out how to translate chart legend labels.
In this example demo I get "Visitors, Visits, Pageviews". I'd like those translated.
My code:
<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>
Is there any "locale" property I could add to the query?
The answer was custom onSuccess function:
'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();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.