3๐
โ
You can use the scriptable options for this:
var options = {
type: 'line',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderWidth: 1
},
{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7],
borderWidth: 1
}
]
},
options: {
scales: {
y: {
grid: {
color: (ctx) => (ctx.index === 0 ? 'black' : 'rgba(0, 0, 0, 0.1)')
}
}
}
}
}
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.5.1/chart.js"></script>
</body>
1๐
I have finally found the answer! if it of use to anyone, then you need to add a scriptable component to grid:
grid: {
color: context => context.tick.value == 0 ? '#555555' : '#CCCCCC'
}
Source:stackexchange.com