JSFiddle - React, Tailwind, and code Playground
by ninachroscicka
HTML
<script src="https://rawgit.com/musically-ut/d3-circle-text/master/circle-text/circle-text.js"></script>
CSS
text {
font-size: 11px;
}
text.parent {
fill: #1f77b4;
}
text {
font: 10px sans-serif;
}
text:hover {
font-weight: bold;
stroke: #000;
stroke-width: 0.5px;
text-decoration: underline;
}
circle {
fill: #ccc;
stroke: #999;
pointer-events: all;
}
circle.parent {
fill: #fff;
fill-opacity: .1;
stroke: steelblue;
}
circle.parent:hover {
stroke: #ff7f0e;
stroke-width: .5px;
}
circle.child {
pointer-events: none;
}
/*Node hover*/
/*.node {
cursor: pointer;
}
.node:hover {
stroke: #000;
stroke-width: 1.5px;
}
.node--leaf {
fill: white;
}
*/
/*Circle text*/
.label {
font: 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
text-anchor: middle;
text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff, 0 -1px 0 #fff;
}
.label,
.node--root,
.node--leaf {
pointer-events: none;
}
.arc-path {
visibility: hidden;
}
JavaScript
var data = [
//Country,Organisation,entityid
{"Country":"segment 0","Organisation":"π"},
{"Country":"segment 2","Organisation":"π"},
{"Country":"segment 3","Organisation":"β€"},
{"Country":"segment 3","Organisation":"π"},
{"Country":"segment 2","Organisation":"π€"},
{"Country":"segment 1","Organisation":"π"},
{"Country":"segment 1","Organisation":"π"},
{"Country":"segment 3","Organisation":"π"},
{"Country":"segment 3","Organisation":"πͺ"},
{"Country":"segment 2","Organisation":"π"},
{"Country":"segment 3","Organisation":"π"},
{"Country":"segment 0","Organisation":"π"},
{"Country":"segment 0","Organisation":"βΊ"},
{"Country":"segment 2","Organisation":"π"},
{"Country":"segment 3","Organisation":"π"},
{"Country":"segment 2","Organisation":"π"},
{"Country":"segment 3","Organisation":"π€"},
{"Country":"segment 3","Organisation":"π"},
{"Country":"segment 0","Organisation":"π"},
{"Country":"segment 1","Organisation":"π"},
{"Country":"segment 0","Organisation":"π"},
{"Country":"segment 3","Organisation":"π«"}
]
var w = 860,
//h = 800,
r = 600,
x = d3.scale.linear().range([0, r]),
y = d3.scale.linear().range([0, r]),
node,
root,
format = d3.format(",d");
var focus = root,
view;
var circleText = d3.circleText()
.radius(function(d) {
return d.r - 5;
})
.value(function(d) {
return d.key; //Get lables
})
.method('align')
.spacing('exact')
.fontSize('100%');
//Declare the D3 layout type and set accessor functions
var pack = d3.layout.pack()
.size([r, r])
.children(function(d) {
return d.values; // accessor for children
})
.value(function(d) {
return d.values; // accessor for values
});
//Declare SVG attributes
var svg =...