Lovelace: custom history graph

I created a custom history graph card today that allows you to zoom on your data, does live updating and is more customizable.

Will need some further tweaking, especially with some caching.

Compared to the default:


and zoomed in:
image

shown config:

      - type: "custom:graph-card"
        hours_to_show: 24
        update_interval: 10
        zoom: 75
        entities:
          - entity: sensor.elektra_verbruik_vandaag
            color: "#ffce57"
            areaStyle: {}
            smooth: true
            name: Totaal
          - entity: sensor.elektra_dal_verbruik_vandaag
            name: Dal
            color: "#36A2EB"
            smooth: true
            areaStyle: {}
          - entity: sensor.elektra_piek_verbruik_vandaag
            name: Piek
            color: "#FF6384"
            smooth: true
            areaStyle: {}

basic config:

      - type: "custom:graph-card"
        entities:
          - sensor.elektra_verbruik_vandaag
          - sensor.elektra_dal_verbruik_vandaag
          - sensor.elektra_piek_verbruik_vandaag

advanced config:

      - type: "custom:graph-card"
        title: 'Stroom verbruik'
        hours_to_show: 24
        update_interval: 10
        zoom: 75
        entities:
          - entity: sensor.elektra_dal_verbruik_vandaag
            name: Dal
            smooth: false
            color: "blue"
            areaStyle:
              color:
                type: 'linear'
                x: 0
                y: 0
                x2: 0
                y2: 1
                colorStops: 
                  - offset: 0
                    color: 'red'
                  - offset: 1
                    color: 'blue' 
                globalCoord: false
          - entity: sensor.elektra_piek_verbruik_vandaag
            name: Piek
            smooth: true
            color: "red"
            areaStyle:
              color:
                type: 'radial'
                x: 0.5
                y: 0.5
                r: 0.5
                colorStops: 
                  - offset: 0
                    color: 'blue'
                  - offset: 1
                    color: 'red'
                globalCoord: false
          - entity: sensor.elektra_verbruik_vandaag
            areaStyle: {}
            name: Totaal
          - sensor.elektra_verbruik_vandaag

Installation:

Download graph-card.js and echarts.min.js and place them in /config/www/custom-lovelace/graph-card/ (or another folder but you will need to adjust the path to echarts.min.js in graph-card.js)

Include graph-card.js in your lovelace config:

resources:
  - url: /local/custom-lovelace/graph-card/graph-card.js?v=0.1
    type: js
13 Likes

YES PLEASE!

Great i wanted something like this

Looks absolutely beautiful

Donā€™t know why, but canā€™t get this to workā€¦ Just gives me a blank cardā€¦ :frowning:

Found it. You hard reference to
getScript("/local/custom-lovelace/graph-card/echarts.min.js", function(){
in the graph-card.js

In your first post you mention that you can change the install dir, which I did. So thatā€™s why it failed in my case.

I changed to my own custom location and now it works, but at the next update (I use your update json also), it will fail againā€¦
I hope you can fix that. :wink:

Nice card by the way! Thanks!!

Looks cool now! Any chance you can add the labels and the title?

installed everything and itā€™s showing, but for some reason the main area doesnā€™t show anythingā€¦
Iā€™ve placed it in the folder you suggested and copied the config you suggested (only changed the entity)
Any idea what could be wrong ?

Same thing here, changed path though. Card show up and working fine in android mobile!!! but not on computer with chrome or edge. No graph in main windows but I do see the small graph below.

Is it any documentation for

areaStyle: {}

?

https://ecomfe.github.io/echarts-doc/public/en/option.html#series-line.areaStyle

Thanks, i already find but was not sure :slight_smile: One more question - is it possible to use another settings from that page to the chart? If yes - how?

You could add them here:

You could add them here:

Thanks!

Same here, on my laptop in Chrome it doesnā€™t work (large graph is there but no data is shown), on my phone in Chrome it does. Itā€™s a shame, it looks really cool.

Same here, no data on Firefox or Chrome on Ubuntu. Android works fine.

any update on this ?

Do you see any errors in the console? Can you check if the network request is successful?

Hi

How to make ā€œlegendā€ visible?
And how to name graph?

P.S.
It looks very nice! Just a bit slow, butā€¦ something for something :slight_smile:

I really like the look of the graph! The customization is easy too, but I would like to turn of the data points, is it possible?

Iā€™m trying to add this card in ā€˜Edit UI modeā€™ but i get an error when adding a name.

My question is: will this work in UI mode? Or will it ony work when in YAML mode?