SlideShare a Scribd company logo
d3sparql.js 
JavaScript library for visualization of SPARQL results 
Toshiaki Katayama <ktym@dbcls.jp> 
http://jp.linkedin.com/in/toshiakikatayama 
Database Center for Life Science (DBCLS), 
Research Organization of Information and Systems (ROIS), Japan 
2014/12/10 @ SWAT4LS, Berlin, Germany
D3.js : Data-Driven Document
SPARQL 1.1 Query Results JSON Format 
• Accept: application/sparql-results+json 
d3sparql.query 
= 
function(endpoint, 
sparql, 
callback) 
{ 
var 
url 
= 
endpoint 
+ 
"?query=" 
+ 
encodeURIComponent(sparql) 
var 
mime 
= 
"application/sparql-­‐results+json" 
d3.xhr(url, 
mime, 
function(request) 
{ 
var 
json 
= 
request.responseText 
callback(JSON.parse(json)) 
}) 
} 
D3.js 
→ 
AJAX 
→ 
SPARQL 
→ 
JSON 
→ 
D3.js
D3SPARQL 
Demo site: 
http://biohackathon.org/d3sparql
Visualization of trees, graphs, ...
Transformation of trees 
• Query Result JSON 
{ 
"head": 
{ 
"link": 
[], 
"vars": 
["root_name", 
"parent_name", 
"child_name"] 
}, 
"results": 
{ 
"distinct": 
false, 
"ordered": 
true, 
"bindings": 
[ 
{ 
"root_name": 
{ 
"type": 
"literal", 
"value": 
"root" 
}, 
"parent_name": 
{ 
"type": 
"literal", 
"value": 
"root" 
} 
, 
"child_name": 
{ 
"type": 
"literal", 
"value": 
"child1" 
}}, 
{ 
"root_name": 
{ 
"type": 
"literal", 
"value": 
"root" 
}, 
"parent_name": 
{ 
"type": 
"literal", 
"value": 
"child1" 
}, 
"child_name": 
{ 
"type": 
"literal", 
"value": 
"grand 
child1" 
}}, 
{ 
"root_name": 
{ 
"type": 
"literal", 
"value": 
"root" 
}, 
"parent_name": 
{ 
"type": 
"literal", 
"value": 
"child1" 
}, 
"child_name": 
{ 
"type": 
"literal", 
"value": 
"grand 
child2" 
}}, 
// 
list 
of 
parent-­‐child 
node 
pairs 
... 
] 
}
Transformation of trees 
• D3 data structure 
{ 
"name": 
"root", 
"size": 
1024, 
"children": 
[ 
{ 
"name": 
"child1", 
"size": 
2, 
"children": 
[ 
{ 
"name": 
"grand 
child1", 
"size": 
1 
}, 
{ 
"name": 
"grand 
child2", 
"size": 
1 
} 
], 
}, 
// 
list 
of 
children 
nodes 
... 
] 
}
Transformation of graphs 
• Query Result JSON 
{ 
"head": 
{ 
"link": 
[], 
"vars": 
["peer1", 
"name1", 
"peer2", 
"name2"] 
}, 
"results": 
{ 
"distinct": 
false, 
"ordered": 
true, 
"bindings": 
[ 
{ 
"peer1": 
{ 
"type": 
"literal", 
"value": 
"node0" 
}, 
"name1": 
{ 
"type": 
"literal", 
"value": 
"node0 
label" 
}, 
"peer2": 
{ 
"type": 
"literal", 
"value": 
"node1" 
}, 
"name2": 
{ 
"type": 
"literal", 
"value": 
"node1 
label" 
} 
}, 
{ 
"peer1": 
{ 
"type": 
"literal", 
"value": 
"node2" 
}, 
"name1": 
{ 
"type": 
"literal", 
"value": 
"node2 
label" 
} 
"peer2": 
{ 
"type": 
"literal", 
"value": 
"node3" 
}, 
"name2": 
{ 
"type": 
"literal", 
"value": 
"node3 
label" 
} 
}, 
{ 
"peer1": 
{ 
"type": 
"literal", 
"value": 
"node1" 
}, 
"name1": 
{ 
"type": 
"literal", 
"value": 
"node1 
label" 
} 
"peer2": 
{ 
"type": 
"literal", 
"value": 
"node3" 
}, 
"name2": 
{ 
"type": 
"literal", 
"value": 
"node3 
label" 
} 
}, 
// 
list 
of 
pairs 
... 
] 
}
Transformation of graphs 
• D3 data structure 
{ 
"nodes": 
[ 
{ 
"key": 
"node0 
value", 
"label": 
"name0 
value" 
}, 
{ 
"key": 
"node1 
value", 
"label": 
"name1 
value" 
}, 
{ 
"key": 
"node2 
value", 
"label": 
"name2 
value" 
}, 
{ 
"key": 
"node3 
value", 
"label": 
"name3 
value" 
}, 
// 
list 
of 
nodes 
... 
], 
"links": 
[ 
{ 
"source": 
0, 
"target": 
1 
}, 
{ 
"source": 
2, 
"target": 
3 
}, 
{ 
"source": 
1, 
"target": 
3 
}, 
// 
list 
of 
edges 
... 
(nodes 
indexed 
in 
order 
of 
occurrences) 
] 
}
Visualization types currently implemented
Visualization types currently implemented 
• Charts 
• barchart, piechart, scatterplot 
• Graphs 
• force graph, sankey graph 
• Trees 
• roundtree, dendrogram, treemap, sunburst, circlepack 
• Maps 
• coordmap, namedmap 
• Tables 
• htmltable, htmlhash
Usage 
<!DOCTYPE html> 
<meta charset="utf-8"> 
<html> 
<head> 
<script src="http://d3js.org/d3.v3.min.js"></script> 
<script src="d3sparql.js"></script> 
<script> 
function exec() { 
var endpoint = d3.select("#endpoint").property("value") 
var sparql = d3.select("#sparql").property("value") 
d3sparql.query(endpoint, sparql, render) 
} 
function render(json) { 
// set options and call the d3xxxxx function in this library ... 
var config = { ... } 
d3sparql.xxxxx(json, config) 
} 
</script> 
<style> 
<!-- customize CSS --> 
</style> 
</head> 
<body onload="exec()"> 
<form style="display:none"> 
<input id="endpoint" value="http://dbpedia.org/sparql" type="text"> 
<textarea id="sparql"> 
PREFIX ... 
SELECT ... 
WHERE { ... } 
</textarea> 
</form> 
</body> 
</html> 
Download from: 
https://github.com/ktym/d3sparql 
Highly configurable but optional
Demo
TogoGenome 
• Stanza
Future directions 
• Keep it Simple, Stupid (KISS) 
• As an easy to use LEGO blocks for Web developers 
• Integrate more visualization types 
• Statistics, time course etc. 
• Biological representations 
• Based on life science SPARQL endpoints 
• Visualization of OWL/RDF data models 
• Interactive Web applications 
https://github.com/ktym/d3sparql 
Just updated today. Let’s hack together at the hackathon tomorrow :)

More Related Content

What's hot (18)

PDF
Elastify you application: from SQL to NoSQL in less than one hour!
David Pilato
 
PDF
Elasticsearch in 15 minutes
David Pilato
 
PDF
Catmandu / LibreCat Project
Patrick Hochstenbach
 
PPTX
JSON-LD update DC 2017
Gregg Kellogg
 
PPTX
Building a Scalable Inbox System with MongoDB and Java
antoinegirbal
 
PPTX
MongoDB
Bembeng Arifin
 
PPTX
Querying mongo db
Bogdan Sabău
 
PPTX
Scaling Analytics with elasticsearch
dnoble00
 
PDF
Using elasticsearch with rails
Tom Z Zeng
 
PPTX
Back to Basics Webinar 3: Schema Design Thinking in Documents
MongoDB
 
PDF
CouchDB at New York PHP
Bradley Holt
 
ZIP
CouchDB-Lucene
Martin Rehfeld
 
PDF
Solr Graph Query: Presented by Kevin Watters, KMW Technology
Lucidworks
 
PDF
An introduction to MongoDB
Universidade de São Paulo
 
KEY
Modeling Data in MongoDB
lehresman
 
PDF
Building Apps with MongoDB
Nate Abele
 
PPSX
Elasticsearch - basics and beyond
Ernesto Reig
 
ODP
MongoDB - A Document NoSQL Database
Ruben Inoto Soto
 
Elastify you application: from SQL to NoSQL in less than one hour!
David Pilato
 
Elasticsearch in 15 minutes
David Pilato
 
Catmandu / LibreCat Project
Patrick Hochstenbach
 
JSON-LD update DC 2017
Gregg Kellogg
 
Building a Scalable Inbox System with MongoDB and Java
antoinegirbal
 
Querying mongo db
Bogdan Sabău
 
Scaling Analytics with elasticsearch
dnoble00
 
Using elasticsearch with rails
Tom Z Zeng
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
MongoDB
 
CouchDB at New York PHP
Bradley Holt
 
CouchDB-Lucene
Martin Rehfeld
 
Solr Graph Query: Presented by Kevin Watters, KMW Technology
Lucidworks
 
An introduction to MongoDB
Universidade de São Paulo
 
Modeling Data in MongoDB
lehresman
 
Building Apps with MongoDB
Nate Abele
 
Elasticsearch - basics and beyond
Ernesto Reig
 
MongoDB - A Document NoSQL Database
Ruben Inoto Soto
 

Similar to d3sparql.js demo at SWAT4LS 2014 in Berlin (20)

PDF
DBpedia's Triple Pattern Fragments
Ruben Verborgh
 
PDF
Learn D3.js in 90 minutes
Jos Dirksen
 
PDF
D3 Basic Tutorial
Tao Jiang
 
PDF
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
Florian Georg
 
PPTX
Academy PRO: D3, part 1
Binary Studio
 
PDF
Create Graph and Grid Using D3 Library
Yanliang Bao (Beryl)
 
PPTX
Introduction to D3.js
Oleksii Prohonnyi
 
PDF
Introduction to D3
Marcos Iglesias
 
PDF
Sustainable queryable access to Linked Data
Ruben Verborgh
 
ODP
DGraph: Introduction To Basics & Quick Start W/Ratel
Knoldus Inc.
 
PPTX
Validating and Describing Linked Data Portals using RDF Shape Expressions
Jose Emilio Labra Gayo
 
PPTX
Introduction to DGraph - A Graph Database
Knoldus Inc.
 
PDF
D3 data visualization
Keenan Holloway
 
PDF
Having fun with graphs, a short introduction to D3.js
Michael Hackstein
 
PDF
Introduction to d3js (and SVG)
zahid-mian
 
PPTX
SPARQL and RDF query optimization
Kisung Kim
 
PDF
Data Visualization on the Web - Intro to D3
Angela Zoss
 
PDF
Heuristic based Query Optimisation for SPARQL
PlanetData Network of Excellence
 
PPTX
Semantic web meetup – sparql tutorial
AdonisDamian
 
PDF
Visualize your graph database
Michael Hackstein
 
DBpedia's Triple Pattern Fragments
Ruben Verborgh
 
Learn D3.js in 90 minutes
Jos Dirksen
 
D3 Basic Tutorial
Tao Jiang
 
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
Florian Georg
 
Academy PRO: D3, part 1
Binary Studio
 
Create Graph and Grid Using D3 Library
Yanliang Bao (Beryl)
 
Introduction to D3.js
Oleksii Prohonnyi
 
Introduction to D3
Marcos Iglesias
 
Sustainable queryable access to Linked Data
Ruben Verborgh
 
DGraph: Introduction To Basics & Quick Start W/Ratel
Knoldus Inc.
 
Validating and Describing Linked Data Portals using RDF Shape Expressions
Jose Emilio Labra Gayo
 
Introduction to DGraph - A Graph Database
Knoldus Inc.
 
D3 data visualization
Keenan Holloway
 
Having fun with graphs, a short introduction to D3.js
Michael Hackstein
 
Introduction to d3js (and SVG)
zahid-mian
 
SPARQL and RDF query optimization
Kisung Kim
 
Data Visualization on the Web - Intro to D3
Angela Zoss
 
Heuristic based Query Optimisation for SPARQL
PlanetData Network of Excellence
 
Semantic web meetup – sparql tutorial
AdonisDamian
 
Visualize your graph database
Michael Hackstein
 
Ad

More from Toshiaki Katayama (6)

PDF
SPARQList
Toshiaki Katayama
 
PDF
SPARQLアプリケーション開発
Toshiaki Katayama
 
PDF
BioHackathon 2015 report
Toshiaki Katayama
 
PDF
RDFによるデータ統合と相互運用性のための技術開発
Toshiaki Katayama
 
PDF
d3sparql.js
Toshiaki Katayama
 
PDF
Introduction to BioHackathon 2014
Toshiaki Katayama
 
SPARQLアプリケーション開発
Toshiaki Katayama
 
BioHackathon 2015 report
Toshiaki Katayama
 
RDFによるデータ統合と相互運用性のための技術開発
Toshiaki Katayama
 
d3sparql.js
Toshiaki Katayama
 
Introduction to BioHackathon 2014
Toshiaki Katayama
 
Ad

Recently uploaded (20)

PPTX
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
PDF
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
PPTX
00-ClimateChangeImpactCIAProcess_PPTon23.12.2024-ByDr.VijayanGurumurthyIyer1....
praz3
 
PPTX
Sensor IC System Design Using COMSOL Multiphysics 2025-July.pptx
James D.B. Wang, PhD
 
PDF
7.2 Physical Layer.pdf123456789101112123
MinaMolky
 
PPTX
Online Cab Booking and Management System.pptx
diptipaneri80
 
PDF
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
PPTX
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
PDF
Farm Machinery and Equipments Unit 1&2.pdf
prabhum311
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Irrigation Project Report, CTEVT, Diploma in Civil engineering
civilhack22
 
PDF
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PPTX
Fluid statistics and Numerical on pascal law
Ravindra Kolhe
 
PDF
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PDF
CFM 56-7B - Engine General Familiarization. PDF
Gianluca Foro
 
PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
PPT
IISM Presentation.ppt Construction safety
lovingrkn
 
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
00-ClimateChangeImpactCIAProcess_PPTon23.12.2024-ByDr.VijayanGurumurthyIyer1....
praz3
 
Sensor IC System Design Using COMSOL Multiphysics 2025-July.pptx
James D.B. Wang, PhD
 
7.2 Physical Layer.pdf123456789101112123
MinaMolky
 
Online Cab Booking and Management System.pptx
diptipaneri80
 
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
Farm Machinery and Equipments Unit 1&2.pdf
prabhum311
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Irrigation Project Report, CTEVT, Diploma in Civil engineering
civilhack22
 
Air -Powered Car PPT by ER. SHRESTH SUDHIR KOKNE.pdf
SHRESTHKOKNE
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
Fluid statistics and Numerical on pascal law
Ravindra Kolhe
 
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
CFM 56-7B - Engine General Familiarization. PDF
Gianluca Foro
 
Information Retrieval and Extraction - Module 7
premSankar19
 
IISM Presentation.ppt Construction safety
lovingrkn
 

d3sparql.js demo at SWAT4LS 2014 in Berlin

  • 1. d3sparql.js JavaScript library for visualization of SPARQL results Toshiaki Katayama <[email protected]> http://jp.linkedin.com/in/toshiakikatayama Database Center for Life Science (DBCLS), Research Organization of Information and Systems (ROIS), Japan 2014/12/10 @ SWAT4LS, Berlin, Germany
  • 3. SPARQL 1.1 Query Results JSON Format • Accept: application/sparql-results+json d3sparql.query = function(endpoint, sparql, callback) { var url = endpoint + "?query=" + encodeURIComponent(sparql) var mime = "application/sparql-­‐results+json" d3.xhr(url, mime, function(request) { var json = request.responseText callback(JSON.parse(json)) }) } D3.js → AJAX → SPARQL → JSON → D3.js
  • 4. D3SPARQL Demo site: http://biohackathon.org/d3sparql
  • 6. Transformation of trees • Query Result JSON { "head": { "link": [], "vars": ["root_name", "parent_name", "child_name"] }, "results": { "distinct": false, "ordered": true, "bindings": [ { "root_name": { "type": "literal", "value": "root" }, "parent_name": { "type": "literal", "value": "root" } , "child_name": { "type": "literal", "value": "child1" }}, { "root_name": { "type": "literal", "value": "root" }, "parent_name": { "type": "literal", "value": "child1" }, "child_name": { "type": "literal", "value": "grand child1" }}, { "root_name": { "type": "literal", "value": "root" }, "parent_name": { "type": "literal", "value": "child1" }, "child_name": { "type": "literal", "value": "grand child2" }}, // list of parent-­‐child node pairs ... ] }
  • 7. Transformation of trees • D3 data structure { "name": "root", "size": 1024, "children": [ { "name": "child1", "size": 2, "children": [ { "name": "grand child1", "size": 1 }, { "name": "grand child2", "size": 1 } ], }, // list of children nodes ... ] }
  • 8. Transformation of graphs • Query Result JSON { "head": { "link": [], "vars": ["peer1", "name1", "peer2", "name2"] }, "results": { "distinct": false, "ordered": true, "bindings": [ { "peer1": { "type": "literal", "value": "node0" }, "name1": { "type": "literal", "value": "node0 label" }, "peer2": { "type": "literal", "value": "node1" }, "name2": { "type": "literal", "value": "node1 label" } }, { "peer1": { "type": "literal", "value": "node2" }, "name1": { "type": "literal", "value": "node2 label" } "peer2": { "type": "literal", "value": "node3" }, "name2": { "type": "literal", "value": "node3 label" } }, { "peer1": { "type": "literal", "value": "node1" }, "name1": { "type": "literal", "value": "node1 label" } "peer2": { "type": "literal", "value": "node3" }, "name2": { "type": "literal", "value": "node3 label" } }, // list of pairs ... ] }
  • 9. Transformation of graphs • D3 data structure { "nodes": [ { "key": "node0 value", "label": "name0 value" }, { "key": "node1 value", "label": "name1 value" }, { "key": "node2 value", "label": "name2 value" }, { "key": "node3 value", "label": "name3 value" }, // list of nodes ... ], "links": [ { "source": 0, "target": 1 }, { "source": 2, "target": 3 }, { "source": 1, "target": 3 }, // list of edges ... (nodes indexed in order of occurrences) ] }
  • 11. Visualization types currently implemented • Charts • barchart, piechart, scatterplot • Graphs • force graph, sankey graph • Trees • roundtree, dendrogram, treemap, sunburst, circlepack • Maps • coordmap, namedmap • Tables • htmltable, htmlhash
  • 12. Usage <!DOCTYPE html> <meta charset="utf-8"> <html> <head> <script src="http://d3js.org/d3.v3.min.js"></script> <script src="d3sparql.js"></script> <script> function exec() { var endpoint = d3.select("#endpoint").property("value") var sparql = d3.select("#sparql").property("value") d3sparql.query(endpoint, sparql, render) } function render(json) { // set options and call the d3xxxxx function in this library ... var config = { ... } d3sparql.xxxxx(json, config) } </script> <style> <!-- customize CSS --> </style> </head> <body onload="exec()"> <form style="display:none"> <input id="endpoint" value="http://dbpedia.org/sparql" type="text"> <textarea id="sparql"> PREFIX ... SELECT ... WHERE { ... } </textarea> </form> </body> </html> Download from: https://github.com/ktym/d3sparql Highly configurable but optional
  • 13. Demo
  • 15. Future directions • Keep it Simple, Stupid (KISS) • As an easy to use LEGO blocks for Web developers • Integrate more visualization types • Statistics, time course etc. • Biological representations • Based on life science SPARQL endpoints • Visualization of OWL/RDF data models • Interactive Web applications https://github.com/ktym/d3sparql Just updated today. Let’s hack together at the hackathon tomorrow :)