Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
d3-layout-circle-graph
Advanced tools
A d3 layout generator for visualizing a graph using a circle of nodes and chords connecting them
A d3 layout generator for visualizing a graph using a circle of nodes and chords connecting them. Kind of like this block by sjengle.
bower install d3-layout-circle-graph
The demo that the above screenshot is taken from is located in demo.html
.
First, include circleGraph.js
in your project, either manually or with bower.
var myRadius = 100;
var myNodes = [
{ name: 'node1' },
{ name: 'node2' },
{ name: 'node3' }
];
var myEdges = [
{ source: 'node1', target: 'node2' },
{ source: 'node1', target: 'node3' }
];
var layout = d3.layout.circleGraph()
.radius(myRadius)
.tension(0.3)
.nodes(myNodes)
.edges(myEdges);
The node objects will be endowed with x
, y
, radians
, radianRange
, and degrees
properties. These can be used to visualize the graph as a circle. Note that 0° is assumed to be 12 o'clock, and increases going clockwise.
node.x
, node.y
The x
and y
coordinates for the center of the node.
node.radians
, node.degrees
The radians and degrees around the circle that the node resides.
node.radianRange
An array of two radian values that give the "range" of a particular node (good for visualizing bands, etc).
The edge objects will be endowed with a coords
property, which is an array of three coordinates: the source node point, the center of the circle (as a control point), and the target node point.
d3.layout.circleGraph()
Creates the layout object.
circleGraph.radius([Number])
Sets the radius of the circle.
circleGraph.line
Line function that can be used for drawing chords.
circleGraph.tension([Number])
Sets the tension of the bundle
line function that is available at circleGraph.line
. Should be a number between 0 and 1.
circleGraph.nodes([nodes])
Runs the layout on the provided nodes, adding the x
, y
, radians
and degrees
properties. By default, assumes that there is an identifying property called name
on each node. To change this behavior, use the circleGraph.key
function.
circleGraph.edges([edges])
Runs the layout on the provided edges, adding a coords
array to each edge. By default, this assumes that there are two properties on each edge object: a source
property and a target
property. This can be changed with the circleGraph.edgeSource
and circleGraph.edgeTarget
methods, respectively.
circleGraph.key([fn])
Sets the accessor function used to identify a node. By default, this function is:
function key(node) {
return node.name;
}
circleGraph.edgeSource([fn])
Sets the accessor function used to find the source node's identity from an edge object. By default, this function is:
function edgeSourceAccessor(edge) {
return edge.source;
}
circleGraph.edgeTarget([fn])
Same as edgeSource
, but for the target. Default is:
function edgeTargetAccessor(edge) {
return edge.target;
}
circleGraph.nodeMap()
Returns an object that maps identities to nodes. Sometimes useful in client code.
FAQs
A d3 layout generator for visualizing a graph using a circle of nodes and chords connecting them
The npm package d3-layout-circle-graph receives a total of 1 weekly downloads. As such, d3-layout-circle-graph popularity was classified as not popular.
We found that d3-layout-circle-graph demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.