kalkih / mini-graph-card

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

Fill color problem when line is flat #1080

Open jhemak opened 4 months ago

jhemak commented 4 months ago

Hello! Thanks for creating such a great card! I am seeing a problem similar to #652.

When the line is flat, the line is the wrong color (even though the icon is the correct color).

type: custom:mini-graph-card
name: Battery Charge
entities:
  - entity: sensor.apc_battery_charge
hours_to_show: 6
points_per_hour: 1
decimals: 0
color_thresholds_transition: hard
color_thresholds:
  - value: 20
    color: '#ff0000'
  - value: 50
    color: '#ffa500'
  - value: 80
    color: '#008000'
show:
  labels: false
  points: false
  icon_adaptive_color: true

1

When I add the lower_bound, the line turns the correct color but the fill is strange.

type: custom:mini-graph-card
name: Battery Charge
entities:
  - entity: sensor.apc_battery_charge
hours_to_show: 6
points_per_hour: 1
decimals: 0
lower_bound: ~0
color_thresholds_transition: hard
color_thresholds:
  - value: 20
    color: '#ff0000'
  - value: 50
    color: '#ffa500'
  - value: 80
    color: '#008000'
show:
  labels: false
  points: false
  icon_adaptive_color: true

2

Would be great if you can take a look at it when you have time. Thank you!

jhemak commented 4 months ago

Oops - sorry about that. Thanks for making me aware.

ildar170975 commented 4 months ago

Well,

  1. As it was already suggested in the similar post - use labels: true to make the picture clear.
  2. As it was described in readme - the value in color_threasholds stands for "starting from this point - apply this color". I.e. it should be value: 0.
  3. There are already registered issues related to thresholds - which in most cases may be fixed by defining lower_bound.
jhemak commented 4 months ago

Thanks for the suggestions - and for caching my typo on point 2. Add'l tests suggests the behavior remains the same.

type: custom:mini-graph-card
name: Battery Charge
entities:
  - entity: sensor.apc_battery_charge
hours_to_show: 12
points_per_hour: 1
decimals: 0
color_thresholds_transition: hard
color_thresholds:
  - value: 0
    color: '#ff0000'
  - value: 20
    color: '#ffa500'
  - value: 80
    color: '#008000'
show:
  labels: true
  points: false
  icon_adaptive_color: true

1

type: custom:mini-graph-card
name: Battery Charge
entities:
  - entity: sensor.apc_battery_charge
hours_to_show: 12
points_per_hour: 1
decimals: 0
lower_bound: ~0
color_thresholds_transition: hard
color_thresholds:
  - value: 0
    color: '#ff0000'
  - value: 20
    color: '#ffa500'
  - value: 80
    color: '#008000'
show:
  labels: true
  points: false
  icon_adaptive_color: true

2