Skip to content

Commit

Permalink
Merge pull request #144 from mlamberts78/develop
Browse files Browse the repository at this point in the history
Fix conflict with weather-card
  • Loading branch information
mlamberts78 authored Mar 20, 2024
2 parents 07ad0c1 + fc2691f commit 8fa8d23
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
84 changes: 42 additions & 42 deletions dist/weather-chart-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -1558,7 +1558,7 @@ class WeatherCardEditor extends s {
`;
}
}
customElements.define("weather-card-editor", WeatherCardEditor);
customElements.define("weather-chart-card-editor", WeatherChartCardEditor);

/**
* @license
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -727,4 +727,4 @@ class WeatherCardEditor extends LitElement {
`;
}
}
customElements.define("weather-card-editor", WeatherCardEditor);
customElements.define("weather-chart-card-editor", WeatherChartCardEditor);

0 comments on commit 8fa8d23

Please sign in to comment.