angular
.module('meuApp', ['nvd3'])
.controller('MeuController', MeuController);
MeuController.$inject = [];
function MeuController() {
var vm = this;
vm.opcoes = {
chart: {
type: 'pieChart',
pie: {
dispatch: {
elementClick: function(evento){ console.log(evento) }
}
},
height: 500,
x: function(d) {
return d.key;
},
y: function(d) {
return d.y;
},
showLabels: true,
duration: 500,
labelThreshold: 0.01,
labelSunbeamLayout: true,
legend: {
margin: {
top: 5,
right: 35,
bottom: 5,
left: 0
}
}
}
};
vm.dados = [
{key: "One", y: 5},
{key: "Two", y: 2},
{key: "Three", y: 9},
{key: "Four", y: 7},
{key: "Five", y: 4},
{key: "Six", y: 3},
{key: "Seven", y: .5}
];
};
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.1/nv.d3.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.1/nv.d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-nvd3/1.0.5/angular-nvd3.min.js"></script>
<div ng-app="meuApp">
<div ng-controller="MeuController as vm">
<nvd3 options="vm.opcoes" data="vm.dados"></nvd3>
</div>
</div>
Really show! + 1.
– Guilherme Nascimento
@Guilhermenascimento worse than the documentation is half obscure
– Sorack
I don’t think so much http://krispo.github.io/angular-nvd3/#/Quickstart, I found it easy for those who don’t read the most complete Ocs, such as javadoc and phpdoc. I thought it well :)
– Guilherme Nascimento
@Sorack, thanks again, brother. Hug.
– Antonio Braz Finizola
@Sorack, back to the questions. How do I put a clickable part in the middle of the piechart donut? In my chart, there is a piece "all", which returns all the data. Only I didn’t want to put one more piece in the chart, but in the middle of it. How do I?
– Antonio Braz Finizola