mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Echarts: fix Y scaling (#23988)
* Echarts: fix scaling of Y axis * fix fit logic to only extend the limits * handle invalid min for log scale
This commit is contained in:
parent
0197e32783
commit
6e39242ca3
@ -187,6 +187,11 @@ export class StateHistoryChartLine extends LitElement {
|
||||
) {
|
||||
const dayDifference = differenceInDays(this.endTime, this.startTime);
|
||||
const rtl = computeRTL(this.hass);
|
||||
const minYAxis =
|
||||
// log(0) is -Infinity, so we need to set a minimum value
|
||||
this.logarithmicScale && typeof this.minYAxis === "number"
|
||||
? Math.max(this.minYAxis, 0.1)
|
||||
: this.minYAxis;
|
||||
this._chartOptions = {
|
||||
xAxis: {
|
||||
type: "time",
|
||||
@ -213,8 +218,14 @@ export class StateHistoryChartLine extends LitElement {
|
||||
yAxis: {
|
||||
type: this.logarithmicScale ? "log" : "value",
|
||||
name: this.unit,
|
||||
min: this.fitYData ? this.minYAxis : undefined,
|
||||
max: this.fitYData ? this.maxYAxis : undefined,
|
||||
min:
|
||||
this.fitYData && typeof minYAxis === "number"
|
||||
? ({ min }) => Math.min(min, minYAxis!)
|
||||
: minYAxis,
|
||||
max:
|
||||
this.fitYData && typeof this.maxYAxis === "number"
|
||||
? ({ max }) => Math.max(max, this.maxYAxis!)
|
||||
: this.maxYAxis,
|
||||
position: rtl ? "right" : "left",
|
||||
scale: true,
|
||||
nameGap: 2,
|
||||
|
@ -251,9 +251,15 @@ export class StatisticsChart extends LitElement {
|
||||
},
|
||||
position: computeRTL(this.hass) ? "right" : "left",
|
||||
// @ts-ignore
|
||||
scale: this.chartType !== "bar",
|
||||
min: this.fitYData ? undefined : this.minYAxis,
|
||||
max: this.fitYData ? undefined : this.maxYAxis,
|
||||
scale: true,
|
||||
min:
|
||||
this.fitYData && typeof this.minYAxis === "number"
|
||||
? ({ min }) => Math.min(min, this.minYAxis!)
|
||||
: this.minYAxis,
|
||||
max:
|
||||
this.fitYData && typeof this.maxYAxis === "number"
|
||||
? ({ max }) => Math.max(max, this.maxYAxis!)
|
||||
: this.maxYAxis,
|
||||
splitLine: {
|
||||
show: true,
|
||||
lineStyle: splitLineStyle,
|
||||
|
Loading…
x
Reference in New Issue
Block a user