Giter Club home page Giter Club logo

Comments (6)

caged avatar caged commented on May 17, 2024

Wow, that's an order of magnitude slower. Quickly looking at your code, it looks like you're initializing a new instance every time you mouseover a node here and in similar areas. Try moving the invocation to the parent SVG element. You only need to call tip.show and tip.hide in the mouseover and mouseout events.

from d3-tip.

caged avatar caged commented on May 17, 2024

a5b1216 should also help. It performed pretty well with 5k nodes and was just acceptable at around 10k. I haven't really dug into performance tuning yet, but I have a few ideas that I think could speed things up:

  • Only perform matrix transforms on the direction you're interested in.
  • Remove expensive operations from tip.show.
  • Possibly use direct DOM APIs in tip.show instead of d3.

from d3-tip.

kbroman avatar kbroman commented on May 17, 2024

That doesn't seem to be the problem. svg.call(tip) happens just once for each of the four types of tips I've made, and tip.show and tip.hide are just in the mouseover/mouseout events.

The line you pointed to is in the original (faster) version of the script, using the old version of d3-tip. Here's the corresponding line in the revised version.

I initialize at lines 300-303

from d3-tip.

caged avatar caged commented on May 17, 2024

You're right, I was looking at the wrong file. I just did some performance tuning. Optimizing this loop cut the time in half, but I don't think it's going to be as fast as the original version because the original version was inherently broken for all but the most simple cases.

What's happening here is a bunch of mouseover events are being triggered, one right after the other, causing the operations to run on nodes that are likely not the node the user's mouse stops on. One option is to delay tip.show so it doesn't get called every time the user moves their mouse.

Unfortunately, I wasn't able to get your example running locally. Here's the updated version: https://raw.github.com/Caged/d3-tip/performance-tuning/src/d3.tip.js

from d3-tip.

kbroman avatar kbroman commented on May 17, 2024

Understood; thanks for spending so much time looking into it. Adding a delay does seem like the best option.

from d3-tip.

caged avatar caged commented on May 17, 2024

No problem!

from d3-tip.

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.