title: NVD3.js - How to add bar text to each bar in a stacked graph?
body: <p>I have created a multi bar chart in NVD3/AngularJS.   I want to display text inside each rectangular bar along with its value as seen in the JSON below.</p>
  
  <p>How do I display text values to the graph within each bar?</p>
  
  <p><strong>NVD3 Chart Definition</strong></p>
  
  <pre><code>multiBarChart: {
          options: function(){
            return {
              chart: {
                type: 'multiBarChart',
                stacked: true,
                x: function(d){return d.x;},
                y: function(d){return d.y;},
                text: function(d){return d.x;},
                showLabels: true,
                showLegend: false,
                transitionDuration: 500,
                forceX: ["Team", "Meeting", "Phase", "Source"],
                xAxis: {
                  axisLabel: 'Category',
                  axisLabelDistance: -8
                },
                yAxis: {
                  axisLabel: 'Number Of Action Items',
                }
              }
            }
          },
          data: categoryChartData
        }
  </code></pre>
  
  <p><strong>JSON Data (categoryChartData)</strong></p>
  
  <pre><code>  [ 
                                  {"values" : [
                                      {
                                          "y" :10,
                                          "x" : "Team"
                                      }, {
                                          "y" : 0,
                                          "x" : "Meeting"
                                      },
                                      {
                                          "y" :0,
                                          "x" : "Phase"
                                      }, {
                                          "y" : 0,
                                          "x" : "Source"
                                      }
                                      ],
                                      "key" : "Team1"
                                  },
  
                                  {"values" : [
                                      {
                                          "y" :5,
                                          "x" : "Team"
                                      }, {
                                          "y" : 0,
                                          "x" : "Meeting"
                                      },
                                      {
                                          "y" :0,
                                          "x" : "Phase"
                                      }, {
                                          "y" : 0,
                                          "x" : "Source"
                                      }
                                      ],
                                      "key" : "Team2"
                                  },
                                      {"values" : [
                                      {
                                          "y" :0,
                                          "x" : "Team"
                                      }, {
                                          "y" : 7,
                                          "x" : "Meeting"
                                      },
                                      {
                                          "y" :0,
                                          "x" : "Phase"
                                      }, {
                                          "y" : 0,
                                          "x" : "Source"
                                      }
                                      ],
                                      "key" : "Meeting1"
                                  },
                                      {"values" : [
                                      {
                                          "y" :0,
                                          "x" : "Team"
                                      }, {
                                          "y" : 3,
                                          "x" : "Meeting"
                                      },
                                      {
                                          "y" :0,
                                          "x" : "Phase"
                                      }, {
                                          "y" : 0,
                                          "x" : "Source"
                                      }
                                      ],
                                      "key" : "Meeting2"
                                  },
                                  {"values" : [
                                      {
                                          "y" :0,
                                          "x" : "Team"
                                      }, {
                                          "y" : 0,
                                          "x" : "Meeting"
                                      },
                                      {
                                          "y" :9,
                                          "x" : "Phase"
                                      }, {
                                          "y" : 0,
                                          "x" : "Source"
                                      }
                                      ],
                                      "key" : "Phase1"
                                  },
                                  {"values" : [
                                      {
                                          "y" :0,
                                          "x" : "Team"
                                      }, {
                                          "y" : 0,
                                          "x" : "Meeting"
                                      },
                                      {
                                          "y" :5,
                                          "x" : "Phase"
                                      }, {
                                          "y" : 0,
                                          "x" : "Source"
                                      }
                                      ],
                                      "key" : "Phase1"
                                  },
                                  {"values" : [
                                      {
                                          "y" :0,
                                          "x" : "Team"
                                      }, {
                                          "y" : 0,
                                          "x" : "Meeting"
                                      },
                                      {
                                          "y" :0,
                                          "x" : "Phase"
                                      }, {
                                          "y" : 2,
                                          "x" : "Source"
                                      }
                                      ],
                                      "key" : "Internal"
                                  },
                                  {"values" : [
                                      {
                                          "y" :0,
                                          "x" : "Team"
                                      }, {
                                          "y" : 0,
                                          "x" : "Meeting"
                                      },
                                      {
                                          "y" :0,
                                          "x" : "Phase"
                                      }, {
                                          "y" : 1,
                                          "x" : "Source"
                                      }
                                      ],
                                      "key" : "Customer"
                                  }
  
  
                                  ];
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/3jJKp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3jJKp.png" alt="Category Stacked Chart"></a></p>