Hola,
He observado un problema en la visualización de la potencia de los enchufes .
Como se puede ver en las capturas adjuntas, el gráfico y los valores de consumo evolucionan, a veces de manera significativa, pero la variación mostrada sigue bloqueada sistemáticamente en +47,50 % .
Por ejemplo, según las capturas, el perfil de consumo es muy diferente, mientras que el indicador de variación nunca cambia.
Comportamiento esperado: la variación en porcentaje debería recalcularse y actualizarse en función de los datos mostrados.
Comportamiento observado: el valor sigue en +47,50 % , independientemente de la evolución del gráfico.
Ejemplo con el enchufe del frigorífico solo que indica 95% pero arriba siempre 47,50%:
Sería quizás pertinente tener una opción para desconectar el valor en W y el porcentaje de variación, ya que « Mostrar la variación hace desaparecer los 2 valores y en mi caso solo tener la variación en porcentaje sería pertinente. »
Gracias
¡Hola a todos!
Este tema ahora está en desarrollo .
Se ha abierto una PR para que el encabezado del widget gráfico siga las series visibles en la leyenda:
master ← claude/bug-affichage-variation-nbk3fh
ouvert 11:28AM - 04 Sep 26 UTC
### Description
On a chart box with several devices and "display variation" ena… bled, the value and the variation shown above the chart were computed on **all** the devices of the box. Hiding a device through the chart legend changed the curves but never the numbers.
That is what the forum user saw on their "Puissance prises" box (washing machine + fridge): the header always showed `43.13 W +47.50%`, i.e. the average of the last values `(0 + 86.25) / 2` and the average of the per-device variations `(0% + 95%) / 2`, whatever was toggled in the legend.
What changes:
- **The header follows the legend.** Each time the chart is drawn (ApexCharts `mounted` and `updated` events, which a legend toggle goes through), `ApexChartComponent` reports the series the chart has actually collapsed (`collapsedSeriesIndices` + `ancillaryCollapsedSeriesIndices`) to `Chart`, which recomputes the last value and the variation from the visible series only. Hiding the washing machine shows the fridge alone (`86.25 W +95%`), showing it again goes back to the average of both. Reading the state of the chart rather than mirroring the clicks keeps the header right whatever ApexCharts did with a click.
- **Hidden series stay hidden while browsing periods.** ApexCharts keeps collapsed series when only the data is refreshed (`updateOptions`), and the header follows since it is fed by the chart itself. A recreated chart shows all its series, and so does the header. Hiding every series empties the header instead of showing stale numbers.
- **The chart is recreated when the devices of the box change** (`key` on `ApexChartComponent` built from `box.device_features`): the hidden series are positional, so this avoids keeping hiding an index that now points to another device, in the chart as in the header.
- **The variation is the variation of the averaged value**, not the average of the per-device variations, so the two numbers of the header describe the same quantity ("the average of the visible devices is now X, Y% more than at the start of the period"). It also avoids a device starting the period at `0` turning the whole variation into `Infinity`. In the case above the box now shows `43.13 W +95%` with both devices visible.
- The first/last values are now converted (miles/°F preferences) on the aggregated value (`min`/`max`/`sum`…) rather than only on `value`, which was a small pre-existing inconsistency.
Verified in demo mode (`npm run start-demo`, with `display_axes` temporarily enabled on the "Production and consumption" box) using Playwright: hide series A → header shows series B only, show A again → back to the average, hide B → series A only, previous period → B stays hidden in the chart and the header shows A only, hide both → empty header.
| both visible | solar inverter hidden | previous period, electric meter hidden |
|---|---|---|
| `2199 W -23%` | `1500 W -25%` | `3996 W +48%` |
## Forum
Forum: https://community.gladysassistant.com/t/bug-d-affichage-la-variation-en-ne-se-met-pas-a-jour/10797
### Checklist
- [x] Tests pass: front-only change, no server code touched; Cypress has no chart-box spec, the behaviour was verified manually in demo mode with Playwright (see above)
- [x] Linter and prettier pass on both front and server (`npm run eslint`, `npm run prettier`)
- [x] No undocumented breaking change
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01HrXCc7YmGQP6o97Evz8ttc
## Summary by CodeRabbit
* **Bug Fixes**
* Chart event handling now preserves existing chart behaviors while tracking hidden series.
* Chart summary values now update correctly when series are hidden or shown through the legend.
* Hidden-series tracking now remains accurate when multiple series are collapsed.
* Charts refresh correctly when configured device features change, including legacy single-device configurations.
* Existing timeline chart styling and other configured chart interactions continue to work alongside hidden-series updates.
No duden en seguir la PR, probar (opcional, especialmente para pequeñas solicitudes) y dar sus comentarios aquí si es necesario.