score:1
Accepted answer
You called draw
method multiple times, so you have to treat it carefully.
Only newly added nodes are supposed to be added image
and circle
tags,
so you should change
mNode = svg.selectAll(".node")
.data(mNodesData)
.enter()
.append("g")
.attr("class", "node").
merge(mNode);
to
var newNodes = svg.selectAll(".node")
.data(mNodesData)
.enter()
.append("g")
.attr("class", "node");
mNode=newNodes.merge(mNode);
and change
var nodeCircle = mNode.append("circle")
to
var nodeCircle = newNodes.append("circle")
And image
related code are supposed to be changed in same manner.
Source: stackoverflow.com
Related Query
- d3.js - graph is broken after adding new nodes
- d3 / svg layering issue when adding new nodes after a time
- D3 force-directed graph adding new nodes causes x & y to be NaN
- d3 v4 adding new nodes to force directed graph
- Adding new nodes to Force-directed layout
- Adding and Removing Nodes in D3js Force Graph
- D3 updating graph with new elements create edges with the wrong nodes
- Adding child elements to specific nodes in a force-directed graph using d3js
- Maintaining relative ordering when adding nodes to a layered graph in Dagre
- Combine Nodes & Links in D3 Force Graph After CSV is Parsed to make one Array (Angular & D3.JS)
- Dynamically adding nodes to d3.js Force directed graph
- Adding new nodes to a clustered force layout
- Adding tooltips to line graph data points AFTER lines animate
- Adding foreignObjects to D3 force-directed graph nodes breaks events
- d3 force directed graph nodes stay at fixed position after filter
- D3.js - old links not getting deleted after adding a new node and trasitioning
- D3.js update graph when pushing new nodes
- Color descendant nodes and links broken after moving to d3 v5
- Tree not updating nodes position when adding a new sibling
- D3.JS bar graph column offset while adding new data
- maintaining the layering of elements after adding new elements
- Adding nodes group by group to a D3 force directed graph
- D3v4 graph class, trouble adding nodes
- Issues with adding a link via mouse click to two nodes in force directed graph
- Need assistance with adding text into nodes in codeflower graph via D3.js
- D3.js - adding text to nodes in force-directed graph
- Adding FontAwesome icons to a D3 graph
- Simple graph of nodes and links without using force layout
- d3js: make new parent data descend into child nodes
- Getting Screen Positions of D3 Nodes After Transform
More Query from same tag
- Can't get c3.js right click event arguments
- changing svg circles to image
- Unable to understand d3js zoom functionality
- Overlapping Axis Ticks with Margin
- nice() method for ticks in nvd3
- Circular Picture on D3JS
- What is wrong with this data visualization code?
- SVG vs Canvas for a "wind" chart
- Novice d3 stacked area graph
- Is there any possibility to cut to a shape an image that can be moved with d3 (jquery)
- Tooltip with Multi-Series Line Chart in Vega-Lite API
- Manipulating path element in HTML
- D3/Shiny Example Doesn't Display Bars
- Append conditionally without filtering
- How to set the zoom factor in D3.js v.4.x?
- Why is scale a function of pi in D3's Mercator projection?
- D3 force directed graph: nodes not staying at mouse position while dragging
- D3 d3.text request function bug
- d3; attaching multiple svg to div's
- How to find top 5 numbers in a data set and data associated with it?
- Not able to show min and max value on x-axis in d3 js
- Multiple line chart issue from json
- How to make a D3 Line Chart Responsive
- D3 hyperlinked nodes: URL pattern + {d.url}
- Exit and update nested nested elements in D3
- Styling tooltip in multi-line D3.js line chart
- d3 click handler not working on leaflet map layer
- Test mouseover and mouseout events in AngularJS directive
- d3 path - split into 2 new paths
- SVG added to DOM using javascript is not visible.