How to change the format type of the label in Google Chart with Javascript as my image below:Here is my data (in US Dollars): ['2004', 340456060], ['2005', 581766089], ['2006', 666099879], ['2007', 1980361212],1. When the chart runs, I would like to modify these figures with ,. Hence, whenever the mouseover, it must be like that:2007 with Sales: 1,980,361,2122006 with Sales: 666,099,8792005 with Sales: 581,766,0892004 with Sales: 340,456,0602. How to add $ as the last character?2007 with Sales: 1,980,361,212$2006 with Sales: 666,099,879$2005 with Sales: 581,766,089$2004 with Sales: 340,456,060$3. Besides that, how to change the label to %?2007 with Sales: 55.6%2006 with Sales: 18.6%2005 with Sales: 16.3%2004 with Sales: 9.5%DemoHTML:<div id="chart_div" style="width: 500px; height: 400px;"></div>Javascript:google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Year', 'Sales'], ['2004', 340456060], ['2005', 581766089], ['2006', 666099879], ['2007', 1980361212] ]); var options = { title: 'Company Performance', vAxis: {title: 'Dollars'}, hAxis: {title: 'Year'} }; var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); chart.draw(data, options); } 解决方案 Here is my answer. I just add the highlight code. Please let me know if something goes wrong.var formatter = new google.visualization.NumberFormat({ pattern: '#,###$'});formatter.format(data, 1); 这篇关于如何使用Javascript更改Google图表中标签的格式类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-12 05:32