Skip to content

Instantly share code, notes, and snippets.



Last active Aug 7, 2017
What would you like to do?
license: mit

Data Driven Parallel Coordinates to Chord Diagram

This example is interesting in a couple of ways.

First, it demonstrates the ability of dex.js to construct charts from data. This construction can include interactions as well.

Secondly, the interaction itself is interesting. By selecting the axis on the parallel coordinates chart the chord diagram is updated showing the relationships of the selected data.


The dex.create method takes a json specification and constructs the components it describes but does not render them.


The dex.render method takes a json specification, constructs and renders it. An array of constructed components is returned.


<!DOCTYPE html>
<meta charset="utf-8">
html, body {
height: 100%;
min-height: 100%;
width: 100%;
min-width: 100%;
#ParallelCoordinatesParent, #ChordParent {
display: inline-block;
height: 100%;
min-height: 100%;
width: 49%;
min-width: 49%;
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<link rel="stylesheet" href=""/>
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<div id="ParallelCoordinatesParent"></div>
<div id="ChordParent"></div>
d3.csv("presidents.csv", function(error, data) {
// Converting from d3's json-csv to dex-csv
var csv = new dex.csv(data);
// Create interactive components from json data.
var components = dex.render({
"components": [
"name": "PC",
"class": "dex.charts.d3.ParallelCoordinates",
"config": {
"parent": "#ParallelCoordinatesParent",
"margin": {"top": 40, "bottom": 30, "left": 50, "right": 50},
"csv": csv
"name": "Chord",
"class": "dex.charts.d3.Chord",
"config": {
"parent": "#ChordParent",
'margin': {'top': 10, 'bottom': 20, 'left': 10, 'right': 10},
"csv": csv
"interactions": [{
"sources": ["PC"],
"destinations": ["Chord"],
"event": "select",
"action": "setSelected"
President Party Home State
George Washington Independent Virginia
John Adams Federalist Massachusetts
Thomas Jefferson Dem/Rep Virginia
James Madison Dem/Rep Virginia
James Monroe Dem/Rep Virginia
John Quincy Adams Dem-Rep/Nat-Rep Massachusetts
Andrew Jackson Democratic Tennessee
Martin Van Buren Democratic New York
William Henry Harrison Whig Ohio
John Tyler Whig Virginia
James K. Polk Democratic Tennessee
Zachary Taylor Whig Louisiana
Millard Fillmore Whig New York
Franklin Pierce Democratic New Hampshire
James Buchanan Democratic Pennsylvania
Abraham Lincoln Rep/Nat Union Illinois
Andrew Johnson Dem/Nat Union Tennessee
Ulysses S. Grant Republican Ohio
Rutherford B. Hayes Republican Ohio
James A. Garfield Republican Ohio
Chester A. Arthur Republican New York
Grover Cleveland Democratic New York
Benjamin Harrison Republican Indiana
Grover Cleveland (2nd term) Democratic New York
William McKinley Republican Ohio
Theodore Roosevelt Republican New York
William Howard Taft Republican Ohio
Woodrow Wilson Democratic New Jersey
Warren G. Harding Republican Ohio
Calvin Coolidge Republican Massachusetts
Herbert Hoover Republican Iowa
Franklin D. Roosevelt Democratic New York
Harry S. Truman Democratic Missouri
Dwight D. Eisenhower Republican Texas
John F. Kennedy Democratic Massachusetts
Lyndon B. Johnson Democratic Texas
Richard Nixon Republican California
Gerald Ford Republican Michigan
Jimmy Carter Democratic Georgia
Ronald Reagan Republican California
George H. W. Bush Republican Texas
Bill Clinton Democratic Arkansas
George W. Bush Republican Texas
Barack Obama Democratic Illinois
Donald Trump Republican New York
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment