You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+49-1Lines changed: 49 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -696,7 +696,55 @@ entities:
696
696
- map_y: y + vars.temp1.ys[i]
697
697
```
698
698
699
-
### Universal functions
699
+
### Entity click handlers
700
+
701
+
When the legend is clicked (or doubleclicked), the trace will be hidden (or showed alone) by default. This behaviour is controlled by [layout-legend-itemclick](https://plotly.com/javascript/reference/layout/#layout-legend-itemclick).
702
+
On top of that, a `$fn` function can be used to add custom behaviour.
703
+
If a handler returns false, the default behaviour trace toggle behaviour will be disabled, but this will also inhibit the `on_legend_dblclick ` handler. Disable the default behaviour via layout-legend-itemclick instead if you want to use both click and dblclick handlers.
Alternatively, clicking on points of the trace itself.
719
+
720
+
```yaml
721
+
type: custom:plotly-graph
722
+
entities:
723
+
- entity: sensor.temperature1
724
+
on_click: |-
725
+
$fn () => (event_data) => {
726
+
...
727
+
// WARNING: this doesn't work and I don't understand why. Help welcome
728
+
}
729
+
```
730
+
731
+
There is also a double click plot handler, it works on the whole plotting area (not points of an entity). Beware that double click also autoscales the plot.
732
+
733
+
```yaml
734
+
type: custom:plotly-graph
735
+
entities:
736
+
- entity: sensor.temperature1
737
+
on_dblclick: |-
738
+
$fn ({ hass }) => () => {
739
+
hass.callService('light', 'turn_on', {
740
+
entity_id: 'light.portique_lumiere'
741
+
})
742
+
}
743
+
```
744
+
745
+
See more in plotly's [official docs](https://plotly.com/javascript/plotlyjs-events)
746
+
747
+
## Universal functions
700
748
701
749
Javascript functions allowed everywhere in the yaml. Evaluation is top to bottom and shallow to deep (depth first traversal).
0 commit comments