2017-02-13 89 views
0

我與谷歌的柱形圖在這裏工作,我無法弄清楚如何在我的圖表顯示小數我的價值觀,我可以證明我的價值的唯一途徑是包括.ToString(".")這將刪除所有小數,並只顯示一個整數。顯示在谷歌圖表API小數

有沒有辦法解決這個問題的方式,我想顯示一個小數有。例如(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

爲什麼在標籤C#? –

+0

我用剃刀 –

+0

[谷歌維基數字格式(https://developers.google.com/chart/interactive/docs/customizing_axes#number-formats)也許這將幫助 –

回答

1

谷歌圖表期待.代替, 使用@average.replace(",",".")