d3+venn实现带提示交互效果的韦恩图图表代码

代码语言:html

所属分类:图表

代码描述:d3+venn实现带提示交互效果的韦恩图图表代码

代码标签: d3 venn 提示 交互 韦恩图 图表

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
  
<style>
body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.4);
}

#tooltell {
  display: block;
  width: 50%;
  height: 100%;
  font-size: 16px;
  color: #111111;
}

.venntooltip {
  position: absolute;
  text-align: center;
  width: 60px;
  height: 60px;
  background: #ddd;
  color: #000;
  padding: 2px;
  border: 0px;
  border-radius: 8px;
  opacity: 0;
  top: 0;
  left: 0;
}

svg path {
  /*     stroke: rgba(33,33,33,0.6); */
  /*     stroke-width: 3px; */
}

svg text {
  fill: white;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
}

[data-venn-sets="0_1"] text {
  fill: black;
}

/* [data-venn-sets="0"]   { fill: #125FE3; }
[data-venn-sets="1"]   { fill: #FD4DB0; }
[data-venn-sets="2"]   { fill: #C94402; }
[data-venn-sets="0_1"] { fill: #FCE917; }
[data-venn-sets="0_2"] { fill: #2C4A68; }
[data-venn-sets="1_2"] { fill: #9244A6; }
[data-venn-sets="0_1_2"] { fill: #44A691; } */
[data-venn-sets="2"] {
  fill: #c94402;
}

[data-venn-sets="1"] {
  fill: #fd4db0;
}

[data-venn-sets="0"] {
  fill: #125fe3;
}

[data-venn-sets="0_1"] {
  fill: #fce917;
}

[data-venn-sets="0_2"] {
  fill: #9244a6;
}

[data-venn-sets="1_2"] {
  fill: #2c4a68;
}

[data-venn-sets="0_1_2"] {
  fill: #44a691;
}

svg {
  mix-blend-mode: difference;
}

/* svg:hover g:not(:hover) path
 { opacity: .5;
    -webkit-filter: grayscale(0%); 
    filter: grayscale(0%);
    filter: blur(50);
}
svg:hover g:not(:hover) text
 { opacity: .3; } */
g#venngroup:hover g:not(:hover) path {
  opacity: 0.5;
  z-index: 9999;
}

g#venngroup:hover g:not(:hover) text {
  opacity: 0.5;
}
</style>

  
  
  
</head>

<body>
    <div id="venn"></div>
  <div id="tooltell">&nbsp;</div>



<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/d3.v5.js"></script>

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/venn.js"></script>
  
      <script >
var sets = [
{ "sets": [2], "label": "People", "size": 100, "data": "This is how we do it" },
{ "sets": [0], "label": "Technology", "size": 100, "data": "This is how we do it" },
{ "sets": [1], "label": "Business", "size": 100, "data": "This is how we do it" },
{ "sets": [0, 1], "label": "Business Process Engineering", "size": 20, "data": "This is how we do it" },
{ "sets": [0, 2], "label": "User Experience Design", "size": 20, "data": "This is how we do it" },
{ "sets": [1, 2], "label": "Customer Experience Design", "size": 20, "data": "This is how we do it" },
{ "sets": [0, 1, 2], "label": "True Innovation", "size": 40, "data": "This is how we do it" }];

var svgContainer = d3.select("#venn").append("svg").
attr("width", 500).
attr("height", 500);

var venngroup = svgContainer.append("g").
attr(.........完整代码请登录后点击上方下载按钮下载查看

网友评论0