Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Legend Padding

Open RobTables opened this issue 4 years ago • 6 comments

I have been having an issue with my chart legends when trying to add padding.

I am hoping for a feature that allows for more than just padding between the items in the legend. Something like:

  legend: {
    paddingLeft: 10, //suggested; also paddingRight, paddingTop, paddingBottom
    labels: {
      padding: 50 //current
    }
  },

At least in my case this would prevent having to create the legend as a separate object.

RobTables avatar Sep 30 '19 21:09 RobTables

it can set the padding for legend? i have try to set paddingTop,but it's not OK

jianjunhua avatar Apr 13 '21 05:04 jianjunhua

Really hoping for a simple way to set padding between whole legend itself and the chart somewhere in Chart.defaults.global.legend.

intoxopox avatar Jul 22 '21 16:07 intoxopox

This would be helpful for me as well.

satoshisound avatar Jul 22 '21 16:07 satoshisound

I would like to add some space between top-left aligned legend and chart. Is it possible?

monab avatar Sep 06 '21 12:09 monab

Implementing the above suggested enhancement as soon as possible would be beneficial to us as well. Currently, we cannot adjust the padding top, but we can adjust the padding bottom. chart.legend.fit = function () { ... this.height += chartDimension.legendHeight; };

fsdkarthik avatar Feb 14 '22 10:02 fsdkarthik

Another vote for this one.

The example @fsdkarthik gave works in some cases but it's very much a hack. Ideally we'd have the ability to set padding similar to how it works for the overall chart padding in layout:

https://www.chartjs.org/docs/latest/general/padding.html#top-left-bottom-right-object

methnen avatar Feb 15 '22 20:02 methnen

Please implement this: legend.padding.left legend.padding.top legend.padding.right legend.padding.bottom

RVXD avatar Nov 01 '22 09:11 RVXD

Hi guys. If you want to customize the legend visually, please use an HTML legend. Due to Chart.js using canvas, we can't implement every requested feature cause this will bloat the code.

dangreen avatar Nov 07 '22 20:11 dangreen