suggestedMin and suggestedMax options for scales

This commit is contained in:
etimberg 2015-10-31 11:01:40 -04:00
parent 988034cef6
commit 3aaa3e27f3
2 changed files with 15 additions and 2 deletions

View File

@ -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,
}
}]
}

View File

@ -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--;