Chart.js - 样式图例:较小的圆圈

Chart.js - style legend: smaller circles

我用 chart.js 创建了折线图。我使用以下方法将图例符号形式从矩形更改为圆形:

legend: {
  display: true,
  labels: {
    usePointStyle: true,
  },
}

我想改变圆圈的大小。但根据文档,这只有在我还更改字体大小时才有可能:

Label style will match corresponding point style (size is based on fontSize, boxWidth is not used in this case). - https://www.chartjs.org/docs/latest/configuration/legend.html#legend-label-configuration

有谁知道是否还有其他更改大小的选项?或者我必须使用 generateLabels().

这里有一个 codePen 可以看一下。

您可以使用 boxWidth 选项来影响图例中点的大小:

options: {
  legend: {
    labels: {
      usePointStyle: true,
      boxWidth: 6
    }
  }
}

阅读 documentation of chartjs about legend