Chr*_*ris 7 charts ng2-charts angular
我工作的饼图中NG2-图表。我正在尝试自定义图例的默认形状。我可以改变图例的位置,但可以改变形状吗?它有任何内置属性还是我们必须定制?
HTML
<div class="chart">
<canvas baseChart
[data]="pieChartData"
[labels]="pieChartLabels"
[chartType]="pieChartType"
[options]="pieChartOptions"
[plugins]="pieChartPlugins"
[colors]="pieChartColors"
[legend]="pieChartLegend">
</canvas>
</div>
Run Code Online (Sandbox Code Playgroud)
TS
public pieChartLabels: Label[] = [['Download', 'Sales'], ['In', 'Store', 'Sales'], 'Mail Sales'];
public pieChartData: number[] = [300, 500, 100];
public pieChartType: ChartType = 'pie';
public pieChartOption: any = {
legend: {
position: 'right',
labels: {
fontSize: 10
}
}
}
Run Code Online (Sandbox Code Playgroud)
我得到了什么
小智 10
ng2-charts使用chartjs,在chartjs 中有legend.labels.usePointStyle,你必须让它成为真的。
public pieChartLabels: Label[] = [['Download', 'Sales'], ['In', 'Store', 'Sales'],
'Mail Sales'];
public pieChartData: number[] = [300, 500, 100];
public pieChartType: ChartType = 'pie';
public pieChartOption: any = {
legend: {
position: 'right',
labels: {
fontSize: 10,
usePointStyle: true
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5357 次 |
| 最近记录: |