【发布时间】:2019-03-31 15:41:52
【问题描述】:
我正在使用角度为 7 的 ng2 图表。我有一个饼图
如何增加图例和图表之间的间距?
我正在尝试这样做,但它不起作用。
public pieChartOptions: ChartOptions = {
responsive: true,
rotation: 0,
plugins: {
afterFit: function(chart, options) {
chart.plugins.register({
afterFit: function() {
this.height = this.height + 150;
},
})
},
datalabels: {
align: 'end',
anchor: 'end',
formatter: (value, ctx) => {
const label = ctx.chart.data.labels[ctx.dataIndex];
return value + '% ';
},
font: {
weight: 'bold',
size: 16,
}
}
}
};
【问题讨论】:
-
感谢您的回复。我试过了。但是不行
-
检查你使用的chart.js版本并尝试了Like tat页面?
-
我把这条线放在哪里 Chart.Legend.prototype.afterFit = function() { this.height = this.height + 50; };
-
@gowthamrajan 我试过这个插件:{ afterFit: function(chart, options) { chart.Legend.prototype.afterFit = function() { this.height = this.height + 50; }; },但不工作:(
标签: angular chart.js ng2-charts