0

How to prevent hiding plotly chart bar on chart legend click in an angular application.

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

1 Answer 1

0

You need to disable the default Plotly behaviour by using event.preventDefault() or return false, so inside your launchColorPicker function.

  launchColorPicker(event: any) {
    // Your code ...

    if (event) {
      event.preventDefault ? event.preventDefault() : (event.returnValue = false);
    }
    return false;
  }
1
  • Its not working, Its hiding the chart bar
    – vijesh
    Commented May 8 at 10:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.