Change Chart.js plugin
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
<canvas id="myChart" height="150"></canvas>
JavaScript
var chartColors = {
red: 'rgb(255, 99, 132)',
blue: 'rgb(54, 162, 235)'
};
var myChart = new Chart(document.getElementById("myChart"), {
type: 'pie',
responsive: true,
maintainAspectRatio: false,
data: {
labels: ["Label 1", "Label 2"],
datasets: [{
backgroundColor: [chartColors.red, chartColors.blue],
data: [4, 7],
hoverBorderWidth: 5,
borderColor: 'transparent',
}]
},
options: {
title: {
display: true,
text: 'Chart Title',
},
legend: {
display: true,
position: 'bottom',
fullWidth: false,
onClick: () => {},
labels: {
// generateLabels: (chart) => {
// return pieOptions.legendLeft(chart);
// }
}
},
rotation: 3.9,
},
plugins: [{
beforeInit: function(chart, options) {
console.log('yolo');
}
}]
});