Created
June 27, 2014 07:35
-
-
Save bettysteger/65c63923f4ead9e53f06 to your computer and use it in GitHub Desktop.
How-to create a simple pie chart with angularjs-nvd3-directives
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<nvd3-pie-chart id="{{id}}" | |
data="pieData" | |
width="80" | |
height="80" | |
x="xFunction()" | |
y="yFunction()"> | |
</nvd3-pie-chart> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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