我正在使用angular-chart.js图表饼 .
我需要像 horizontalAlign: "right", verticalAlign: "center"
那样对齐图例,但我不知道该怎么做 .
我的代码
HTML:
<canvas id="pie" class="chart chart-pie"
chart-data="data" chart-labels="labels" chart-options="options">
</canvas>
模块:
angular.module("app", ["chart.js"]).controller("PieCtrl", function ($scope) {
$scope.labels = ["Download Sales", "In-Store Sales", "Mail-Order Sales"];
$scope.data = [300, 500, 100];
$scope.options = {
legend : {
display : true,
position : "right"
}
};
});
1 回答
只需将此样式添加到您的CSS:
我编辑了我的代码 . 这将使您的图例水平向右对齐,在中间垂直对齐 .
Explanation:
该指令创建了这个html结构:
您可以将自己的样式添加到元素中 .
Edit 输入这样的html:
Edit 2.
上面的代码适用于旧版本 . 对于较新的版本,请打开Chart.js并添加此代码
以上
更确切地说,在6553线上 .