2๐
โ
I solved this on a similar project using xAxe.ticks.min / max attributes.
In your case, something like this should do the trick:
if (elevation[0]){
var minX = elevation[0]['x'];
var maxX = elevation[elevation.length -1]['x'];
}
myLineChart = new Chart(ctx, {
type: 'scatter',
data: {
datasets: [{
label: "Elevation Profile",
data: elevation,
showLine: true
}]
},
options: {
...
scales: {
xAxes: [{
ticks:{
min: minX,
max: maxX,
}
}]
},
...
}
});
Source:stackexchange.com