1

我正在尝试实现这样的目标,但底部有图例。当我尝试添加它时,我最多可以得到这样的东西: 在此处输入图像描述

我正在考虑将图例分离到另一个 div,例如

<div id="js-legend" class="chart-legend"></div>

但是用以前的解决方案来实现它会很好。

在此先感谢您的帮助

4

2 回答 2

3

我认为这样的事情应该有效。

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;
              }
            };
          }
        }]
于 2019-01-13T19:03:06.170 回答
-4

您可以将margin-top 用于#js-legend。

于 2018-09-06T09:56:18.733 回答