If you want to indent under the legend for some diagrams only in your application:
ChartJS> = 2.1.0
Chart.plugins.register({ id: 'paddingBelowLegends', beforeInit: function(chart, options) { chart.legend.afterFit = function() { this.height = this.height + 50; }; } }); // ---------------------------------- // disable the plugin only for charts // where you DO NOT WANT the padding // ---------------------------------- // for raw ChartJS use: var chart = new Chart(ctx, { config: { plugins: { paddingBelowLegends: false } } }); // for angular-chartjs: $scope.myChart.options.plugins = { paddingBelowLegends: false } // then in template: // <canvas class="chart ..." chart-options="myChart.options" ... />
ChartJS> = 2.5.0
For each chart, certain plugins are supported, this should be possible to do:
var chart = new Chart(ctx, { plugins: [{ beforeInit: function(chart, options) { chart.legend.afterFit = function() { this.height = this.height + 50; }; } }] });
See ChartJS + documentation inspired by this other answer
source share