mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 09:16:38 +00:00
Don't fix width of label when not virtualized (#12842)
Don't fix width of label when not virtualized
This commit is contained in:
parent
ced37aab4c
commit
ac08daa64e
@ -93,7 +93,7 @@ export class StateHistoryChartTimeline extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) public isSingleDevice = false;
|
||||
|
||||
@property({ type: Boolean }) public dataHasMultipleRows = false;
|
||||
@property({ type: Boolean }) public chunked = false;
|
||||
|
||||
@property({ attribute: false }) public startTime!: Date;
|
||||
|
||||
@ -117,7 +117,6 @@ export class StateHistoryChartTimeline extends LitElement {
|
||||
public willUpdate(changedProps: PropertyValues) {
|
||||
if (!this.hasUpdated) {
|
||||
const narrow = this.narrow;
|
||||
const multipleRows = this.data.length !== 1 || this.dataHasMultipleRows;
|
||||
this._chartOptions = {
|
||||
maintainAspectRatio: false,
|
||||
parsing: false,
|
||||
@ -163,13 +162,14 @@ export class StateHistoryChartTimeline extends LitElement {
|
||||
drawTicks: false,
|
||||
},
|
||||
ticks: {
|
||||
display: multipleRows,
|
||||
display:
|
||||
this.chunked || !this.isSingleDevice || this.data.length !== 1,
|
||||
},
|
||||
afterSetDimensions: (y) => {
|
||||
y.maxWidth = y.chart.width * 0.18;
|
||||
},
|
||||
afterFit: function (scaleInstance) {
|
||||
if (multipleRows) {
|
||||
afterFit: (scaleInstance) => {
|
||||
if (this.chunked) {
|
||||
// ensure all the chart labels are the same width
|
||||
scaleInstance.width = narrow ? 105 : 185;
|
||||
}
|
||||
|
@ -92,10 +92,12 @@ class StateHistoryCharts extends LitElement {
|
||||
)
|
||||
);
|
||||
|
||||
const combinedItems = chunkData(
|
||||
this.historyData.timeline,
|
||||
CANVAS_TIMELINE_ROWS_CHUNK
|
||||
).concat(this.historyData.line);
|
||||
const combinedItems = this.historyData.timeline.length
|
||||
? (this.virtualize
|
||||
? chunkData(this.historyData.timeline, CANVAS_TIMELINE_ROWS_CHUNK)
|
||||
: [this.historyData.timeline]
|
||||
).concat(this.historyData.line)
|
||||
: this.historyData.line;
|
||||
|
||||
return this.virtualize
|
||||
? html`<div class="container ha-scrollbar" @scroll=${this._saveScrollPos}>
|
||||
@ -127,8 +129,7 @@ class StateHistoryCharts extends LitElement {
|
||||
.data=${item.data}
|
||||
.identifier=${item.identifier}
|
||||
.isSingleDevice=${!this.noSingle &&
|
||||
this.historyData.line &&
|
||||
this.historyData.line.length === 1}
|
||||
this.historyData.line?.length === 1}
|
||||
.endTime=${this._computedEndTime}
|
||||
.names=${this.names}
|
||||
></state-history-chart-line>
|
||||
@ -140,11 +141,11 @@ class StateHistoryCharts extends LitElement {
|
||||
.data=${item}
|
||||
.startTime=${this._computedStartTime}
|
||||
.endTime=${this._computedEndTime}
|
||||
.noSingle=${this.noSingle}
|
||||
.isSingleDevice=${!this.noSingle &&
|
||||
this.historyData.timeline?.length === 1}
|
||||
.names=${this.names}
|
||||
.narrow=${this.narrow}
|
||||
.dataHasMultipleRows=${this.historyData.timeline.length &&
|
||||
this.historyData.timeline.length > 1}
|
||||
.chunked=${this.virtualize}
|
||||
></state-history-chart-timeline>
|
||||
</div> `;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user