kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
2.85k stars 231 forks source link

fix: always get points so state last works with other graphs #1075

Open jasonlewis opened 4 months ago

jasonlewis commented 4 months ago

Fixes #736 by always getting points.

There's probably a few ways to fix this as it seems the state: last functionality specifically relies on points being available, but points are only set when specifically showing points (and never for bar graphs).

I decided to always define points and adjust the logic for rendering points to be based on whether the config is set. Granted I haven't tested all scenarios for rendering points so this may not be an adequete solution in all cases.

akloeckner commented 4 months ago

@jasonlewis, thanks for contributing! It seems we'll have to work on it a bit still. See my comment. Unfortunately, I will only be able to look into it in a few days...

akloeckner commented 4 months ago

I did think about this quite some time. Sorry for the delay.

Although it's a small change, I don't like that we would treat points differently from the other properties, such as bar. So, I wondered, could we make this more consistent and came up with two ideas:

  1. What do you think about always defining all those properties and moving the conditions to the render* functions? I'm a bit hesitant, because I still don't fully understand, how much calculating this would cause.

  2. One other thing, I just stumbled against is: we could maybe just use this.Graph[id].coords[-1][V] instead of this.points[id][-1][V]. Or would we abuse the Graph then?

What do you think? Maybe you discarded these ideas already for some reason?