Zeshan
Zeshan

Reputation: 2657

NVD3 piechart missing low percentage labels

I'm using NVD3 ver 3.1.7 for generating pieChart.

Everything works perfect except the chart labels. If the label value is of very low percentage, it does not appear. I want to make it visible irrespective of its value.

This is my code.

nv.addGraph(function() {
  var chart = nv.models.pieChart()
      .x(function(d) { return d.label })
      .y(function(d) { return d.value })
      .showLabels(true);

    d3.select("#chart svg")
        .datum(data)
      .transition().duration(1200)
        .call(chart);

  return chart;
});

Help would highly be appreciated.

Upvotes: 0

Views: 521

Answers (2)

Abhishek Kasera
Abhishek Kasera

Reputation: 240

You can use this option also.

.labelSunbeamLayout(true)

Upvotes: 0

Zeshan
Zeshan

Reputation: 2657

I just managed to resolve this issue.

In nvd3 pieChart, there is a parameter

.labelThreshold(.05)

which sets percentage for chart labels to display or hide. By default this is set to

.02 => 2%.

I increased it to

.05 => 5%

which solved my problem.

Upvotes: 3

Related Questions