Annotation for min and max in a specific timeframe #309
Answered
by
dbuezas
marce14-git
asked this question in
Q&A
-
I am trying to copy my apexchart graph with annotations/labels at min and max, preferably in the last 24h, or in the next 24h for the forcast thanks in advance |
Beta Was this translation helpful? Give feedback.
Answered by
dbuezas
Sep 3, 2023
Replies: 1 comment 3 replies
-
Hi Marce,
type: custom:plotly-graph
hours_to_show: 12
entities:
- entity: sensor.openweathermap_temperature
fn: |- # put this one at the end of the entity
$ex {
let max = {y: -Infinity};
let min = {y: +Infinity};
for (let i = 0; i < ys.length; i++){
const x = xs[i];
const y = parseFloat(ys[i]);
if (y > max.y) max = {x, y};
if (y < min.y) min = {x, y};
}
vars.min = min
vars.max = max
}
layout:
annotations:
- x: $ex vars.min.x
y: $ex vars.min.y
text: $ex vars.min.y.toFixed(2)
ax: -30
ay: -40
- x: $ex vars.max.x
y: $ex vars.max.y
text: $ex vars.max.y.toFixed(2)
ax: -30
ay: -40 |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
dbuezas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Marce,
I don't see any simple way of doing this without using custom functions.
If you want to style the annotations, take a look at these: