2
如何在具有雙x軸的谷歌條形圖上設置數字值的格式? 帶標籤支持的頂部軸應至少有四位小數位,如工具提示中顯示的值。帶雙x軸(十進制)的谷歌條形圖格式號碼
我試過的是this的方法,但它似乎沒有工作。
我的代碼:
data.addColumn('string', 'RuleName');
data.addColumn('number', 'Lift');
data.addColumn('number', 'Support');
for (var i = 0; i < chartsdata.length; i++) {
data.addRow([rule, Lift,Support)]);
}
// format numbers in second column to 5 decimals
var formatter = new google.visualization.NumberFormat({
pattern: '#,##0.00000'
}); // This does work, but only for the value in the tooltip.
formatter.format(data, 2);
// Passing in some options
var chart = new google.charts.Bar(document.getElementById('barChart'));
var options = {
title: "Association Rules by lift and support",
bars: 'horizontal',
series: {
0: { axis: 'Lift', targetAxisIndex: 0, },
1: { axis: 'Support', targetAxisIndex: 1}
},
axes: {
x: {
Lift: { label: 'Lift', format: '0,000' //Doesn't work, }, // Bottom x-axis.
Support: { side: 'top', label: 'Support' } // Top x-axis.
}
}, ..........
我也試圖從谷歌文檔這種方法:
series:{hAxes:{1:{title:'abc', format: '0,0000'}}
任何幫助將不勝感激!
希望這有助於與_Material_,請務必在繪製前使用'convertOptions' ... – WhiteHat
這絕對有幫助!我確實嘗試過'hAxis:'格式:'#,## 0.00000' }'選項,但不知道'convertOptions'。這解決了我的問題,通過格式化這兩個軸。 – Chris