javascript - How to show decimal numbers in d3 radialProgress? -
im using d3 component radialprogress.js
but not possible show decimal numbers, example:
1.37% shows 1%.
is there configuration can change it?
thanks.
[edit]
i found function:
function labeltween(a) { var = d3.interpolate(_currentvalue, a); _currentvalue = i(0); return function(t) { _currentvalue = i(t); this.textcontent = math.round(i(t)) + "%"; } } wich used by:
label.transition().duration(_duration) .tween("text",labeltween); the a parameter in labeltween function value on label text. value rounded when labeltween function called.
this not configurable, value rounded in code. need replace
.text(function (d) { return math.round((_value-_minvalue)/(_maxvalue-_minvalue)*100) + "%" }) with
.text(function (d) { return (_value-_minvalue)/(_maxvalue-_minvalue)*100 + "%" }) to disable rounding. there few other places needs happen well:
label.datum(math.round(ratio*100)); should be
label.datum(ratio*100); and
this.textcontent = math.round(i(t)) + "%"; should be
this.textcontent = i(t) + "%";
Comments
Post a Comment