Skip to content

Commit

Permalink
feat(treemap): fix TreeMapD3 nodes exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Benitte committed May 13, 2016
1 parent 3b61508 commit 9e02da4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/charts/treemap/TreeMapD3.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ class TreeMapD3 extends Component {

const nodes = wrapper.datum(root).selectAll('.nivo_treemap_node').data(treemap.nodes);

const newNodes = nodes.enter().append('div')
nodes.enter().append('div')
.classed('nivo_treemap_node', true)
.classed('_is-parent', d => (d.children && d.children.length > 0))
.classed('_is-child', d => (d.parent !== undefined && (!d.children || d.children.length === 0)))
.style('z-index', 10)
.each(function (d) {
if (d.depth > 1 ) {
d.color = d3.rgb(d.parent.color).brighter(.2);
Expand Down Expand Up @@ -139,6 +140,17 @@ class TreeMapD3 extends Component {
;
})
;

nodes.exit()
.style('z-index', 5)
.transition()
.duration(transitionDuration)
.ease(transitionEasing)
.style('width', '0px')
.style('height', '0px')
.style('opacity', 0)
.remove()
;
}

shouldComponentUpdate(nextProps) {
Expand Down

0 comments on commit 9e02da4

Please sign in to comment.