score:1
Accepted answer
I'd try something like
d3.selectAll(".link").attr("class", function(d) {
var c = "link";
if (d.source.visible && d.target.visible) { // or however you check the nodes?
c += " visible";
} else {
c += " hidden";
}
return c;
});
For your scenario you might use if (selectedNodes.indexOf(d.source)...
Source: stackoverflow.com
Related Query
- How do I give certain edges a class?
- How to give a class for all descendants of a tree node
- How can I retrieve the data-index of a class that contains a certain text?
- How do I select only nodes with a certain CSS class ? D3/JS
- How to use D3 selectAll with multiple class names
- How to put labels on the edges in the Dendrogram example?
- d3js: how to toggle css class after clicking on anelement
- How can I toggle the class of all elements in a selection?
- How to add label to edges in d3 graph
- d3.js: How to convert edges from lines to curved paths in a network visualization by drawing a quadratic Bezier curve?
- D3 Selecting all elements having a certain class or combination of classes
- how to give href to d3js text element
- How can I create a doughnut chart with rounded edges only on one end of each segment?
- D3 How to append needle at a certain point on a curve
- How to make a scatterplot based upon certain criteria using d3.js
- In sequences sunburst, how to give a child the same color of parent?
- How can I change style class & content of text for ancestors in this d3.js tree?
- How do I find neighboring nodes & edges of all selected nodes ? D3
- D3 select sibling, give it a class
- How to unselect a class when clicking on another class with javascript
- When creating an HTML table with D3, use certain data for a row class rather than cell
- How to select certain time period in d3 js?
- How to give padding on top/bottom/left/right to text that is contained inside a rect
- Unable to select primitives with certain class in d3js
- How to Place labels and give color range by number
- How to approach filtering nodes and edges rendered via d3.js according to user preference?
- Calculate how many std deviations the values of certain keys are from the mean
- how to avoid clickable of certain nodes of tree layout in d3 js
- How to select all elements with a class that contains a str?
- How do i give ellipsis in axis labels in d3 v4?
More Query from same tag
- Recovering x-axis value on click - NVD3 LineChart
- Add space between x-axis and line with time scale
- Updating d3 line graph shows incorrect data, perhaps due to path transitions
- How do I access the array sum here?
- End arrow is missing while dragging node in dagre-d3
- nvD3 Lineplusbar chart tool tip shows incorrect date (12/31/1969)
- d3 - mock the labelling of the x axis
- How to convert D3 time scale from V3 to V4?
- Image onLoad event is not triggered using Chrome on iOS
- d3 div doesn't change size on attribute changes
- D3.js Scale Tick Marks
- D3 matrix of circles iterating over colors
- Changing text attribute based upon event handler in d3.js
- CSS Values in a D3 Transition box shadow
- Does anyone know of a Javascript .csv file reader that will create an associative array?
- Cannot use attr with an object in D3 v4
- How to rotate d3 geo svg map
- on which parameters depend requestAnimationFrame? -- slowness
- d3 microlibraries not working
- d3 Grouping data on multiple values in combination with key value pair
- Disable clearing of D3.js brush
- Creating Pie Chart Dynamically with nvd3 and AngualrJs
- rCharts nvd3 library force ticks
- d3.max(...) in Typescript returns a string
- How to get the data from given array of objects in d3.js
- Multiple Classes in SVG
- Consume nested data in d3
- Why are both of these lines coming up the same color?
- How show jsPDF data on image
- How to properly add padding to the plot area in a D3 line chart?