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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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.

            
              <head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="https://rawgit.com/monfera/plotly.js/sankey-micro-alignment/dist/plotly.min.js"></script>
</head>
<body>
<div id="graphDiv"></div>
</body>
</html>
            
          
!
            
              // Sankey core layout code Copyright Mike Bostock, 2015 (MIT)
// with a modification covered with a PR
//
// Add-on features:
//    - use of force for drag&drop without manual overlap fiddling
//       - multiple force ticks per frame for faster response
//       - starting/stopping force per graph layer (column)
//       - use of force for handling apparently non-circular shapes
//    - vertical layout (sorry, transition to be disabled later)
//    - option for multi-edge handling https://github.com/d3/d3-sankey/pull/19
//    - plotly tooltips and raising various plotly events
//    - plotly-style color contrast: text becomes white on darker backgrounds
//    - highlight all connecting links and nodes when hovering a node
// 
// Current limitations:
//    - positions aren't saved (layout lost on update)
//    - positions aren't specifiable yet (no attributes for this yet)
//    - cheesy horizontal/vertical switch
//    - screenshot fails for a couple of reasons
//
// PR: https://github.com/plotly/plotly.js/pull/1591

var d3 = Plotly.d3;

var mock = {
  data: [{"node": {"color": ["#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46", "#262C46"], "line": {"color": "black", "width": 0.5}, "thickness": 30, "pad": 10, "label": ["People from Iran", "People from Afghanistan", "People from Pakistan", "People from Iraq", "People from Bangladesh", "People from Myanmar", "People from Somalia", "People from Lebanon", "People from Myanmar (Stateless)", "People from Sri Lanka", "Stateless People", "People from Nepal", "Other People", "People from India", "Manus", "Nauru", "Total Asylum Seekers", "Still on Manus or Nauru", "Unknown", "Iran", "Iraq", "Cambodia", "Afghanistan", "Lebanon", "Sri Lanka", "Somalia"]}, "valueformat": ".0f", "domain": {"y": [0, 1], "x": [0, 1]}, "orientation": "h", "link": {"source": [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16], "target": [14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 14, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 16, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], "value": [548, 167, 135, 37, 105, 74, 106, 21, 74, 42, 53, 17, 48, 9, 46, 13, 27, 123, 41, 104, 19, 12, 18, 13, 13, 14, 1246, 633, 1215, 607, 34, 10, 4, 2, 4, 2, 1]}, "type": "sankey"}],
  layout: {"height": 772, "font": {"size": 10}, "marging": {"right": 0, "left": 0}, "title": "Refugee movement through Manus and Nauru, via <a href='http:\/\/www.bryanbrussee.com\/sankey.html'>Bryan Brussee<\/a>"}
};

Plotly.plot('graphDiv', mock.data, mock.layout); 
 
graphDiv.on('plotly_hover', function(e) {
    console.log('hover', e);
});

graphDiv.on('plotly_unhover', function(e) {
    console.log('unhover', e);
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console