我使用angular-chart.js创建了一个饼图,它工作得很好 . 现在我需要在饼图的每个部分显示数据值,这不起作用 .
我尝试使用Chart.PieceLabel.js并在选项部分添加了以下代码 . 它没用 . 我不知道如何将它与angular-chart.js一起使用,因为它最初是为chart.js编写的
pieceLabel: {
render: 'label'
}
我使用了onAnimationComplete,但它似乎不起作用 . 我没有收到任何错误消息 . 这是我的代码 . 我哪里错了?感谢您的帮助! :)
html
<canvas id="pie" class="chart chart-pie"
chart-data="data" chart-labels="labels" chart-options="options" width="500" height="300" chart-colors="colors"></canvas>
JS code
$scope.options = {
legend: {
display: true,
position: "bottom"
},
tooltipEvents: [],
showTooltips: true,
tooltipCaretSize: 0,
onAnimationComplete: function () {
this.showTooltip(this.segments, true);
}
};
$scope.data = tempData;
$scope.labels = tempLabels;
Plunker link: https://embed.plnkr.co/zlBWzJ/
1 回答
在你的plunker中,我换了
同