Được TopGit lập chỉ mục từ metadata GitHub: benfred/venn.js có 1.1k sao, viết chủ yếu bằng JavaScript. Area proportional Venn and Euler diagrams in JavaScript
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
A javascript library for laying out area proportional venn and euler diagrams.
Details of how this library works can be found on the blog
post
I wrote about this. A follow up post discusses testing strategy and
algorithmic improvements.
Installing
If you use NPM, npm install venn.js. Otherwise, download the latest release.
Usage
This library depends on d3.js to display the venn
diagrams.
Simple layout
To lay out a simple diagram, just define the sets and their sizes along with the sizes
of all the set intersections.
The VennDiagram object will calculate a layout that is proportional to the
input sizes, and display it in the appropriate selection when called:
The style of the Venn Diagram can be customized by using D3 after the diagram
has been drawn. For instance to draw a Venn Diagram with white text and a darker fill:
View this example, along with other possible styles
Dynamic layout
To have a layout that reacts to a change in input, all that you need to do is
update the dataset and call the chart again:
// draw the initial diagram
var chart = venn.VennDiagram()
d3.select("#venn").datum(getSetIntersections()).call(chart);
// redraw the diagram on any change in input
d3.selectAll("input").on("change", function() {
d3.select("#venn").datum(getSetIntersections()).call(chart);
});
View this example
Making the diagram interactive
Making the diagram interactive is basically the same idea as changing the style: just add event listeners to the elements in the venn diagram. To change the text size and circle colours on mouseover:
Another common case is adding a tooltip when hovering over the elements in the diagram. The only
tricky thing here is maintaining the correct Z-order so that the smallest intersection areas
are on top, while still making the area that is being hovered over appear on top of the others:
// draw venn diagram
var div = d3.select("#venn")
div.datum(sets).call(venn.VennDiagram());
// add a tooltip
var tooltip = d3.select("body").append("div")
.attr("class", "venntooltip");
// add listeners to all the groups to display tooltip on mouseover
div.selectAll("g")
.on("mouseover", function(d, i) {
// sort all the areas relative to the current item
venn.sortAreas(div, d);
// Display a tooltip with the current size
tooltip.transition().duration(400).style("opacity", .9);
tooltip.text(d.size + " users");
// highlight the current path
var selection = d3.select(this).transition("tooltip").duration(400);
selection.select("path")
.style("stroke-width", 3)
.style("fill-opacity", d.sets.length == 1 ? .4 : .1)
.style("stroke-opacity", 1);
})
.on("mousemove", function() {
tooltip.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
.on("mouseout", function(d, i) {
tooltip.transition().duration(400).style("opacity", 0);
var selection = d3.select(this).transition("tooltip").duration(400);
selection.select("path")
.style("stroke-width", 0)
.style("fill-opacity", d.sets.length == 1 ? .25 : .0)
.style("stroke-opacity", 0);
});
GitHub topics của benfred/venn.js: "d3", "euler-diagram", "javascript", "venn-diagram". TopGit xếp repo vào nhóm Frontend.
benfred/venn.js có phải mã nguồn mở không?
Có — benfred/venn.js phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/benfred/venn.js.
benfred/venn.js có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho benfred/venn.js. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
benfred/venn.js còn đang phát triển không?
Commit gần nhất trên benfred/venn.js là 5.6 năm trước (theo timestamp GitHub). Repo có 222 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
benfred/venn.js dùng license gì?
benfred/venn.js phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
Đọc thêm về benfred/venn.js ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/benfred/venn.js là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
venn.js có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về venn.js.