Iam using Chart.js and have a simple question.
Is it possible to assign a attribute like margin onto the legend property of the chart.js options?
This is my chart.js optionsObject:
optionsObject = {
legend: {
margin: {
bottom: 40,
// top: 40
},
display: true,
position: 'top',
align: 'center',
padding: 40,
labels: {
padding: 30,
boxWidth: 30,
fontSize: 15,
}
},
plugins: {
datalabels: false,
datasource: {
url: 'sample-dataset.csv'
}
},
responsive: true,
// without maintainAspectRatio all Charts crash height!!!!!!!
maintainAspectRatio: false,
scales: {
xAxes: [{
id: 'X',
scaleLabel: {
display: true,
labelString: 'Date'
},
}],
yAxes: [{
id: 'Y',
scaleLabel: {
display: true,
labelString: '# Bravos'
},
ticks: {
beginAtZero: true,
callback: function (value) {
if (Number.isInteger(value)) {
return value;
}
},
stepSize: 1
}
}],
}
}
This is my actual output of the chart: Chart
My goal is to move up the legend section so the chart have more space between legend and chart data. I am pretty new to Chart.js and hope u can help me.
Thanks in advance.