在 ng2-charts 中自定义图例形状

Customizing Legend Shape in ng2-charts

我正在研究 Pie Chart in ng2-charts。我正在尝试自定义图例的默认形状。我可以改变图例的位置但是可以改变形状吗?它有任何内置的 属性 还是我们必须自定义?

HTML

<div class="chart">
      <canvas baseChart
        [data]="pieChartData"
        [labels]="pieChartLabels"
        [chartType]="pieChartType"
        [options]="pieChartOptions"
        [plugins]="pieChartPlugins"
        [colors]="pieChartColors"
        [legend]="pieChartLegend">
      </canvas>
    </div>

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
          }
        }
      }

我想要的

我得到了什么

ng2-charts uses 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
      }
    }
  }