Coder Social home page Coder Social logo

Comments (3)

vasturiano avatar vasturiano commented on September 23, 2024

@somu2324 you cannot directly use a div or any type of DOM objects as nodes. They need to be created as Canvas drawing instructions using nodeCanvasObject(...). This is in part for performance reasons so that the browser doesn't get overloaded with two many nodes in the document.

However, you could try converting your DOM elements to canvas images, so that you can draw them that way, using something like html2canvas.

from force-graph.

somu2324 avatar somu2324 commented on September 23, 2024

Thanks @vasturiano.
one more thing. Do we have any callback method through which I can capture x and y position of mouse respect to node.
something link onNodeMouseMove(event) which may give event.x and event.y with respect to node center position.

from force-graph.

vasturiano avatar vasturiano commented on September 23, 2024

@somu2324 you can derive that information using various sources:

  • Attaching mouseMove events to your DOM element will give you mouse movement coordinates
  • Each of your node objects will have { x, y } coordinates indicating their current position on the canvas
  • By calling the getters .centerAt() and .zoom() you can extract the current pan/zoom settings of the canvas, if the user has interacted with it.

from force-graph.

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.