[Chartjs]-Create space between legend and chart in charts.js

1๐Ÿ‘

โœ…

If I am not wrong, there isnt a configuration built by chart js to put padding between the labels and the chart,although, the padding to the labels are applied in wor format, this means that chart js applies padding between labels, on the other hand, you can apply padding between the title of the chart and the labels.

If you want padding between the tittle of the chart and the chart you can use the following code:

                 plugins: {
                    title: {
                        display: true,
                        text:'Historico Mensual',
                    },
                    legend: {
                        labels: {
                            padding: 100
                        }
                    }
                },

Another solution it could be to change the position of the labels to the bottom with the following code:

options: {
legend: {
  display: true,
  position: "bottom"
},

And adding a layput padding so the values dont get outside the canvas.

  options: {
     layout:{
        padding:20
     }
  },

Leave a comment