2

i'm trying to achieve something like this but with legend on bottom. When i try adding it at most i can get something like this: enter image description here

i'm considering separating legend to another div like

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

but it would be nice to achieve it with the former solution.

Thanks in advance for the help

TestzWCh
  • 153
  • 1
  • 3
  • 14
  • Related - [Increase spacing between legend and chart](https://stackoverflow.com/q/42585861/104380) – vsync Sep 22 '18 at 12:38

2 Answers2

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;
              }
            };
          }
        }]
grimmm
  • 346
  • 3
  • 5
-4

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

Vishnu Nair
  • 265
  • 1
  • 4
  • 13