Skip to content

Commit 9988f6c

Browse files
authored
Enhance Extra entity attributes section (#283)
* Enhance Extra entity attributes section * Update readme.md * Update readme.md
1 parent 7ce592e commit 9988f6c

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

readme.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,16 +394,23 @@ entities:
394394
name: living temperature in Farenheit # Overrides the entity name
395395
unit_of_measurement: °F # Overrides the unit
396396
show_value: true # shows the last value as text
397+
customdata: |
398+
$fn ({states}) =>
399+
states.map( () => ({ extra_attr: "hello" }) )
400+
# customdata is array with the same number of values as x axis (states)
401+
# use statistics instead of states if entity is based on statistic
397402
texttemplate: >- # custom format for show_value
398-
<b>%{y}</b>%{customdata.unit_of_measurement}<br>
399-
%{customdata.name}
403+
<b>%{y}</b>%{customdata.extra_attr}<br>
400404
# to show only 2 decimals: "%{y:.2f}"
401-
# see more here: https://plotly.com/javascript/reference/pie/#pie-texttemplate
402-
403-
hovertemplate: >- # custom format for tooltip
404-
<b>%{customdata.name}</b><br><i>%{x}</i><br>
405-
%{y}%{customdata.unit_of_measurement}
406-
<extra></extra>
405+
# see more here: https://plotly.com/javascript/hover-text-and-formatting/
406+
# only x, y, customdata are available as %{} template
407+
408+
hovertemplate: | # custom format for hover text using entity properites name and unit_of_measurement
409+
$fn ({ getFromConfig }) =>
410+
` <b>${getFromConfig(".name")}</b><br>
411+
<i>%{x}</i><br>
412+
%{y}${getFromConfig(".unit_of_measurement")}
413+
<extra></extra>` # <extra></extra> removes text on the side of the tooltip (it otherwise defaults to the entity name)
407414
```
408415

409416
### Extend_to_present

0 commit comments

Comments
 (0)