1

I'm having a hard time getting the title to display for a donut chart. Here is the plunkr I have: http://plnkr.co/edit/nJBpvU3YFAGaoc5BTXi7?p=preview. Here are the options I put:

$scope.options = {
        chart: {
            type: 'pieChart',
            height: 450,
            donut: true,
            x: function(d){return d.key;},
            y: function(d){return d.y;},
            showLabels: true,


            pie: {
                startAngle: function(d) { return d.startAngle/2 -Math.PI/2 },
                endAngle: function(d) { return d.endAngle/2 -Math.PI/2 }
            },
            transitionDuration: 500,
            legend: {
                margin: {
                    top: 5,
                    right: 70,
                    bottom: 5,
                    left: 0
                }
            },
            title: "Hello"
        },
        title: {
          text: "Hello"
        }
    };

I tried adding the title "Hello" in two separate places, but it's not showing up. Can anyone see what I'm doing wrong?

Jane
  • 81
  • 2
  • 9

1 Answers1

0

Turned out I needed to set the configuration to extended in order to set the title in the controller.

$scope.config = {
    extended: true
};

I also needed to set the config in the html:

<nvd3 options="options" data="data" config="config"></nvd3>

Then I was able to set the title to enabled and set the text of it. I was also able to put the title in the middle of the the donut chart by positioning it with the css.

title: {
    enable: true,
    text: "TEST",
    css: {
        position: 'relative',
        left: '0px',
        top: '200px'
    }
}

Here is the edited plunkr: http://plnkr.co/edit/td4AIZUQV9wrLEHp8zlo?p=preview

Jane
  • 81
  • 2
  • 9