score:1
Accepted answer
You don't have to destroy the graph - simply put your fill method call after merge.
.merge(data)
.attr("fill", function (d) {
switch(d.group) {
case "use case":
return useCaseColor;
case "data service":
return dataServColor;
case "source":
return sourceColor;
}
})
merge allows you to work with both initial & enter selections, so you can update it correctly.
Source: stackoverflow.com
Related Query
- Modifying Node color in Force Layout based on Color Picker
- d3: Optionally add child elements based on node content in force layout
- Constraining d3 force layout graphs based on node degree
- D3 force directed layout - changing node color and its links color on button click
- Change color of node groups in a d3.js force node canvas layout
- Create nodes based on content BBox and get width of source node when adding links in force layout
- d3: Optionally add child elements based on node content in force layout - when filter is not the solution
- Fix Node Position in D3 Force Directed Layout
- d3.js: suggested node position in force layout
- Charge based on size - d3 force layout
- D3 force layout fix root node at the center
- D3 Force Layout Graph - Self linking node
- Space out nodes evenly around root node in D3 force layout
- Add text label to d3 node in Force layout
- Align Marker on node edges D3 Force Layout
- Recentering D3 force layout diagram on node click
- Inserting a line break in D3 force layout node labels
- How to display a text when mouseover a node in D3 force layout
- Center force directed layout after tick using root node (return to center)
- How to get the same node positions in d3's force layout graph
- modifying d3's force layout "annealling" schedule
- D3 Force Layout : How to force a group of node to stay in a given area
- d3js force layout dynamically adding image or circle for each node
- Creating force layout node labels in d3.js
- d3.js Node "jumps back" on fast drag in force layout
- How to pan to a node using d3's force layout
- How to layer D3 Force Simulation nodes based on element and not node order?
- Show div element on mouseover for node in D3 force layout
- Can't draw links by node property using D3 force layout
- Two labels on one node in a D3 force layout
More Query from same tag
- How to position the bubbles in bubble map statewise and in a row/column
- D3 axis not show
- How do you add a subtitle to multiple XY line chart in c3js.org?
- What's the best way to expose this data via JSON/Web Service?
- Example of D3 USA Map done in angular2
- How to get JSON key for d3.js chart
- Dragging and panning in d3 force layout
- D3 charts - Image in center of donut chart SVG
- How to load data using XHR in D3
- Apply d3 geo projection to an image
- How to animate multiple circles on a path in d3.js?
- D3js "bars.enter().attr" is not a function
- Insert text inside Circle in D3 chart
- How to set d3 stroke width
- Change arch width through transition with D3js
- Transitioning xAxis and data at the same time - D3.js
- d3.js csv loading - simple data conversion
- How to color D3-Geo path points in MultiPoints mode on canvas with individual colors
- How to change color of line in line chart using dimple.js?
- How to fasten the d3 zoomable sunburst transitions?
- How to vary the size of piechart in d3 with tree layout
- D3 V4 How to move dots according to zoom in linechart?
- How to show pandas data on web page with d3 style graphs?
- Zoomable network graph in AngularJS
- Creating a flag swimlane chart in D3.js
- Bar Chart inside Stacked Bar Chart
- d3.parseDate Error cannot read property 'forEach' of undefined
- Children with n>1 parents in d3.js tree layout
- d3js two svg, one external postitioning
- D3 changing X Axis on zoom