Skip to content

on_click event not firing in annotations or updatemenus buttons #619

Description

@victor-vc

I'm trying to use the on_click handler as shown in the documentation examples, but the event never fires.

Notes:

  1. The mouse cursor does change to a hand when hovering over the element (annotation or button), so the card "knows" it's interactive.
  2. I added console.log and debugger inside the $ex function, but nothing appears in the DevTools console when clicking.
  3. $fn works perfectly fine in filters (I can see logs there), and on_legend_dblclick also works (see code below).

It seems specifically the on_click binding in layout objects is broken.

Environment:

  • Home Assistant
    • Core: 2026.2.3
    • Supervisor: 2026.02.3
    • Operating System: 17.1
    • Frontend: 20260128.6
  • Plotly Graph Card: 3.3.5
  • Browser: Windows Chrome 145.0.7632.117

My code:

type: custom:plotly-graph
title: Outside
hours_to_show: 24
refresh_interval: auto
entities:
  - entity: sensor.outside_temperature
    showlegend: true
    on_legend_dblclick: |-
      $fn () => (event_data) => {
        event = new Event( "hass-more-info")
        event.detail =  { entityId: 'sensor.outside_temperature' };
        document.querySelector('home-assistant').dispatchEvent(event);
        return false;
      }
    name: |
      $fn ({ hass }) => {
        const val = hass.states['sensor.outside_temperature']?.state || '...';
        return `<span style='color: #ff7f0e'>Temperature (<b>${val}°C</b>)</span>`;
      }
    line:
      color: ff7f0e
layout:
  annotations:
    - x: 1
      xref: paper
      "y": 1
      yref: paper
      showarrow: false
      text: 📊
      captureevents: true
      on_click: >-
        $ex () => {
        window.location="/history?entity_id=sensor.outside_temperature"; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions