diff --git a/dist/weather-chart-card.js b/dist/weather-chart-card.js index b66c895..557af5b 100644 --- a/dist/weather-chart-card.js +++ b/dist/weather-chart-card.js @@ -842,7 +842,7 @@ const ALT_SCHEMA = [ { name: "windspeed", title: "Alternative wind speed sensor", selector: { entity: { domain: 'sensor' } } }, ]; -class WeatherCardEditor extends s { +class WeatherChartCardEditor extends s { static get properties() { return { _config: { type: Object }, @@ -1558,7 +1558,7 @@ class WeatherCardEditor extends s { `; } } -customElements.define("weather-card-editor", WeatherCardEditor); +customElements.define("weather-chart-card-editor", WeatherChartCardEditor); /** * @license @@ -17683,7 +17683,7 @@ Chart.register(...registerables, plugin); class WeatherChartCard extends s { static getConfigElement() { - return document.createElement("weather-card-editor"); + return document.createElement("weather-chart-card-editor"); } static getStubConfig(hass, unusedEntities, allEntities) { @@ -18268,46 +18268,46 @@ drawChart({ config, language, weather, forecastItems } = this) { drawTicks: false, color: dividerColor, }, -ticks: { - maxRotation: 0, - color: config.forecast.chart_datetime_color || textColor, - padding: config.forecast.precipitation_type === 'rainfall' && config.forecast.show_probability && config.forecast.type !== 'hourly' ? 4 : 10, - callback: function (value, index, values) { - var datetime = this.getLabelForValue(value); - var dateObj = new Date(datetime); + ticks: { + maxRotation: 0, + color: config.forecast.chart_datetime_color || textColor, + padding: config.forecast.precipitation_type === 'rainfall' && config.forecast.show_probability && config.forecast.type !== 'hourly' ? 4 : 10, + callback: function (value, index, values) { + var datetime = this.getLabelForValue(value); + var dateObj = new Date(datetime); - var timeFormatOptions = { - hour12: config.use_12hour_format, - hour: 'numeric', - ...(config.use_12hour_format ? {} : { minute: 'numeric' }), - }; - - var time = dateObj.toLocaleTimeString(language, timeFormatOptions); - var mode = 'daily'; - - if (forecast.length >= 3 && new Date(forecast[2].datetime) - new Date(forecast[1].datetime) < 864e5) { - mode = 'hourly'; - } - - if (dateObj.getHours() === 0 && dateObj.getMinutes() === 0 && mode === 'hourly') { - var dateFormatOptions = { - day: 'numeric', - month: 'short', - }; - var date = dateObj.toLocaleDateString(language, dateFormatOptions); - time = time.replace('a.m.', 'AM').replace('p.m.', 'PM'); - return [date, time]; - } - - if (mode !== 'hourly') { - var weekday = dateObj.toLocaleString(language, { weekday: 'short' }).toUpperCase(); - return weekday; - } - - time = time.replace('a.m.', 'AM').replace('p.m.', 'PM'); - return time; - }, -}, + var timeFormatOptions = { + hour12: config.use_12hour_format, + hour: 'numeric', + ...(config.use_12hour_format ? {} : { minute: 'numeric' }), + }; + + var time = dateObj.toLocaleTimeString(language, timeFormatOptions); + var mode = 'daily'; + + if (forecast.length >= 3 && new Date(forecast[2].datetime) - new Date(forecast[1].datetime) < 864e5) { + mode = 'hourly'; + } + + if (dateObj.getHours() === 0 && dateObj.getMinutes() === 0 && mode === 'hourly') { + var dateFormatOptions = { + day: 'numeric', + month: 'short', + }; + var date = dateObj.toLocaleDateString(language, dateFormatOptions); + time = time.replace('a.m.', 'AM').replace('p.m.', 'PM'); + return [date, time]; + } + + if (mode !== 'hourly') { + var weekday = dateObj.toLocaleString(language, { weekday: 'short' }).toUpperCase(); + return weekday; + } + + time = time.replace('a.m.', 'AM').replace('p.m.', 'PM'); + return time; + }, + }, }, TempAxis: { position: 'left', diff --git a/src/main.js b/src/main.js index 434fb61..7ae0c17 100644 --- a/src/main.js +++ b/src/main.js @@ -7,7 +7,7 @@ import { WeatherEntityFeature } from './const.js'; import {LitElement, html} from 'lit'; -import './weather-card-editor.js'; +import './weather-chart-card-editor.js'; import { property } from 'lit/decorators.js'; import {Chart, registerables} from 'chart.js'; import ChartDataLabels from 'chartjs-plugin-datalabels'; @@ -16,7 +16,7 @@ Chart.register(...registerables, ChartDataLabels); class WeatherChartCard extends LitElement { static getConfigElement() { - return document.createElement("weather-card-editor"); + return document.createElement("weather-chart-card-editor"); } static getStubConfig(hass, unusedEntities, allEntities) { diff --git a/src/weather-card-editor.js b/src/weather-chart-card-editor.js similarity index 99% rename from src/weather-card-editor.js rename to src/weather-chart-card-editor.js index e3f4f15..0210b4b 100644 --- a/src/weather-card-editor.js +++ b/src/weather-chart-card-editor.js @@ -11,7 +11,7 @@ const ALT_SCHEMA = [ { name: "windspeed", title: "Alternative wind speed sensor", selector: { entity: { domain: 'sensor' } } }, ]; -class WeatherCardEditor extends LitElement { +class WeatherChartCardEditor extends LitElement { static get properties() { return { _config: { type: Object }, @@ -727,4 +727,4 @@ class WeatherCardEditor extends LitElement { `; } } -customElements.define("weather-card-editor", WeatherCardEditor); +customElements.define("weather-chart-card-editor", WeatherChartCardEditor);