javascript - How to display exact value using google.visualization.Table -
i'm having trouble displaying exact values using google.visualization.table
please see jsfiddle example.
it seems defaults 3 decimal places despite more exact values being provided. want show entire value (e.g. 0.000001).
below data used:
data.addrows([ ['mike', {v: 0.01}, true], ['jim', {v: 0.001}, false], ['alice', {v: 0.0001}, true], ['bob', {v: 0.00001}, true] ]);
the table display formatted value default
using object notation, can provide both value (v:
) , formatted value (f:
)
e.g. --> {v: 0.00001, f: '0.00001'}
see following working snippet...
google.charts.load('current', { callback: drawtable, packages:['table'] }); function drawtable() { var data = new google.visualization.datatable(); data.addcolumn('string', 'name'); data.addcolumn('number', 'salary'); data.addcolumn('boolean', 'full time employee'); data.addrows([ ['mike', {v: 0.01, f: '0.01'}, true], ['jim', {v: 0.001, f: '0.001'}, false], ['alice', {v: 0.0001, f: '0.0001'}, true], ['bob', {v: 0.00001, f: '0.00001'}, true] ]); var table = new google.visualization.table(document.getelementbyid('table_div')); table.draw(data, {showrownumber: true, width: '100%', height: '100%'}); }
<script src="https://www.gstatic.com/charts/loader.js"></script> <div id="table_div"></div>
wiki
Comments
Post a Comment