1👍
zeroLineWidth
apparently only works if the yAxis
starts at zero. This can be guaranteed by adding ticks.beginAtZero
to your yAxis
.
ticks: {
beginAtZero: true
}
new Chart(document.getElementById('myChart'), {
type: 'line',
data: {
labels: ['A', 'B', 'C', 'D'],
datasets: [{
label: 'OK',
data: [1, 2, 1, 2],
fill: false,
borderColor: 'blue'
}]
},
options: {
responsive: true,
legend: {
display: false
},
scales: {
xAxes: [{
gridLines: {
display: false
}
}],
yAxes: [{
gridLines: {
drawBorder: false,
drawTicks: false,
borderDash: [4, 4],
color: "#eee",
zeroLineWidth: 0
},
ticks: {
beginAtZero: true
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<canvas id="myChart" height="90"></canvas>
- Chartjs-Error trying to switch between different charts
- Chartjs-ChartJs functional component does not refresh even when forceUpdate
Source:stackexchange.com