Merge pull request #1779 from olyckne/adds_min_and_max_to_y_axes

Adds min and max setting to axes
This commit is contained in:
Evert Timberg
2015-12-14 21:55:17 -05:00
5 changed files with 113 additions and 0 deletions

View File

@@ -181,6 +181,14 @@
this.ticks.push(niceMin + (j * spacing));
}
if (this.options.ticks.min !== undefined) {
this.ticks[0] = this.options.ticks.min;
}
if (this.options.ticks.max !== undefined) {
this.ticks[this.ticks.length - 1] = this.options.ticks.max;
}
if (this.options.position == "left" || this.options.position == "right") {
// We are in a vertical orientation. The top value is the highest. So reverse the array
this.ticks.reverse();
@@ -191,6 +199,15 @@
this.max = helpers.max(this.ticks);
this.min = helpers.min(this.ticks);
if (this.options.ticks.min !== undefined) {
this.min = this.options.ticks.min;
}
if (this.options.ticks.max !== undefined) {
this.max = this.options.ticks.max;
}
if (this.options.ticks.reverse) {
this.ticks.reverse();

View File

@@ -90,6 +90,14 @@
}, this);
}
if (this.options.ticks.max) {
this.max = this.options.ticks.max;
}
if (this.options.ticks.min) {
this.min = this.options.ticks.min;
}
if (this.min === this.max) {
if (this.min !== 0 && this.min !== null) {
this.min = Math.pow(10, Math.floor(helpers.log10(this.min)) - 1);
@@ -121,6 +129,14 @@
this.tickValues.push(1.0 * Math.pow(10, maxExponent));
if (this.options.ticks.min) {
this.tickValues[0] = this.min;
}
if (this.options.ticks.max) {
this.tickValues[this.tickValues.length - 1] = this.max;
}
if (this.options.position == "left" || this.options.position == "right") {
// We are in a vertical orientation. The top value is the highest. So reverse the array
this.tickValues.reverse();
@@ -131,6 +147,14 @@
this.max = helpers.max(this.tickValues);
this.min = helpers.min(this.tickValues);
if (this.options.ticks.min) {
this.min = this.options.ticks.min;
}
if (this.options.ticks.max) {
this.max = this.options.ticks.max;
}
if (this.options.ticks.reverse) {
this.tickValues.reverse();