gpt4 book ai didi

angularjs - 在 angular-chart.js 圆环图上渲染图例

转载 作者:行者123 更新时间:2023-12-03 21:02:26 27 4
gpt4 key购买 nike

我遵循了 angular-chart.js 文档,并创建了一个图表,但我无法用它来渲染图例。我不明白为什么它不起作用。

文档:http://jtblin.github.io/angular-chart.js/
类似的问题:How to color legend in angular-chart.js

<div class="panel-body" ng-controller="CircleCtrl" style="display: block;">
<div class="chart-container" style="width:400px; height:200px;">
<canvas id="doughnut"
class="chart chart-doughnut"
chart-data="data"
chart-labels="labels"
chart-colours="colours"
chart-legend="true">
</canvas>
</div>
</div>

enter image description here

我还尝试在 Controller 中为图例定义一个数组,
$scope.legend = ["complete", "incomplete"]

根据另一个 SO 问题中接受的答案, chart-legend="true"应该足以让它工作。

有没有人有使用这个库的经验并且知道如何解决这个问题?

最佳答案

如果您使用的是基于 chart.js 2 的 1.0.0-alpha 分支,则正确的语法是:

$scope.options = {legend: {display: true}};

并在您的 html 中
<canvas id="pie"
class="chart chart-pie"
chart-data="data"
chart-labels="labels"
chart-options="options">
</canvas>

关于angularjs - 在 angular-chart.js 圆环图上渲染图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37107708/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com