Skip to content

Commit 20e2322

Browse files
committed
fix: handling extra space was “decaling” axis lines
1 parent c2b59f3 commit 20e2322

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/charting/components/YAxis.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,17 @@ export class YAxis extends AxisBase {
398398
// recalculate
399399
range = Math.abs(max - min);
400400

401-
// calc extra spacing
402-
this.mAxisMinimum = this.mCustomAxisMin ? this.mAxisMinimum : min - (range / 100) * this.getSpaceBottom();
403-
this.mAxisMaximum = this.mCustomAxisMax ? this.mAxisMaximum : max + (range / 100) * this.getSpaceTop();
404-
405-
this.mAxisRange = Math.abs(this.mAxisMinimum - this.mAxisMaximum);
401+
// calc extra spacing only for range.
402+
// using it for mAxisMinimum and mAxisMaximum would make the axis use decaled "values"
403+
let delta = 0;
404+
if (!this.mCustomAxisMin) {
405+
this.mAxisMinimum = min;
406+
delta += (range / 100) * this.getSpaceBottom();
407+
}
408+
if (!this.mCustomAxisMax) {
409+
this.mAxisMaximum = max;
410+
delta += (range / 100) * this.getSpaceTop();
411+
}
412+
this.mAxisRange = Math.abs(this.mAxisMinimum - this.mAxisMaximum) + delta;
406413
}
407414
}

0 commit comments

Comments
 (0)