Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


    <script src=""></script>
  <script src="d3.legend.js"></script>
    <script src=""></script>
    <script src="index.js"></script>
    <link href="" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="index.css">
    <div id="content">
    Who's panelling at the Animal Rights National Conference?
    <svg id="network"></svg>


              body {
  font-family: 'Josefin Sans', cursive;

#content {
  position: absolute;
  width: 800px;
  padding: 25px;
  margin-left: auto;
  margin-right: auto;
  left: 0;
  right: 0;
  background-color: rgba(249, 249, 249, 0.863);
  border-left: 5px solid #000000;
  border-right: 5px solid #000000;

h1 {
  text-align: center;
  font-size: 42px;

#network {
  position: relative;
  width: 800px;
  height: 600px;
  padding: 15px;
  margin: 0 auto;

.tooltip {
  position: absolute;
  text-align: left;
  width: 120px;
  padding: 8px;
  margin-top: -20px;
  border:2px solid #000000;
  font: 12px sans-serif;
  background: #FFFFFF;
  pointer-events: none;

.edges line {
  stroke: #999;
  stroke-opacity: 0.4;

.nodes circle {
  stroke: #FFF;
  stroke-width: 2px;

.nodes {
  width: 100%;
  height: 100%;
  margin: 0 auto;

.edges {
  width: 100%;
  height: 100%;
  margin: 0 auto;



              //Set SVG height and width
var width = 960,
    height = 660,
    padding = 5,
    radius=function (d) {
        return * 150};

// Draw tooltips, to be used on mouseover and mouseout functions
var div ="body").append("div")	
    .attr("class", "tooltip")				
    .style("opacity", 0);
//Set force simulation for links and nodes

var force = d3.forceSimulation()
    //Create a force between nodes based on links
    .force("link", d3.forceLink().id(function (d) {
    //.force("forceY", d3.forceY().y(height/2).strength(0.2))
    //.force("forceX", d3.forceX().x(width/2).strength(0.1))
    //forceManyBody simulates attraction and repulsion between nodes based on edge weight
    .force("attract", d3.forceManyBody().distanceMax(height - 2).distanceMin(20).strength(50))
    .force("repel", d3.forceManyBody().distanceMax(width/2).distanceMin(20).strength(-80))
    //Sets center force to the middle of the visualization
    .force("center", d3.forceCenter(width / 2, height / 2));

//Parse node list and edge list for use as arrays
//Entire chart creation procedure nested inside .csv functions
d3.csv("", function (edges) {
    d3.csv("", function (nodes) {

            //Color scale variable
            var colorScale =  d3.scaleQuantize()
                .domain([d3.min(nodes, function(d){ 
                  return d.orgbudget}),d3.max(nodes, function(d){
                  return d.orgbudget})])

            //Set variable for drawing new edges
            //Edges referred to as "links" in d3 network graph documentation    
            var link"svg")
                .attr("class", "edges")
                .attr("width", width)
                .attr("height", height)
                .attr("stroke-width", function (d) {
                    return Math.sqrt(+d.weight) - 1

            //Set variable for drawing new nodes    
            var node"svg")
                .attr("class", "nodes")
                .attr("r", radius)
                .attr("fill", function(d){ return colorScale(+d.orgbudget)})
                .on("mousemove", function(d) {		
                        .style("opacity", .9)		
                    div	.html("<b>" + d.label + "</b><br/>" + d.organization + "</br> <b>Organization Budget</b>: $<i>" + d.orgbudget +"</i>")	
                        .style("left", (d3.event.pageX + 20) + "px")		
                        .style("top", (d3.event.pageY - 60) + "px");	
                .on("mouseout", function(d) {		
                        .style("opacity", 0);
         function dragstarted(d)
            d.fx = d.x;
            d.fy = d.y;
         function dragged(d)
            d.fx = d3.event.x;
            d.fy = d3.event.y;
         function dragended(d)
            d.fx = null;
            d.fy = null;

                .text(function (d) {
                    return d.label;

            //Initiate force simulation, set nodes to specified array
                //Adds nodes, assigns x/y positions and x/y velocity based on the forces declared in the variable "force"
                //.on(tick) increments the "tick" counter by 1,
                //Initiates the "ticked" function to position nodes and edges 
                .on("tick", ticked);

            //Declares the links to be used in the link force       
            //Set node and link positioning based on "tick" function
            //Basically waits for all elements to be processed, 
            //increments the tick timer by 1, then positions objects 
            function ticked() {
                    .attr("x1", function (d) {
                        return d.source.x;
                    .attr("y1", function (d) {
                        return d.source.y;
                    .attr("x2", function (d) {
                    .attr("y2", function (d) {

                    .attr("cx", function(d) { return d.x = Math.max(200, Math.min(width-200, d.x))
                    .attr("cy", function(d) { return d.y = Math.max(100, Math.min(height-100, d.y)) ;});