Comments (7)
I'm thinking of something like this:
example of normalisation wrt to last
type: custom:plotly-graph
entities:
- entity: sensor.my_sensor
lambda: |-
(ys) => ys.map(y => y/ys[ys.length-1])
example of normalisation wrt to first fetched value
- entity: sensor.my_sensor
lambda: |-
(ys) => ys.map(y => y/ys[0])
So basically a js function that receives all the data for that entity, and you can do whatever you want. The problem is that the unit_of_measurement would also need to be tweakable.
Here some more examples, including unit_of_measurement
(to show along the y axis and in the tooltips).
example of accumulated value
- entity: sensor.my_sensor
unit_of_measurement: "total pulses"
lambda: |-
(ys) => {
let accumulator = 0;
return ys.map(y => accumulator + y)
}
example of 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;
})
}
example of 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;
})
}
What do you think?
Regarding normalising against the first value, you should consider that the "first value" will be just the 1st known value, which will change if you scroll the plot and older data is fetched
edit: changed variable names to x and y
from lovelace-plotly-graph-card.
Cool, then I'll give it a go tomorrow :)
Thanks for the cool ideas!
I use my own hardcoded "hacked" version to do things like these.
With your feedback, I think we nailed a configurable way 👍
from lovelace-plotly-graph-card.
Thanks for implementation!
Works as specified :-)
from lovelace-plotly-graph-card.
Interesting idea.
Can you post examples as you imagine the configuration would look like?
The other two alternatives I see are:
- To guide people towards the statistics sensor
- To allow for an arbitrary JavaScript mapping function
But I do like the convinice your idea would bring
from lovelace-plotly-graph-card.
Let's take the normalization on the latest value and assume to have N lines (e.g. different stocks) in the chart. Then I'd like to see all lines in the chart ending up to 100%
n=1,..,N
values[n][:] = values[n][:]/values[n][-1]
by that kind of normalizsation you can see the trend of the stocks, independent from the selected timeframe (4h, 1d, 1w)
alternatively we can also normalize with the first value (values[n][:]/values[n][0]), then we see the trend based on the selected timeframe -> how much percent did the stock perform better than the other one
allowing mapping functions sounds interessting
from lovelace-plotly-graph-card.
Looks great!
With these examples, it looks like a real nice playground to experiment with visualisations directly in the lovelace config!
from lovelace-plotly-graph-card.
@lein1013 done in v0.5.0!
try it out and let me know if it works as you needed :)
from lovelace-plotly-graph-card.
Related Issues (20)
- reset_every filter does not consider start of [day|week|month] HOT 3
- Color Threshold or Color Scale in chart HOT 1
- Data not being updated on real time HOT 16
- Display times with HA selected timezone?
- Gaps in data when scrolling HOT 16
- Non null flat line joining when no data HOT 23
- Pie chart not working HOT 3
- URL duplicated in the `no_default_layout` deprecation message HOT 3
- Add a "year" grouping option in period
- Edition window moves under Safari
- Add notation points along realtime graph.
- Range of data not updating when zooming out HOT 4
- "resample" does not allign traces iwth different initial starting points HOT 1
- Show value missing when using filter HOT 2
- Resample is not timezone aware HOT 2
- To be able to detect whether a trace is displayed (enabled or disabled in the legend) HOT 3
- Statistic data is not renewed within graphs's live time HOT 1
- Fillgradient in scatter graphs HOT 1
- FR: Using Plotly.Fx.hover in callbacks
- Global or tag based date and time picker. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lovelace-plotly-graph-card.