简体   繁体   中英

Google Charts API custom month names

I need to set custom month names in Charts.

How set custom month names in Google Charts API?

You can specify custom ticks on the hAxis ...

  google.load('visualization', '1', {packages: ['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('date', 'Time of Day'); data.addColumn('number', 'Rating'); data.addColumn({type: 'string', role: 'tooltip'}); data.addRows([ [new Date(2015, 1, 1), 5, 'January'], [new Date(2015, 2, 1), 7, 'February'], [new Date(2015, 3, 1), 3, 'March'], [new Date(2015, 4, 1), 2, 'April'], [new Date(2015, 5, 1), 2, 'May'] ]); var options = { width: 900, height: 500, hAxis: { format: 'MMM', gridlines: {count: 5}, ticks: [ {v: new Date(2015, 1, 1), f:'custom 1'}, {v: new Date(2015, 2, 1), f:'custom 2'}, {v: new Date(2015, 3, 1), f:'custom 3'}, {v: new Date(2015, 4, 1), f:'custom 4'}, {v: new Date(2015, 5, 1), f:'custom 5'} ] }, vAxis: { gridlines: {color: 'none'}, minValue: 0 } }; var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data, options); } 
 <script src="https://www.google.com/jsapi"></script> <div id="chart_div"></div> 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM