Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line segment idea #20

Open
Arkkimaagi opened this issue Jun 27, 2024 · 1 comment
Open

Line segment idea #20

Arkkimaagi opened this issue Jun 27, 2024 · 1 comment

Comments

@Arkkimaagi
Copy link

If I understood correctly based on a forum post, this card might use chart.js to render the charts.

I'd love if we could color line segments based on some criteria, so I could avoid having to color a separate timeline below the line segment.
image

Currently I do it with this config:

type: custom:history-explorer-card
cardName: historycard-39265679
header: Historia
defaultTimeRange: 24h
decimation: accurate
lineMode: stepped
lineGraphHeight: 500
barGraphHeight: 500
refresh:
  automatic: true
uiLayout:
  selector: hide
stateColors:
  poistaa: '#43a047'
  varo: '#ffa600'
  puhaltaa: '#db4437'
  virhe: '#039be5'
graphs:
  - type: line
    options: null
    entities:
      - entity: sensor.airflow_direction
        name: Airflow Direction
  - type: timeline
    entities:
      - entity: sensor.airflow_direction
        name: Airflow Direction
        process: |-
          ( state < 10 ) ? 
            "poistaa" : 
            ( state < 20) ?
              "varo" :
              ( state >= 20 ) ?
              "puhaltaa" : "virhe"

To me it seems that chart.js supports line segment coloring, so could there be a way to color the line based on similar rules?

https://www.chartjs.org/docs/latest/samples/line/segments.html

@Arkkimaagi
Copy link
Author

On simpler cases just setting the fill color and origin might be enough, but most flexible would be with a similar coloring than states.

https://www.chartjs.org/docs/latest/charts/area.html#example-with-multiple-colors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant