d3-layout-circle-graph
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -32,3 +32,3 @@ { | ||
}, | ||
"version": "1.0.0" | ||
"version": "1.1.0" | ||
} |
@@ -12,2 +12,3 @@ (function(d3) { | ||
var nodeMap; | ||
var range = Math.PI * 2; | ||
var nodeKeyAccessor = function(n) { | ||
@@ -63,6 +64,14 @@ return n.name; | ||
range: function(r) { | ||
if (typeof r === 'number') { | ||
range = r; | ||
return layout; | ||
} | ||
return range; | ||
}, | ||
nodes: function (nodes) { | ||
nodeMap = {}; | ||
var numNodes = nodes.length; | ||
var radianSeparation = (2 * Math.PI) / numNodes; | ||
var radianSeparation = range / numNodes; | ||
var halfSeparation = radianSeparation / 2; | ||
@@ -113,2 +122,18 @@ nodes.forEach(function(n, i) { | ||
var to = nodeMap[ edgeTargetKeyAccessor(e) ]; | ||
if (!from) { | ||
console.error('d3.layout.circleGraph: Could not find source from given edge.', | ||
' nodeMap: ', nodeMap, | ||
' edge: ', e, | ||
' edgeSourceKeyAccessor: ', edgeSourceKeyAccessor.toString() | ||
); | ||
throw new Error('d3.layout.circleGraph: Could not find source from given edge.'); | ||
} | ||
if (!to) { | ||
console.error('d3.layout.circleGraph: Could not find target from given edge.', | ||
' nodeMap: ', nodeMap, | ||
' edge: ', e, | ||
' edgeTargetKeyAccessor: ', edgeTargetKeyAccessor.toString() | ||
); | ||
throw new Error('d3.layout.circleGraph: Could not find target from given edge.'); | ||
} | ||
if (from !== to) { | ||
@@ -115,0 +140,0 @@ coords.push( |
{ | ||
"name": "d3-layout-circle-graph", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A d3 layout generator for visualizing a graph using a circle of nodes and chords connecting them", | ||
@@ -5,0 +5,0 @@ "main": "circleGraph.js", |
@@ -121,1 +121,11 @@ d3.layout.circleGraph | ||
### `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: | ||
<img src="demo-with-range.png" width="400" alt="screenshot of demo with range()"> | ||
> **WARNING:** This must be called _before_ `.nodes()` gets called. |
Sorry, the diff of this file is not supported yet
204692
8
182
130