Search code examples
javascriptangulareventschartsplotly

How to add plotly-plot bar chart legend click event in angular


Below code is for my plotly-plot charts in angular template, I want add color picker on clicking the chart legend. How can I get a click event for chart legends

 <plotly-plot
    [divId]="graph.selectedGraph.name"
    [data]="graph.selectedGraph.data"
    [config]="graph.selectedGraph.config"
    [layout]="layout"
    (relayout)="draggedShape($event)"
    [ngClass]="{ 'single-data': graph.data && graph.data.length === 1 }"
    #plotlyPlot
  >
  </plotly-plot>

Solution

  • You can use the (legendClick) event handler for the plotly_legendclick events, the same way you use (relayout) for plotly_relayout events.