All Projects → dbuezas → lovelace-plotly-graph-card

dbuezas / lovelace-plotly-graph-card

Licence: other
Highly customisable Lovelace card to display interactive graphs. Brings scrolling, zooming, and much more!

Programming Languages

typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to lovelace-plotly-graph-card

Matplotplusplus
Matplot++: A C++ Graphics Library for Data Visualization 📊🗾
Stars: ✭ 2,433 (+6302.63%)
Mutual labels:  plots, graphs
go-plotly
The goal of the go-plotly package is to provide a pleasant Go interface for creating figure specifications which are displayed by the plotly.js JavaScript graphing library.
Stars: ✭ 59 (+55.26%)
Mutual labels:  plotly, plotlyjs
Plotly.py
The interactive graphing library for Python (includes Plotly Express) ✨
Stars: ✭ 10,701 (+28060.53%)
Mutual labels:  plotly, plotlyjs
React Use Gesture
👇Bread n butter utility for component-tied mouse/touch gestures in React and Vanilla Javascript.
Stars: ✭ 5,704 (+14910.53%)
Mutual labels:  scroll, zoom
use-gesture
👇Bread n butter utility for component-tied mouse/touch gestures in React and Vanilla Javascript.
Stars: ✭ 6,624 (+17331.58%)
Mutual labels:  scroll, zoom
WikiChron
Data visualization tool for wikis evolution
Stars: ✭ 19 (-50%)
Mutual labels:  graphs, history
Swiftcharts
Easy to use and highly customizable charts library for iOS
Stars: ✭ 2,336 (+6047.37%)
Mutual labels:  plots, graphs
pbPlots
A plotting library available in many programming languages.
Stars: ✭ 71 (+86.84%)
Mutual labels:  plots, graphs
COVIDstats
COVID-19 Statistical Analysis Simulator App using R deployed on shinyapps.io a John Hopkins University COVID count clone and simulator
Stars: ✭ 13 (-65.79%)
Mutual labels:  graphs, plotly
SwiftCharts
Easy to use and highly customizable charts library for iOS
Stars: ✭ 2,405 (+6228.95%)
Mutual labels:  plots, graphs
plotly-plot
Polymer element for the plotly.js library
Stars: ✭ 21 (-44.74%)
Mutual labels:  plotly, plotlyjs
fornalder
Visualize long-term trends in collections of Git repositories.
Stars: ✭ 80 (+110.53%)
Mutual labels:  plots, history
meet-the-fans
Query and Visualize the network graph of your GitHub repositories, followers, stargazers, and forks.
Stars: ✭ 22 (-42.11%)
Mutual labels:  history
ItroublveTSC
Official Source of ItroublveTSC, totally open source. No virus or anything. Feel free to have a look :)
Stars: ✭ 82 (+115.79%)
Mutual labels:  history
visa-chart-components
Visa Chart Components (VCC) is an accessibility focused, framework agnostic set of data experience design systems components for the web. VCC attempts to provide a toolset to enable developers to build equal data experiences for everyone, everywhere.
Stars: ✭ 81 (+113.16%)
Mutual labels:  graphs
Raspberry-Pi-Electricity-Monitor
Software for monitoring the electricity consumption of a home with a Raspberry Pi
Stars: ✭ 33 (-13.16%)
Mutual labels:  graphs
zoom
Lightweight (8 Kb) ES5 javascript plugin without any dependencies, compatible with desktop and mobile devices.
Stars: ✭ 25 (-34.21%)
Mutual labels:  zoom
graphisual
A web application that lets the end users create graphs and visualize algorithms on them.
Stars: ✭ 64 (+68.42%)
Mutual labels:  graphs
window-scroll-position
React hook for Window scroll position
Stars: ✭ 81 (+113.16%)
Mutual labels:  scroll
History-Disabler-for-Chromium
Disable all browsing history in Chromium browsers.
Stars: ✭ 29 (-23.68%)
Mutual labels:  history

Plotly Graph Card




Post in HomeAssistant community forum

You may find some extra info there in this link

More yaml examples

Find more advanced examples in Show & Tell

Installation via HACS

  • Search for Plotly Graph Card.

Card Config

New Visual Config editor available for Basic Configs (*)

type: custom:plotly-graph
entities:
  - sensor.monthly_internet_energy
  - sensor.monthly_teig_energy
  - sensor.monthly_office_energy
  - sensor.monthly_waschtrockner_energy
hours_to_show: 24
refresh_interval: 10

(*) I'm reusing the editor of the standard History Card. Cheap, yes, but it works fine. Use yaml for advanced functionality

Advanced

Filling, line width, color

type: custom:plotly-graph
entities:
  - entity: sensor.office_plug_wattage
  # see examples: https://plotly.com/javascript/line-and-scatter/
  # see full API: https://plotly.com/javascript/reference/scatter/#scatter
  - entity: sensor.freezer_plug_power
    fill: tozeroy
    line:
      color: red
      dash: dot
      width: 1

layout:
  plot_bgcolor: lightgray
  height: 400
config:
  scrollZoom: false

hours_to_show: 1
refresh_interval: 10 # in seconds

Range Selector buttons

type: custom:plotly-graph
entities:
  - entity: sensor.temperature
refresh_interval: 10
hours_to_show: 12
layout:
  xaxis:
    rangeselector:
      # see examples: https://plotly.com/javascript/range-slider/
      # see API: https://plotly.com/javascript/reference/layout/xaxis/#layout-xaxis-rangeselector
      "y": 1.2
      buttons:
        - count: 1
          step: minute
        - count: 1
          step: hour
        - count: 12
          step: hour
        - count: 1
          step: day
        - count: 7
          step: day

