我繪製如下圖代碼:如何更改Google圖表中顯示的號碼格式?
有沒有什麼辦法讓我可以在堆棧中的數字格式更改爲上百萬的那些貨幣。在繪製圖表時,軸已使用選項內的「format:short」標籤格式化爲數百萬。
我基本上有一個JavaScript函數返回具有使用我繪製圖表的值的JSON。 JavaScript函數給出如下:
<script>
google.load('visualization', '1', {packages: ['corechart', 'bar', 'table']});
google.setOnLoadCallback(loadcharts);
var dept= 'General Ward';
function drawBasic() {
var abc = $.ajax({url:'kpi23.php?dept='+dept,async:false,dataType:"json",}).responseText;
var data = new google.visualization.DataTable(abc);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1,
{ //calc: "stringify",
sourceColumn: 1,
type: "number",
role: "annotation" },2,
{ //calc: "stringify",
sourceColumn: 2,
type: "number",
role: "annotation" },3,
{ //calc: "stringify",
sourceColumn: 3,
type: "number",
role: "annotation" },4,
{// calc: "stringify",
sourceColumn: 4,
type: "number",
role: "annotation" },5,
{ //calc: "stringify",
sourceColumn: 5,
type: "number",
role: "annotation" },
{ //calc: "stringify",
sourceColumn: 6,
type: "number",
role: "annotation" }]);
var options = {
chart: {
title: 'Footfall by Day of Week'
},
annotations: {
textStyle: {
fontSize: 10,
//opacity: 0.8 // The transparency of the text.
}
},
//width: 1200,
height: 400,
//hAxis : {textStyle : {fontSize: 9}},
series: {
0:{color:'#083874'},
1:{color:'#94CAFC'},
2:{color:'#EBBA25'},
3:{color:'#F59E47'},
4:{color:'#9A9FA2'},
},
vAxis: {title: "Revenue",titleTextStyle: {italic: false},gridlines: { color: 'transparent'},viewWindowMode: "explicit", viewWindow:{ min: 0 }, format: 'short'},
hAxis: {title: "Month",titleTextStyle: {italic: false},gridlines: { color: 'transparent'} },
//chartArea: {left:90, width: 1000},
//chartArea: {'width': '90%', 'height': '80%'},
legend: { position: 'top', maxLines: 3 },
bar: { groupWidth: '70%' },
isStacked: true,
};
var chart = new google.visualization.ColumnChart(
document.getElementById('chart_div'));
chart.draw(view, options);
}
{ 「的cols」:[{ 「標籤」:「月」,「類型」:「字符串」},{「標籤」:「日託」,「類型」:「數字」},{「標籤」:「半私人」,「類型」 「數」},{ 「標籤」 :「通用病房」,「類型」:「號碼」},{「標籤」:「ICU」,「類型」:「號碼」},{「標籤」:「私人」,「類型」:「號碼」} ,{ 「標籤」: 「套件」, 「類型」: 「號碼」}], 「行」:[{ 「C」:[{ 「v」: 「FEB」},{ 「v」:29023.47},{ 「v」:541438.55},{「v」:442690.4},{「v」:394919.81},{「v」:497903.68},{「v」:198755.42}]}。 。像這樣的東西,不能複製完整的JSON,因爲它太長了! –