33👍
To fix min and max value for yAxes scale use the below code.
options:{
scales: {
yAxes : [{
ticks : {
max : 1,
min : -1
}
}]
}
}
suggestedMax will only works when incoming data is lower than suggestedMax value.
suggestedMin will works only when incoming data is greater than suggestedMin value.
- [Chartjs]-ChartJS: How to get labels, legend, title to show up?
- [Chartjs]-NG2-Charts Can't bind to 'datasets' since it isn't a known property of 'canvas'
14👍
For Chart.js version < 3.0:
From Sanjay Dutt‘s answer:
options:{
scales: {
yAxes : [{
ticks : {
max : 1,
min : -1
}
}]
}
}
For Chart.js version >= 3.0:
Due to breaking changes in version 3.X, the above mentioned answer doesn’t work anymore. Chart.js created a Migration Guide to solve the upcoming problems.
The minimum and maximum values can now be configured directly to the options.scales
:
options : {
scales : {
y : {
min: -1,
max: 1,
}
}
}
Source:stackexchange.com