[Chartjs]-Chart.js โ€“ Increase spacing between bottom legend and chart

5๐Ÿ‘

โœ…

I think something like this should work.

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

-4๐Ÿ‘

you can use margin-top for #js-legend.

Leave a comment