Chart.js-增加底部图例和图表之间的间距

Chart.js-增加底部图例和图表之间的间距,chart.js,chartjs-2.6.0,Chart.js,Chartjs 2.6.0,我正试图实现一些像但底部有传奇的东西。 当我尝试添加它时,最多可以得到如下结果: 我正在考虑把传奇分给另一个像这样的部门 <div id="js-legend" class="chart-legend"></div> 但用前一种解决方案实现这一点会很好 提前感谢您的帮助您可以使用margin top for js legend。我认为类似的功能应该可以使用 plugins: [{ beforeInit: (chart, options) =>

我正试图实现一些像但底部有传奇的东西。 当我尝试添加它时,最多可以得到如下结果:

我正在考虑把传奇分给另一个像这样的部门

<div id="js-legend" class="chart-legend"></div>
但用前一种解决方案实现这一点会很好


提前感谢您的帮助

您可以使用margin top for js legend。

我认为类似的功能应该可以使用

plugins: [{
          beforeInit: (chart, options) => {
            chart.legend.afterFit = () => {
              if (chart.legend.margins) {
                // Put some padding around the legend/labels
                chart.legend.options.labels.padding = 20;
                // Because you added 20px of padding around the whole legend,
                // you will need to increase the height of the chart to fit it
                chart.height += 40;
              }
            };
          }
        }]

在使用前一种解决方案时,不能真正做到这一点,因为它是在画布上绘制的……相关的——我可以说你是一个多么传奇的人@如果你有多行标签,这不是理想的解决方案。