Skip to content

Instantly share code, notes, and snippets.

@bettysteger
Created June 27, 2014 07:35
Show Gist options
  • Save bettysteger/65c63923f4ead9e53f06 to your computer and use it in GitHub Desktop.
Save bettysteger/65c63923f4ead9e53f06 to your computer and use it in GitHub Desktop.
How-to create a simple pie chart with angularjs-nvd3-directives
<nvd3-pie-chart id="{{id}}"
data="pieData"
width="80"
height="80"
x="xFunction()"
y="yFunction()">
</nvd3-pie-chart>
// If there is more than one chart on a page, every chart should have a unique id.
$scope.id = "nvd3-pie-chart-"+uuid;
$scope.pieData = [
{ key: 'Apple', y: 75 },
{ key: 'Oranges', y: 25 }
];
$scope.xFunction = function() {
return function(d) {
return d.key;
};
};
$scope.yFunction = function() {
return function(d){
return d.y;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment