Skip to content

Instantly share code, notes, and snippets.

@puzzler10
puzzler10 / README.md
Last active March 18, 2017 22:39
squashed force directed graph

Uses a combination of the positioning forces forceX and forceCenter to create a "squashed" aesthetic.

If you're interested, here's the explanation behind the graph.

@puzzler10
puzzler10 / README.md
Last active March 18, 2017 22:40
drifting force directed graph

This force graph drifts while the simulation is running.

What happens is that every tick adds 1 to the x and y position of the centering force, so the graph slowly drifts off the screen.

Click here for the full explanation.

@puzzler10
puzzler10 / README.md
Last active March 18, 2017 22:44
Radially expanding force directed graph

This graph radially expands. Try dragging it around - nodes will stay where you put them but the rest will expand outwards.

This effect can be created in two steps:

  • Set the forceLink strength to 0. This removes the link force while maintaining the lines between nodes.
  • Set the charge to a small negative number.

Want to learn more about this example? Click here.

@puzzler10
puzzler10 / README.md
Last active March 18, 2017 22:39
node and link attributes

Here we specify different attributes in the data for links and nodes. We then set the colour of nodes and lines to depend on these attributes.

The characters are from the mesmerising web serial Twig. It's really worth a read!

Want to learn more about node and link attributes? Visit here.

@puzzler10
puzzler10 / README.md
Last active March 6, 2017 11:22
sticky nodes

Sticky nodes - they stay where they are dragged. Read more about it here

@puzzler10
puzzler10 / Readme.md
Last active March 6, 2017 11:02
dragable force directed graphs

Dragable force directed graph. Instructions on the dragging mechanism are here.

@puzzler10
puzzler10 / README.md
Last active February 16, 2021 21:41
Dragging Circles

Example of using version 4 of d3.js to drag circles around the screen. Want to learn this? Read this.

@puzzler10
puzzler10 / Readme.md
Last active February 25, 2017 08:11
d3-force: minimal working example

This is a basic force directed graph using version 4 of d3. Find the tutorial of how to make it here.

@puzzler10
puzzler10 / index.html
Created June 14, 2016 08:32
Grouped, Stacked, Scatter and Line
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: auto;
position: relative;
width: 960px;
}
@puzzler10
puzzler10 / README.md
Created June 9, 2016 11:27
Simple Stacked Bar Chart

This is a simple exploration of a stacked bar chart.

It can also be seen as a basic example of d3's stack layout.