Comments (10)
This appends an extra tspan below each label with the size of the area
function annotateSizes() {
d3.select(this).select("text")
.append("tspan")
.text(function(d) { return "size " + d.size; })
.attr("x", function() { return d3.select(this.parentNode).attr("x"); })
.attr("dy", "1.5em")
.style("fill", "#666")
.style("font-size", "10px");
}
div.selectAll("g").transition("venn").each("end", annotateSizes).duration(0);
There might be an easier way of doing this, the 'transition' thing is a bit of a hack. Appending to the 'examples/venn_venn.html' file produces this output:
from venn.js.
It works until the circles start moving – after that, the tspan element gets removed. It happens on some timeout – I'll try to get more information.
I could always wait until the circles on done moving to render the text, but that's not preferable.
from venn.js.
I added an example with transitions for this: http://benfred.github.io/venn.js/examples/sublabels.html
This required making some minor changes to the library (a13bab7) so you'll need to get the latest version if you want to go this route. hope this helps =)
from venn.js.
Thanks! I've got the sublabels working exactly as desired now.
However, is there something in the latest commit that would've changed the way hover on intersection works? Even when not including the new sublabels feature, my old hover on intersection code is not working like it was before.
from venn.js.
It seems as if the svg path element on venn-intersection is not being created correctly – the text is added in the right place, however.
Take a look:
from venn.js.
I double checked and this issue was not present in 050d9ad
from venn.js.
I put some debugger statements in and found that venn.intersectionAreaPath
is not being called on the initial circle creation in a13bab7 but is in 050d9ad
from venn.js.
Figured it out – a simple change – https://github.com/benfred/venn.js/blob/master/src/diagram.js#L92 should read
update.select("path")
instead of update.select(".venn-circle path")
.
Was there a reason you made that change? The label rendering still works properly with path
only.
from venn.js.
sorry about that - didn't mean to check that in =( the indentation level changed, so I didn't spot it in the diff.
thanks for fixing!
from venn.js.
Sublabels work better when you "retext" the labels on update – they refresh if the sizes have changed. For example:
// move existing
layout.update
.select(".sublabel")
.text(function(d) {
if (d.size == 0.9) return "0 opinions";
else return (d.size) + ' opinions'; }) // 0.9 is the marker for 0
.style("font-size", "10px")
.attr("dy", "18")
.attr("x", function(d) {
return Math.floor(textCentres[d.sets].x);
})
.attr("y", function(d) {
return Math.floor(textCentres[d.sets].y);
});
from venn.js.
Related Issues (20)
- Default loss function should use log ratio, not subtraction
- Proper subset not displaying correctly
- Removing and readding a set quickly uninentionally hides the set
- Invisible triple intersection HOT 1
- Minimum circle size HOT 2
- Static size of circles HOT 2
- Label is displayed on other label
- Abandoned? Lots of good PRs out there. HOT 2
- could not find a declaration file for module 'venn.js' in React HOT 1
- Dependent d3 version5 for venn.js HOT 2
- Parsing a heading with each set of data
- Compatibility with d3-selection HOT 1
- url question about snowpack HOT 3
- could you publish the npm for the latest git code? HOT 3
- Uncaught initial bisect points must have opposite signs HOT 1
- How to fix circle same position on every refresh time in venn.js
- Custom circle colors HOT 1
- jsnext:main es6 problem HOT 1
- The calculation accuracy of function circleCircleIntersection problem
- Is there a way to programmatically get a list of intersections not shown. HOT 4
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 venn.js.