Chart.js
Chart.js copied to clipboard
Legend Padding
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.
it can set the padding for legend? i have try to set paddingTop,but it's not OK
Really hoping for a simple way to set padding between whole legend itself and the chart somewhere in Chart.defaults.global.legend.
This would be helpful for me as well.
I would like to add some space between top-left aligned legend and chart. Is it possible?
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; };
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
Please implement this: legend.padding.left legend.padding.top legend.padding.right legend.padding.bottom
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.