Git Product home page Git Product logo

Comments (7)

etpinard avatar etpinard commented on May 4, 2024 2

@prasadrajacse that myPlot.on statement must be placed after the first Plotly.plot call.

from plotly.js.

prasadrajacse avatar prasadrajacse commented on May 4, 2024 1

Hi @etpinard thanks for the response

Here is my code block..I am calling myPlot.on after Plotly.newPlot

  this.constructPlotData();
  this.plotHeading = this.donutInput.plotHeading;
  this.plotContainerId = this.donutInput.containerId;
  setTimeout( () => {
    Plotly.newPlot(this.plotContainerId, this.plotdata, this.ploylayout,{displayModeBar: false});
    let myPlot = document.getElementById(this.plotContainerId);
    myPlot.on('plotly_click', function(data){
      console.log(data.points[0].label);
    });
  },1);

from plotly.js.

Vestaxis avatar Vestaxis commented on May 4, 2024

See #21

from plotly.js.

napengam avatar napengam commented on May 4, 2024

thanks

from plotly.js.

prasadrajacse avatar prasadrajacse commented on May 4, 2024

I am trying to use it angular 2 project but it is returning the error
Property 'on' does not exist on type 'HTMLElement'.

let myPlot = document.getElementById('donutChartHigh');
myPlot.on('plotly_click', function(data){
console.log(data.points[0].label);
});

from plotly.js.

jeyasarathi avatar jeyasarathi commented on May 4, 2024

Think it is more of a compilation error. But your code will work. If you are concerned on the error. You can create a child class for ES6 HTMLElement class. Add the below code above in your component.

class CustomHTMLElement extends HTMLElement {
  constructor() {
    super();
  }
  on(event_type, cb) {
  }
}

And type cast in element selection

let myPlot = <CustomHTMLElement>document.getElementById(this.plotContainerId);

from plotly.js.

amansatija avatar amansatija commented on May 4, 2024

@jeyasarathi
thanks I can confirm that your solution works for angular

from plotly.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.