From 52d87600c36b125385acf791e983e3646d6363c2 Mon Sep 17 00:00:00 2001 From: Daniel Martin Gonzalez Date: Tue, 12 Dec 2023 12:24:20 +0100 Subject: [PATCH] Feature #53: Add Baseline Zero option to graph --- dist/pvpc-hourly-pricing-card.js | 38 +++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/dist/pvpc-hourly-pricing-card.js b/dist/pvpc-hourly-pricing-card.js index 44ad040..db7c16b 100644 --- a/dist/pvpc-hourly-pricing-card.js +++ b/dist/pvpc-hourly-pricing-card.js @@ -12,6 +12,7 @@ const locale = { infoNoNextDay: 'Les dades de demà encara no estan disponibles', from: 'de', to: 'a', + optionBaselineZero: 'Línia base zero', optionName: 'Nom (Opcional)', optionEntity: 'Entitat (Necessari)', optionShowCurrent: 'Mostrar Estat Actual', @@ -27,6 +28,7 @@ const locale = { infoNoNextDay: 'Morgendagens data er endnu ikke tilgængelige', from: 'fra', to: 'til', + optionBaselineZero: 'Nul baseline', optionName: 'Navn (valgfrit)', optionEntity: 'Enhed (påkrævet)', optionShowCurrent: 'Vis nuværende status', @@ -42,6 +44,7 @@ const locale = { infoNoNextDay: 'Die Daten von morgen sind noch nicht verfügbar', from: 'von', to: 'bis', + optionBaselineZero: 'Null-Basislinie', optionName: 'Name (optional)', optionEntity: 'Entity (Erforderlich)', optionShowCurrent: 'Aktuellen Status anzeigen', @@ -57,6 +60,7 @@ const locale = { infoNoNextDay: "Tomorrow's data is not yet available", from: 'from', to: 'to', + optionBaselineZero: 'Baseline zero', optionName: 'Name (Optional)', optionEntity: 'Entity (Required)', optionShowCurrent: 'Show Current State', @@ -72,6 +76,7 @@ const locale = { infoNoNextDay: 'Los datos de mañana no están disponibles aún', from: 'de', to: 'a', + optionBaselineZero: 'Línea base cero', optionName: 'Nombre (Opcional)', optionEntity: 'Entidad (Necesario)', optionShowCurrent: 'Mostrar Estado Actual', @@ -87,6 +92,7 @@ const locale = { infoNoNextDay: 'Les données de demain ne sont pas encore disponibles', from: 'de', to: 'à', + optionBaselineZero: 'Référence zéro', optionName: 'Nom (Facultatif)', optionEntity: 'Entity (Required)', optionShowCurrent: "Afficher l'état actuel", @@ -102,6 +108,7 @@ const locale = { infoNoNextDay: 'De gegevens van morgen zijn nog niet beschikbaar', from: 'fra', to: 'til', + optionBaselineZero: 'Nul basislijn', optionName: 'Naam (optioneel)', optionEntity: 'Entiteit (vereist)', optionShowCurrent: 'Toon huidige status', @@ -117,6 +124,7 @@ const locale = { infoNoNextDay: 'Os dados de amanhã ainda não estão disponíveis', from: 'das', to: 'às', + optionBaselineZero: 'Linha de base zero', optionName: 'Nome (Opcional)', optionEntity: 'Entidade (Obrigatório)', optionShowCurrent: 'Mostrar Estado Actual', @@ -132,6 +140,7 @@ const locale = { infoNoNextDay: 'Данные завтра еще не доступны', from: 'С', to: 'до', + optionBaselineZero: 'Нулевая базовая линия', optionName: 'Имя (необязательно)', optionEntity: 'Entity (обязательно)', optionShowCurrent: 'Показать текущий статус', @@ -147,6 +156,7 @@ const locale = { infoNoNextDay: 'Morgondagens data är ännu inte tillgängliga', from: '', to: 'till', + optionBaselineZero: 'Noll baslinje', optionName: 'Namn (valfritt)', optionEntity: 'Enhet (obligatoriskt)', optionShowCurrent: 'Visa aktuell status', @@ -341,7 +351,7 @@ class PVPCHourlyPricingCard extends LitElement { ${this.ll('from')} ${maxPriceFrom} ${this.ll('to')} ${maxPriceTo} ${this.despiction.minPriceNextDay - ? html`
  • + ? html`
  • ${this.ll('minPriceNextDay')} ${minPriceNextDay}${this.pvpcHourlyPricingObj.attributes.unit_of_measurement} ${this.ll('from')} @@ -353,7 +363,7 @@ class PVPCHourlyPricingCard extends LitElement { ${maxPriceNextDay}${this.pvpcHourlyPricingObj.attributes.unit_of_measurement} ${this.ll('from')} ${maxPriceFromNextDay} ${this.ll('to')} ${maxPriceToNextDay}
  • ` - : ''} + : ''} `; } @@ -476,7 +486,7 @@ class PVPCHourlyPricingCard extends LitElement { adapters: { date: { locale: this.hass.locale, - config: this.hass.config, + config: this.hass.config } }, ticks: { @@ -579,6 +589,10 @@ class PVPCHourlyPricingCard extends LitElement { }); } + if (this._config.baseline_zero) { + chartOptions.options.scales.y.suggestedMin = 0; + } + this.ChartData = chartOptions; } @@ -771,6 +785,10 @@ export class PVPCHourlyPricingCardEditor extends LitElement { return this._config.info !== false; } + get _baseline_zero() { + return this._config.baseline_zero == true; + } + render() { if (!this.hass) { return html``; @@ -838,6 +856,20 @@ export class PVPCHourlyPricingCardEditor extends LitElement { + ${this._graph + ? html` +
    +
    + + +
    +
    + ` + : html``} `; }