
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
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.
circleGraph.range([number])
Sets or gets the "range" in radians of a complete circle within which the nodes should be evenly distributed. Default is Math.PI * 2
(which represents the complete circle).
For example, calling circleGraph.range(Math.PI * 3/2)
on the demo will result in this:
WARNING: This must be called before
.nodes()
gets called.
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.
Security News
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.