Remove the Legend from nvd3 pie chart

3.1k views Asked by At

Im working on creating a pie chart using nvd3. I successfully got the pie chart but when the number of slices increase the legends tend to take up lot of space and the pie shrinks. I have decided to remove the legends completely.

i tried somthing like

d3.select(".nv-legendWrap")
  .remove(); 

This hides the legends from being visible but the space is still blank. i want the pie to resize and take up the entire space. How do i do this??

The pie chart looks like this https://i.stack.imgur.com/jkIsG.png

I want the legends specified in the red block to be removed and the pie re-sized to fill the space.

1

There are 1 answers

1
Chris Rosete On BEST ANSWER

what about hidden the legend by the moment of the creation of the chart:

    nv.addGraph(function() {
        var chart = nv.models.lineChart().margin({left: 100})
      .useInteractiveGuideline(true)
      .transitionDuration(350)
      .showLegend(false)    // <-----Show the legend
      .showYAxis(true)
      .showXAxis(true);