mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Round log scale limits (#24151)
This commit is contained in:
parent
f3d55447ca
commit
b0b06a2787
@ -222,14 +222,14 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
minYAxis = ({ min }) => Math.min(min, this.minYAxis!);
|
minYAxis = ({ min }) => Math.min(min, this.minYAxis!);
|
||||||
}
|
}
|
||||||
} else if (this.logarithmicScale) {
|
} else if (this.logarithmicScale) {
|
||||||
minYAxis = ({ min }) => (min > 0 ? min * 0.95 : min * 1.05);
|
minYAxis = ({ min }) => Math.floor(min > 0 ? min * 0.95 : min * 1.05);
|
||||||
}
|
}
|
||||||
if (typeof maxYAxis === "number") {
|
if (typeof maxYAxis === "number") {
|
||||||
if (this.fitYData) {
|
if (this.fitYData) {
|
||||||
maxYAxis = ({ max }) => Math.max(max, this.maxYAxis!);
|
maxYAxis = ({ max }) => Math.max(max, this.maxYAxis!);
|
||||||
}
|
}
|
||||||
} else if (this.logarithmicScale) {
|
} else if (this.logarithmicScale) {
|
||||||
maxYAxis = ({ max }) => (max > 0 ? max * 1.05 : max * 0.95);
|
maxYAxis = ({ max }) => Math.ceil(max > 0 ? max * 1.05 : max * 0.95);
|
||||||
}
|
}
|
||||||
this._chartOptions = {
|
this._chartOptions = {
|
||||||
xAxis: {
|
xAxis: {
|
||||||
|
@ -237,14 +237,14 @@ export class StatisticsChart extends LitElement {
|
|||||||
minYAxis = ({ min }) => Math.min(min, this.minYAxis!);
|
minYAxis = ({ min }) => Math.min(min, this.minYAxis!);
|
||||||
}
|
}
|
||||||
} else if (this.logarithmicScale) {
|
} else if (this.logarithmicScale) {
|
||||||
minYAxis = ({ min }) => (min > 0 ? min * 0.95 : min * 1.05);
|
minYAxis = ({ min }) => Math.floor(min > 0 ? min * 0.95 : min * 1.05);
|
||||||
}
|
}
|
||||||
if (typeof maxYAxis === "number") {
|
if (typeof maxYAxis === "number") {
|
||||||
if (this.fitYData) {
|
if (this.fitYData) {
|
||||||
maxYAxis = ({ max }) => Math.max(max, this.maxYAxis!);
|
maxYAxis = ({ max }) => Math.max(max, this.maxYAxis!);
|
||||||
}
|
}
|
||||||
} else if (this.logarithmicScale) {
|
} else if (this.logarithmicScale) {
|
||||||
maxYAxis = ({ max }) => (max > 0 ? max * 1.05 : max * 0.95);
|
maxYAxis = ({ max }) => Math.ceil(max > 0 ? max * 1.05 : max * 0.95);
|
||||||
}
|
}
|
||||||
const endTime = this.endTime ?? new Date();
|
const endTime = this.endTime ?? new Date();
|
||||||
let startTime = this.startTime;
|
let startTime = this.startTime;
|
||||||
@ -290,7 +290,6 @@ export class StatisticsChart extends LitElement {
|
|||||||
align: "left",
|
align: "left",
|
||||||
},
|
},
|
||||||
position: computeRTL(this.hass) ? "right" : "left",
|
position: computeRTL(this.hass) ? "right" : "left",
|
||||||
// @ts-ignore
|
|
||||||
scale: true,
|
scale: true,
|
||||||
min: this._clampYAxis(minYAxis),
|
min: this._clampYAxis(minYAxis),
|
||||||
max: this._clampYAxis(maxYAxis),
|
max: this._clampYAxis(maxYAxis),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user