我正在做一个角度图表,它有三个值和显示标签,当我点击图表时它必须显示我点击的标签。我试图从积分中获取价值。
$scope.data = ["prospective","CallBacks","Closed"];
$scope.labels = ["4","2","3"];
$scope.onClick = function (points,evt) {
console.log("Points: "+JSON.stringify(points));
$scope.struct=JSON.stringify(points);
$scope.value=$scope.struct.label;
}
<canvas id="pieChart" class="chart chart-pie"
chart-data="data" chart-labels="labels" chart-legend="true" chart-click="onClick">
</canvas>
<span>{{value}}</span>
以下日志显示点数:
[{"value":4,"outerRadius":95.5,"innerRadius":0,"fillColor":"rgba(151,187,205,0.8)","highlightColor":"rgba(151,187,205,0.8)","showStroke":true,"strokeWidth":2,"strokeColor":"#fff","startAngle":4.71238898038469,"circumference":1.9332877868244882,"label":"Prospective","_saved":{"value":4,"outerRadius":95.5,"innerRadius":0,"fillColor":"rgba(151,187,205,1)","highlightColor":"rgba(151,187,205,0.8)","showStroke":true,"strokeWidth":2,"strokeColor":"#fff","startAngle":4.71238898038469,"circumference":0,"label":"Prospective"},"endAngle":6.645676767209178}]
我可以从log获取值,但在$ scope.value中使用相同的值,标签显示为undefined。
答案 0 :(得分:0)
感谢支持人员,当我给$ scope.value = $ scope.struct [0]时,有一些json似乎是这样。.label工作正常..