Features

  • Anything you can do with scatter and barcharts in plotly
  • Zoom / Pan, etc.
  • Data is loaded in the background
  • Axes are automatically configured based on the units of each trace
  • Configuration compatible with the History Card

For now only the only allowed chart types are:

Entities:

entities:
  - entity: sensor.temperature
  - entity: sensor.humidity

Color schemes

Changes default line colors. See more here: https://github.com/dbuezas/lovelace-plotly-graph-card/blob/master/src/color-schemes.ts

type: custom:plotly-graph
entities:
  - sensor.temperature1
  - sensor.temperature2
color_scheme: dutch_field
# color_scheme: 1 # or use numbers instead 0 to 24 available

Attribute values

Plot the attributes of an entity by adding ::atribute_name to the entity name

entities:
  - entity: climate.living::temperature
  - entity: climate.kitchen::temperature

Extra entity attributes:

entities:
  - entity: sensor.temperature_in_celsius
    name: living temperature in Farenheit # Overrides the entity name
    lambda: |- # Transforms the data
      (ys) => ys.map(y => (y × 9/5) + 32)
    unit_of_measurement: °F # Overrides the unit
    show_value: # shows the last value with 40% right margin
      right_margin: 40
    texttemplate: >- # custom format for show_value
      <b>%{y}</b>%{customdata.unit_of_measurement}<br>
      %{customdata.name}
    hovertemplate: >- # custom format for tooltip
      <b>%{customdata.name}</b><br><i>%{x}</i><br>
      %{y}%{customdata.unit_of_measurement}
      <extra></extra>

lambda: transforms

lambda takes a js function (as a string) to pre process the data before plotting it. Here you can do things like normalisation, integration. For example:

Normalisation wrt to last

type: custom:plotly-graph
entities:
  - entity: sensor.my_sensor
     lambda: |-
        (ys) => ys.map(y => y/ys[ys.length-1])

Normalisation wrt to first fetched value

  - entity: sensor.my_sensor
     lambda: |-
        (ys) => ys.map(y => y/ys[0])

note: ys[0] represents the first "known" value, which is the value furthest to the past among the downloaded data. This value will change if you scroll, zoom out, change the hours_to_show, or just let time pass.

Accumulated value

  - entity: sensor.my_sensor
     unit_of_measurement: "total pulses"
     lambda: |-
        (ys) => {
          let accumulator = 0;
          return ys.map(y => accumulator + y)
        }

Derivative

  - entity: sensor.my_sensor
     unit_of_measurement: "pulses / second"
     lambda: |-
        (ys, xs) => {
          let last = {
            x: new Date(),
            y: 0,
          }
          return ys.map((y, index) => {
            const x = xs[index];
            const dateDelta = x - last.x;
            accumulator += (y - last.y) / dateDelta;
            last = { x, y };
            return accumulator;
          })
        }

Right hand riemann integration

  - entity: sensor.my_sensor
     unit_of_measurement: "kWh"
     lambda: |-
        (ys, xs) => {
          let accumulator = 0;
          let last = {
            x: new Date(),
            y: 0,
          }
          return ys.map((y, index) => {
            const x = xs[index]
            const dateDelta = x - last.x;
            accumulator += last.y * dateDelta;
            last = { x, y };
            return accumulator;
          })
        }

Access all entity attributes inside lambda

- entity: climate.wintergarten_floor::valve
  unit_of_measurement: °C
  lambda: |-
    (ys, xs, entity) => 
      entity.map(({attributes}) => 
        return +attributes.temperature - (+attributes.valve / 100) * 2
      )

Custom x coordinates of traces

- entity: climate.wintergarten_floor
  unit_of_measurement: °C
  lambda: |-
    (ys, xs, entity) => ({
      x: xs.map(x => -x),
      y: ys.map(y => y / 2),
    })

Default trace & axis styling

default configurations for all entities and all yaxes (e.g yaxis, yaxis2, yaxis3, etc).

entities:
  - sensor.temperature1
  - sensor.temperature2
defaults:
  entity:
    fill: tozeroy
    line:
      width: 2
  yaxes:
    fixedrange: true # disables vertical zoom & scroll

layout:

To define layout aspects, like margins, title, axes names, ... Anything from https://plotly.com/javascript/reference/layout/.

disable default layout:

Use this if you want to use plotly default layout instead. Very useful for heavy customization while following pure plotly examples.

entities:
  - entity: sensor.temperature_in_celsius
no_default_layout: true

disable Home Assistant themes:

entities:
  - entity: sensor.temperature_in_celsius
no_theme: true

config:

To define general configurations like enabling scroll to zoom, disabling the modebar, etc. Anything from https://plotly.com/javascript/configuration-options/.

hours_to_show:

How many hours are shown. Exactly the same as the history card, except decimal values (e.g 0.1) do actually work

refresh_interval:

Update data every refresh_interval seconds. Use 0 or delete the line to disable updates

Development

  • Clone the repo
  • run npm i
  • run npm start
  • From a dashboard in edit mode, go to Manage resources and add http://127.0.0.1:8000/plotly-graph-card.js as url with resource type JavaScript
  • ATTENTION: The development card is type: custom:plotly-graph-dev

Build

npm run build

Release

  • npm version minor
  • git push
  • click on releases/new draft from tag in github

Proper HACS integration and automated release pending.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].