2π
β
It is not working because you never registered the plugin, if you do that it works fine:
const autocolors = window['chartjs-plugin-autocolors'];
Chart.register(autocolors);
var options = {
type: 'line',
data: {
labels: ["0", "1", "2", "3", "4", "5"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3]
},
{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7]
},
{
label: '# of People',
data: [3, 1, 15, 4, 9, 12]
}
]
},
options: {
plugins: {
autocolors: {
mode: 'dataset'
}
}
}
}
var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-autocolors"></script>
</body>
Source:stackexchange.com