使用此示例plnkr ndv3 pie chart。它绘制了带有静态数据的图表,因为我硬编码但远程数据没有应用到图表,我可以在日志中看到它。这是配置
angular.module('codesApp.charts', ['nvd3'])
.controller('ChartCtrl', function ($scope, $http) {
$scope.options = {
chart: {
type: 'pieChart',
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
}
}
}
};
$scope.data = [
{
"key": "DIRTYPE",
"y": 15
},
{
"key": "PL_TYPE",
"y": 5
}
];
d3.json("./rest/codes/chartData", function (data1) {
$scope.data = data1;
console.log($scope.data);
});
});