2

I'm trying to find out how to add border in chart area but it seems all I've been found is only applicable for datasets and the whole chart. Below code does not work.

Here is my code:

var myChart = new Chart(ctx, {
    type: 'bar',
    gridLines: {
        borderWidth: {
            top: 1,
            right: 0,
            bottom: 0,
            left: 1
        },
        borderColor: '#6B7280',
    },
}

(output wanted) add 5px green border around chart area except label enter image description here

2 Answers2

1

There is no default build in way to achieve this, if you want this you will have to write a custom plugin for it: https://www.chartjs.org/docs/latest/developers/plugins.html

LeeLenalee
  • 27,463
  • 6
  • 45
  • 69
0

you can wrap your canvas with a div tag and set border to it, if labels are out of it you can set padding-bottom & left to contains it