mini-graph-card icon indicating copy to clipboard operation
mini-graph-card copied to clipboard

color thresholds: wrong line color

Open nschloe opened this issue 2 years ago • 14 comments

I have a mini-graph-card with some color thresholds:

type: custom:mini-graph-card
entities:
  - sensor.bogenhanf_conductivity
align_icon: left
align_state: left
show:
  fill: true
hours_to_show: 336
lower_bound: 0
upper_bound: 2500
color_thresholds:
  - value: 300
    color: '#D0342C'
  - value: 301
    color: '#008000'
  - value: 1000
    color: '#D0342C'
color_thresholds_transition: hard

The dots (shown when hovering over the graph) have the correct color, but the line doesnt:

s2

s1

It doesn't matter if the transition is hard or smooth

nschloe avatar Dec 22 '22 10:12 nschloe

Hi,

There seems to be a drift on the linear gradient when setting a higher upper_bound.

If you need the color at a glance I'd recommend to either remove the upper_bound or set show option's points: true

jlsjonas avatar Dec 24 '22 01:12 jlsjonas

Observe the red and green area below the graph: They're also incorrectly computed. Perhaps the bug has something to do with that.

nschloe avatar Dec 24 '22 09:12 nschloe

@nschloe

  1. Cannot reproduce your issue.

image Code for the 1st card:

type: custom:mini-graph-card
name: 'lower_bound: ~400'
entities:
  - sensor.xiaomi_cg_1_co2
show:
  fill: true
  labels: true
hours_to_show: 48
height: 500
line_width: 2
lower_bound: ~400
upper_bound: 1000
color_thresholds:
  - value: 400
    color: green
  - value: 500
    color: red
  - value: 600
    color: blue
color_thresholds_transition: hard
  1. Please post screenshots in a way to make them more visible.

red and green area below the graph

On your screenshots this is rather subtle. Use a default light theme next time. And make it easier for yourself - increase a height, otherwise the area is too narrow to see anything.

Please report can you still see the issue.

ildar170975 avatar Jan 20 '24 05:01 ildar170975

All your transitions are quite sharp. Try it with flatter data near a color threshold.

nschloe avatar Jan 21 '24 13:01 nschloe

All your transitions are quite sharp.

This is good.

Try it with flatter data near a color threshold.

What can it change?

image

type: vertical-stack
cards:
  - type: entities
    entities:
      - input_number.number
  - type: custom:mini-graph-card
    entities:
      - input_number.number
    show:
      fill: true
      labels: true
    hours_to_show: 0.083333
    height: 500
    cache: false
    line_width: 2
    lower_bound: 0
    points_per_hour: 600
    smoothing: false
    color_thresholds:
      - value: 0
        color: green
      - value: 10
        color: red
      - value: 20
        color: blue
    color_thresholds_transition: hard

ildar170975 avatar Jan 21 '24 21:01 ildar170975

This is good.

Well, mine aren't and that causes the problem. If the transition is shallow, colors aren't correctly assigned.

nschloe avatar Jan 22 '24 15:01 nschloe

What is a “shallow” transition? There are 2 types of transition. If you mean “smooth” - then take MY example, change to “smooth” and please show what is wrong there.

ildar170975 avatar Jan 22 '24 19:01 ildar170975

Sorry, my wording was unclear. In your examples, the graphs "dive" sharply from one area to the next. In my example, the y-value hardly changes. Over the whole x-length of the graph, it creeps down:

i1

From looking at it, it seems that everything is still in the green. That's wrong though! The transition into the "red" color area has already happened, and is revealed when hovering with the mouse pointer over the image to such that the points are highlighted:

f

I hope this makes things clearer.

nschloe avatar Jan 23 '24 07:01 nschloe

Already suggested you to make graphs more clear - height, theme. Sorry, can barely see.

ildar170975 avatar Jan 23 '24 07:01 ildar170975

Sorry, can barely see.

Can you see that the graph is completely green in the above chart, and red on the right-hand side in the below graph?

nschloe avatar Jan 23 '24 07:01 nschloe

Perhaps someone may use a loupe and help you.

ildar170975 avatar Jan 23 '24 07:01 ildar170975

I'm really at a loss tring to explain the issue. Last attempt:

rnr

Two pictures of the same data, going from green to red. Top is with mouse hover, so the little data points are visible. They are red; good. Bottom: Just the graph lines. All green; not good.

nschloe avatar Jan 23 '24 08:01 nschloe

You got an issue which you want to sort out. For this you need to simplify the case - to make it clear. Twice I suggested you how we can simplify it - increase height and make colors clearly visible by using a light default theme. Let’s not spent a lot of time and posts for discussing a necessity of these suggestions; and in the end we might still not be able to solve the issue. But it may help.

ildar170975 avatar Jan 23 '24 11:01 ildar170975

Also, thresholds were set in a wrong way:

  - value: 300
    color: '#D0342C'

i.e. starting from "300", but actual data may be below 300 which causes inconsistency.

ildar170975 avatar Jan 27 '24 19:01 ildar170975

No feedback within 3 months, closing

ildar170975 avatar May 01 '24 12:05 ildar170975