0

nvd3-angular-directives pie chart is rounding of values when showing percentages. Is there a way to display the exact with decimal places? I have values 99.71% & 0.29% which are rounded to 100% and 0%.

...
<nvd3-pie-chart
        data="scenarioPie"
        id="scenarioPie"
        width="450"
        height="450"
        x="xFunction()"
        y="yFunction()"
        donut="true"
        tooltips="true"
        showLabels="true"
        donutLabelsOutside="true"
        labelType="percent"
        showLegend="true"
        donutRatio=".4">
<svg></svg>
...

I tried using a function as below to return a format but its not working

...
labelType="myFunction()"
...

$scope.myFunction=function() {
  return function(d){
    return d3.format(',.2%');
  }
}
Bala
  • 11,068
  • 19
  • 67
  • 120

1 Answers1

-1
$scope.xFunction = function(){ return function(d){ return d3.format('.02f')(d.x); }; };
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Aadesh
  • 1
  • Welcome to Stack Overflow, Aadesh, thank you for your answer, but please add some text to explain what exactly your code does. – Sainan Oct 20 '16 at 13:25
  • Welcome to Stack Overflow! Although this code may help to solve the problem, it doesn't explain _why_ and/or _how_ it answers the question. Providing this additional context would significantly improve its long-term educational value. Please [edit] your answer to add explanation, including what limitations and assumptions apply. – Toby Speight Oct 20 '16 at 16:30