mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
suggestedMin and suggestedMax options for scales
This commit is contained in:
parent
988034cef6
commit
3aaa3e27f3
@ -30,7 +30,8 @@
|
||||
</div>
|
||||
<script>
|
||||
var randomScalingFactor = function() {
|
||||
return Math.round(Math.random() * 100 * (Math.random() > 0.5 ? -1 : 1));
|
||||
return Math.round(Math.random() * 100);
|
||||
//return 0;
|
||||
};
|
||||
var randomColorFactor = function() {
|
||||
return Math.round(Math.random() * 255);
|
||||
@ -101,6 +102,10 @@
|
||||
scaleLabel: {
|
||||
show: true,
|
||||
labelString: 'Value'
|
||||
},
|
||||
ticks: {
|
||||
suggestedMin: -10,
|
||||
suggestedMax: 250,
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
@ -138,7 +138,15 @@
|
||||
// move the botttom down to 0
|
||||
this.min = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.options.ticks.suggestedMin) {
|
||||
this.min = Math.min(this.min, this.options.ticks.suggestedMin);
|
||||
}
|
||||
|
||||
if (this.options.ticks.suggestedMax) {
|
||||
this.max = Math.max(this.max, this.options.ticks.suggestedMax);
|
||||
}
|
||||
|
||||
if (this.min === this.max) {
|
||||
this.min--;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user