Constructor
new Beadnet(options)
Create a new BeadNet chart.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Methods
_getChannelById(id) → {Channel|undefined}
Return the channel with the given id.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | the id of the node to find. |
- Source:
Returns:
- Type
- Channel | undefined
_getNodeById(id) → {Node|undefined}
Return the node with the given id.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | the id of the node to find. |
- Source:
Returns:
- Type
- Node | undefined
_getUniqueChannelId(channelInfos)
Creates an unique channel ID using the source and target node IDs and the balances.
Parameters:
Name | Type | Description |
---|---|---|
channelInfos |
* |
- Source:
_positionBeat(b) → {string}
Calculate and then translate a bead to a certain position.
Parameters:
Name | Type | Description |
---|---|---|
b |
* |
- Source:
Returns:
bead position.
- Type
- string
addChannel(channel)
Adds a new channel.
Parameters:
Name | Type | Description |
---|---|---|
channel |
Channel |
- Source:
addChannels(channels)
Adds an array of channels.
Parameters:
Name | Type | Description |
---|---|---|
channels |
* |
- Source:
addNode(node) → {Beadnet}
Adds a new node to the network.
Parameters:
Name | Type | Description |
---|---|---|
node |
Node |
- Source:
Returns:
- Type
- Beadnet
addNodes(nodes) → {Beadnet}
Adds multible new nodes to the network.
Parameters:
Name | Type | Description |
---|---|---|
nodes |
Array.<Node> |
- Source:
Returns:
- Type
- Beadnet
animateBead(bead, direction, delay)
Animates a bead movement.
Parameters:
Name | Type | Description |
---|---|---|
bead |
* | |
direction |
* | |
delay |
* |
- Source:
changeChannelSourceBalance(sourceId, targetId, amount) → {Beadnet}
Transfer a amount from the source node banlance to or from the channel.
Parameters:
Name | Type | Description |
---|---|---|
sourceId |
String | source node id |
targetId |
String | target node id |
amount |
Number | positive if moved from not to channel; negative if moved from channel to node. |
- Source:
Returns:
beadnet
- Type
- Beadnet
changeChannelTargetBalance(sourceId, targetId, amount) → {Beadnet}
Transfer a amount from the target node banlance to or from the channel.
Parameters:
Name | Type | Description |
---|---|---|
sourceId |
String | source node id |
targetId |
String | target node id |
amount |
Number | positive if moved from node to channel; negative if moved from channel to node. |
- Source:
Returns:
beadnet
- Type
- Beadnet
createBehaviors()
Creates the d3js behaviours for zoom and drag&drop.
- Source:
createRandomChannels(countopt, uniqueopt) → {Node}
Create new nodes with random names.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
count |
Number |
<optional> |
1 | how many nodes. |
unique |
Boolean |
<optional> |
true | should channels be unique? |
- Source:
Returns:
- Type
- Node
createRandomNodes(countopt) → {Node}
Create new nodes with random names.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
count |
Number |
<optional> |
1 | how many nodes. |
- Source:
Returns:
- Type
- Node
getChannelCount() → {Number}
Returns the number of channels.
- Source:
Returns:
number of channels
- Type
- Number
getChannels(sourceId, targetId) → {Array.<Channel>}
Returns all channels that exist between two nodes.
Parameters:
Name | Type | Description |
---|---|---|
sourceId |
String | |
targetId |
String |
- Source:
Returns:
channels
- Type
- Array.<Channel>
getRandomChannel()
Picks and returns a random channel from the list of existing channels.
- Source:
getRandomNode() → {Node}
Picks and returns a random node from the list of existing nodes.
- Source:
Returns:
- Type
- Node
highlightChannel(sourceId, targetId, state) → {Beadnet}
Mark a channel as "highlighted".
Parameters:
Name | Type | Description |
---|---|---|
sourceId |
String | |
targetId |
String | |
state |
Boolean | should the channel be highlighted [true]/false |
- Source:
Returns:
- Type
- Beadnet
moveBeads(sourceId, targetId, beadCount, callback) → {Beadnet}
Moves a certain amount of beads from source to target node. If a callback is provided, it is called after the animation
has stopped.
Parameters:
Name | Type | Description |
---|---|---|
sourceId |
* | |
targetId |
* | |
beadCount |
* | |
callback |
* |
- Source:
Returns:
beadnet
- Type
- Beadnet
nextStep()
Show the next step of the presentation. Only has an effect if the instance was initialized in presentation mode.
- Source:
onResize()
Handles a resize event of the window/container.
- Source:
removeChannel() → {Beadnet}
Remove channel with the given source and target ids.
- Source:
Returns:
beadnet
- Type
- Beadnet
removeNode(nodeId) → {Beadnet}
Removes a the node with the given id from the network.
Parameters:
Name | Type | Description |
---|---|---|
nodeId |
String |
- Source:
Returns:
- Type
- Beadnet
tickedBeads()
Handle bead animation.
- Source:
updateSimulationCenter()
Forces the simulation to restart at the center of the SVG area.
- Source:
updateSVGSize()
Updates the size of the SVG element to use the full size of it's container.
- Source: