mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 00:06:35 +00:00
Fix time format in charts (#6671)
This commit is contained in:
parent
e8f6a79c8f
commit
294665fbe8
@ -1,12 +1,12 @@
|
|||||||
/* eslint-plugin-disable lit */
|
/* eslint-plugin-disable lit */
|
||||||
import { IronResizableBehavior } from "@polymer/iron-resizable-behavior/iron-resizable-behavior";
|
import { IronResizableBehavior } from "@polymer/iron-resizable-behavior/iron-resizable-behavior";
|
||||||
import "../ha-icon-button";
|
|
||||||
import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class";
|
import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class";
|
||||||
import { timeOut } from "@polymer/polymer/lib/utils/async";
|
import { timeOut } from "@polymer/polymer/lib/utils/async";
|
||||||
import { Debouncer } from "@polymer/polymer/lib/utils/debounce";
|
import { Debouncer } from "@polymer/polymer/lib/utils/debounce";
|
||||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||||
import { formatTime } from "../../common/datetime/format_time";
|
import { formatTime } from "../../common/datetime/format_time";
|
||||||
|
import "../ha-icon-button";
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
/* global Chart moment Color */
|
/* global Chart moment Color */
|
||||||
@ -355,7 +355,7 @@ class HaChartBase extends mixinBehaviors(
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
const date = new Date(values[index].value);
|
const date = new Date(values[index].value);
|
||||||
return formatTime(date);
|
return formatTime(date, this.hass.language);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawChart() {
|
drawChart() {
|
||||||
@ -420,7 +420,7 @@ class HaChartBase extends mixinBehaviors(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
options = Chart.helpers.merge(options, this.data.options);
|
options = Chart.helpers.merge(options, this.data.options);
|
||||||
options.scales.xAxes[0].ticks.callback = this._formatTickValue;
|
options.scales.xAxes[0].ticks.callback = this._formatTickValue.bind(this);
|
||||||
if (this.data.type === "timeline") {
|
if (this.data.type === "timeline") {
|
||||||
this.set("isTimeline", true);
|
this.set("isTimeline", true);
|
||||||
if (this.data.colors !== undefined) {
|
if (this.data.colors !== undefined) {
|
||||||
|
@ -19,6 +19,7 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
|
|||||||
</style>
|
</style>
|
||||||
<ha-chart-base
|
<ha-chart-base
|
||||||
id="chart"
|
id="chart"
|
||||||
|
hass="[[hass]]"
|
||||||
data="[[chartData]]"
|
data="[[chartData]]"
|
||||||
identifier="[[identifier]]"
|
identifier="[[identifier]]"
|
||||||
rendered="{{rendered}}"
|
rendered="{{rendered}}"
|
||||||
@ -28,6 +29,9 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
|
|||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
|
hass: {
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
chartData: Object,
|
chartData: Object,
|
||||||
data: Object,
|
data: Object,
|
||||||
names: Object,
|
names: Object,
|
||||||
|
@ -25,6 +25,7 @@ class StateHistoryChartTimeline extends LocalizeMixin(PolymerElement) {
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<ha-chart-base
|
<ha-chart-base
|
||||||
|
hass="[[hass]]"
|
||||||
data="[[chartData]]"
|
data="[[chartData]]"
|
||||||
rendered="{{rendered}}"
|
rendered="{{rendered}}"
|
||||||
rtl="{{rtl}}"
|
rtl="{{rtl}}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user