Comments (6)
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.
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.
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.
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.
Understood; thanks for spending so much time looking into it. Adding a delay does seem like the best option.
from d3-tip.
No problem!
from d3-tip.
Related Issues (20)
- Linebreak HOT 1
- Grouped Label Name in Tooltip HOT 1
- Webpack imported Module is not a function HOT 2
- Do you have any examples of how to set this up with Angular 2+? HOT 4
- Suggestion: Add a .text method for plain text tooltips HOT 17
- can't detect that svg has moved HOT 2
- Tooltip with image flashes (in the wrong position) then disappears
- npm package out of date HOT 1
- TypeError: targetel.getScreenCTM is not a function HOT 12
- Positioning in Firefox HOT 3
- d3-tip does not work on tspan in Firefox HOT 7
- this parameter HOT 1
- Any plans to update the library to d3 v5 ? HOT 2
- Tooltips are cut of by the browser window HOT 3
- Usage with a bundler is not documented HOT 5
- Adjust name of JavaScript file in dist folder. HOT 4
- tip is not a function HOT 3
- d3-tip in Vue.js HOT 3
- Using `rootElement` causes errors, doesn't account for ancestor element offsets HOT 1
- Cannot read property 'x' of undefined. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-tip.