Skip to content
Snippets Groups Projects
Commit 1e39210d authored by Mathis Neumann's avatar Mathis Neumann
Browse files

allow and render live updates

parent 0eacea3d
No related branches found
No related tags found
No related merge requests found
...@@ -73,23 +73,24 @@ export default Ember.Component.extend({ ...@@ -73,23 +73,24 @@ export default Ember.Component.extend({
const nodeData = root.selectAll('.node') const nodeData = root.selectAll('.node')
.data(nodes, p => p.id); .data(nodes, p => p.id);
const node = nodeData.enter() const nodeEnter = nodeData.enter()
.append('g') .append('g');
.attr('class', d => d.children? 'node compound' : 'node leaf');
nodeData.exit() nodeData.exit()
.remove(); .remove();
const atoms = node.append('rect') nodeData.attr('class', d => d.children? 'node compound' : 'node leaf');
const atoms = nodeEnter.append('rect')
.attr('width', 10) .attr('width', 10)
.attr('height', 10) .attr('height', 10)
.attr('x', 0) .attr('x', 0)
.attr('y', 0); .attr('y', 0);
node.append('title') nodeEnter.append('title')
.text(d => d.id); .text(d => d.id);
node.append('text') nodeEnter.append('text')
.attr('x', (d) => d.children? 0 : 2.5) .attr('x', (d) => d.children? 0 : 2.5)
.attr('y', 5) .attr('y', 5)
.text((d) => _.get(d, 'labels.0.text', d.id)) .text((d) => _.get(d, 'labels.0.text', d.id))
...@@ -105,11 +106,13 @@ export default Ember.Component.extend({ ...@@ -105,11 +106,13 @@ export default Ember.Component.extend({
.attr('class', 'link') .attr('class', 'link')
.attr('d', 'M0 0'); .attr('d', 'M0 0');
linkData.exit() linkData.exit()
.remove(); .remove();
// apply edge routes // apply edge routes
link.transition().attr('d', (d) => { linkData.transition().attr('d', (d) => {
log('test');
let path = ''; let path = '';
path += 'M' + d.sourcePoint.x + ' ' + d.sourcePoint.y + ' '; path += 'M' + d.sourcePoint.x + ' ' + d.sourcePoint.y + ' ';
(d.bendPoints || []).forEach(bp => path += 'L' + bp.x + ' ' + bp.y + ' '); (d.bendPoints || []).forEach(bp => path += 'L' + bp.x + ' ' + bp.y + ' ');
...@@ -117,8 +120,8 @@ export default Ember.Component.extend({ ...@@ -117,8 +120,8 @@ export default Ember.Component.extend({
return path; return path;
}); });
// apply node positions // apply nodeEnter positions
node.transition() nodeData.transition()
.attr('transform', (d) => 'translate(' + (d.x || 0) + ' ' + (d.y || 0) + ')'); .attr('transform', (d) => 'translate(' + (d.x || 0) + ' ' + (d.y || 0) + ')');
atoms.transition() atoms.transition()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment