Skip to content

Commit

Permalink
Correcting issue #5
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Desmaisons committed Jul 25, 2021
1 parent 73cd14c commit 11bcf4e
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions src/components/sunburst.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export default {
/**
* @private
*/
onData(data, { onlyRedraw = false, updateAngle = false } = {}) {
onData(data, { onlyRedraw = false } = {}) {
if (!data) {
this.vis.selectAll("g").remove();
Object.keys(this.graphNodes).forEach(k => (this.graphNodes[k] = null));
Expand All @@ -373,18 +373,17 @@ export default {
this.root = hierarchy(data)
.sum(d => d.size)
.sort((a, b) => b.value - a.value);
}
const needComputedNode = !onlyRedraw || updateAngle;
if (needComputedNode) {
const { minAngleDisplayed } = this;
this.nodes = partition()(this.root)
.descendants()
.filter(d => Math.abs(this.scaleX(d.x1 - d.x0)) > minAngleDisplayed);
this.nodes = partition()(this.root).descendants();
}
const { zoomedNode, hasCentralCircle, getCircle } = this;
const {
zoomedNode,
hasCentralCircle,
getCircle,
minAngleDisplayed,
scaleX
} = this;
this.scaleY.domain([hasCentralCircle ? zoomedNode.y1 : zoomedNode.y0, 1]);
const rootNode = this.nodes[0];
Expand Down Expand Up @@ -417,7 +416,13 @@ export default {
.append("g")
.style("opacity", 1);
const mergedGroups = newGroups.merge(groups).attr("class", arcClass);
const mergedGroups = newGroups
.merge(groups)
.attr("class", arcClass)
.attr(
"display",
d => (scaleX(d.x1) - scaleX(d.x0) > minAngleDisplayed ? null : "none")
);
if (this.showLabels && this.maxLabelText !== null) {
mergedGroups.attr("clip-path", d => `url(#clip-${d.depth})`);
Expand Down Expand Up @@ -460,7 +465,7 @@ export default {
groups.exit().remove();
if (!needComputedNode) {
if (onlyRedraw) {
return;
}
Expand Down Expand Up @@ -678,6 +683,7 @@ export default {
arcSunburst,
getTextAnchor,
hasCentralCircle,
minAngleDisplayed,
arcClass
} = this;
this.vis.selectAll("g").attr("class", arcClass);
Expand Down Expand Up @@ -725,6 +731,18 @@ export default {
.selectAll("path")
.attrTween("d", nd => () => arcSunburst(nd));
if (minAngleDisplayed > 0) {
transitionSelection
.selectAll("g")
.filter(d => descendants.includes(d))
.attrTween("display", d => () => {
const { scaleX } = this;
return scaleX(d.x1) - scaleX(d.x0) > minAngleDisplayed
? null
: "none";
});
}
const { getCircle } = this;
this.vis
.select("defs")
Expand Down Expand Up @@ -874,7 +892,7 @@ export default {
},
minAngleDisplayed() {
this.reDraw({ updateAngle: true });
this.reDraw();
},
centralCircleRelativeSize() {
Expand Down

0 comments on commit 11bcf4e

Please sign in to comment.