我正在使用Google柱形图,我无法弄清楚如何在我的图表中显示带小数的值,唯一可以显示我的值的方法是包含.ToString(".")
,这会删除所有小数,只显示一个整数。
有没有办法解决这个问题,我想显示一个小数。例如(6,2)
<script>
google.charts.load('current', {
'packages': ['corechart']
});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['Lift', 'Total', 'Squat', 'Benchpress', 'Deadlift'],
['Lift', @average.ToString("."), @saverage.ToString("."), @baverage.ToString("."), @daverage.ToString(".")],
]);
var options = {
title: 'Average reps per set',
backgroundColor: { fill: 'transparent' },
explorer: { axis: 'horizontal' },
vAxes: {
0: { logScale: false, viewWindow: { min: 0 } },
1: { logScale: false, maxValue: 2 }
},
hAxis: { title: '' },
seriesType: 'bars',
curveType: 'function',
series: {
0: { targetAxisIndex: 0, color: '#20f400' },
}
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
答案 0 :(得分:1)
Google图表期待.
而不是,
使用@average.replace(",",".")