kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
2.95k stars 232 forks source link

group_by: date - not working? #191

Closed simonwood0609 closed 4 years ago

simonwood0609 commented 4 years ago

Thanks so much for sharing this card @kalkih !

I can't for the life of me figure out why the group_by flag isn't working - I copied your exact template from the guide and changed the sensor only.

Each day has multiple bar-points (the last two "trends" are two days).

type: 'custom:mini-graph-card'
entities:
  - entity: sensor.fronius_day_energy
name: Energy Generation
hours_to_show: 168
aggregate_func: max
group_by: date
show:
  graph: bar

image

kalkih commented 4 years ago

Hey, You're most likely not loading the latest version of the card. If you've installed through HACS, please see this https://github.com/kalkih/mini-graph-card/issues/169. If you've installed the card manually, try clearing the browser cache.

simonwood0609 commented 4 years ago

Sorry for the late reply - thanks, that fixed it! Just deleted the plugin & re-installed via HACS since I'd previously added it manually.

By the way, any way to easily remove the timestamp from the data when mouse-over?

image

kalkih commented 4 years ago

Not without changing the source code, but yes, we should probably skip the timestamp if grouped by date.

simonwood0609 commented 4 years ago

I'm pretty new to GitHub, where can I leave feature requests?

I'm also wondering if the bar graph can/does support negative values, as some days I produce more power than I consume so the net/total is negative. Would be nice to have that coloured differently too.

kalkih commented 4 years ago

You can just open another issue and state that it's a feature request.

The bar graph does support negative value, the y-axis will change dynamically based on min/max data points.

Sure, you could use color thresholds to render negative bars red and positive bars green for example:

- type: custom:mini-graph-card
  entities:
    - sensor.energy
  show:
    graph: bar
    icon_adaptive_color: true
  color_thresholds:
    - value: -50
      color: '#e74c3c' # red
    - value: 0 # above 0 render as this color
      color: '#27ae60' *# green

An example of a server load bar graph with color thresholds hyperion_8123_lovelace_example (17)

simonwood0609 commented 4 years ago

Thanks again for your time @kalkih .

I now understand how your graph visualises negative data - at first I thought the y-axis responsive scale must have been wrong (why is 1.17 so close to 6.84?) image

Then I realised that is because the zero-line is somewhere here: image

This is what I was hoping to acheive: image

Is that possible currently?

Also how would I add data-labels to the bar graph to show each bar's value?

Here's my current code:

entities:
  - entity: sensor.energyeasy_yesterday_usage
group_by: date
hours_to_show: 336
name: Energy Usage
show:
  graph: bar
type: 'custom:mini-graph-card'
icon_adaptive_color: true
color_thresholds:
  - color: green
    value: -50
  - color: yellow
    value: 0
  - color: orange
    value: 5
  - color: red
    value: 10
kalkih commented 4 years ago

Is that possible currently?

Also how would I add data-labels to the bar graph to show each bar's value?

No, that graph type is not supported. If you want a challenge you could potentially play around with template sensors and some custom css to achieve it though. Here's an example of what you can achieve pretty easily (line graph though).

As for the bar values hover/touch is the only way to see the value atm.