gpt4 book ai didi

angular - 如何设置圆环图的边框宽度

转载 作者:行者123 更新时间:2023-12-05 06:23:46 25 4
gpt4 key购买 nike

我正在制作一个组件来使用 ng2-charts 显示圆环图。

组件属性

@Input() data: MultiDataSet;
@Input() labels: Label[];
@Input() colors: Color[];
@Input() legend: boolean;

datasets: ChartDataSets = {
borderWidth: 2
};
options: ChartOptions = {
responsive: true
};

模板

<canvas
baseChart
[data]="data"
[labels]="labels"
[colors]="colors"
[legend]="legend"
[datasets]="datasets"
[options]="options"
chartType="doughnut"
*ngIf="data?.length"
>
</canvas>

图表按预期显示,但边框宽度太大。 Chart 不会对数据集值使用react。如何设置 donut 的宽度?

最佳答案

import { ChartType } from 'chart.js';
import { MultiDataSet, Label, Color } from 'ng2-charts';

public doughnutChartLabels: Label[] = [];
public doughnutChartColors: Color[] = [
{
backgroundColor:["#fff","ff0000","#fff","ff0000", "#fff","ff0000"],
borderColor: ["#FF0000", "#FF0000","#FF0000", "#FF0000","#FF0000", "#FF0000"],
borderWidth: 2
}
];
public doughnutChartData: MultiDataSet = [
[20, 100, 0, 120, 0, 120],
];
public chartOptions = {
cutoutPercentage: 80,
tooltips: {
enabled: false
}
};
public doughnutChartType: ChartType = 'doughnut';

发件人:https://www.chartjs.org/docs/latest/

关于angular - 如何设置圆环图的边框宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58117454/

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