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

KEY
Elasticsearch & "PeopleSearch"
PPTX
Networkin II Estructuras con MongoDB y Javascript
PDF
Visualizing Web Data Query Results
PDF
elasticsearch - advanced features in practice
PDF
Elasticsearch first-steps
ODP
2011 Mongo FR - Indexing in MongoDB
PPTX
Mongo db
PPT
Catmandu Librecat
Elasticsearch & "PeopleSearch"
Networkin II Estructuras con MongoDB y Javascript
Visualizing Web Data Query Results
elasticsearch - advanced features in practice
Elasticsearch first-steps
2011 Mongo FR - Indexing in MongoDB
Mongo db
Catmandu Librecat

What's hot (18)

PDF
Elastify you application: from SQL to NoSQL in less than one hour!
PDF
Elasticsearch in 15 minutes
PDF
Catmandu / LibreCat Project
PPTX
JSON-LD update DC 2017
PPTX
Building a Scalable Inbox System with MongoDB and Java
PPTX
PPTX
Querying mongo db
PPTX
Scaling Analytics with elasticsearch
PDF
Using elasticsearch with rails
PPTX
Back to Basics Webinar 3: Schema Design Thinking in Documents
PDF
CouchDB at New York PHP
ZIP
CouchDB-Lucene
PDF
Solr Graph Query: Presented by Kevin Watters, KMW Technology
PDF
An introduction to MongoDB
KEY
Modeling Data in MongoDB
PDF
Building Apps with MongoDB
PPSX
Elasticsearch - basics and beyond
ODP
MongoDB - A Document NoSQL Database
Elastify you application: from SQL to NoSQL in less than one hour!
Elasticsearch in 15 minutes
Catmandu / LibreCat Project
JSON-LD update DC 2017
Building a Scalable Inbox System with MongoDB and Java
Querying mongo db
Scaling Analytics with elasticsearch
Using elasticsearch with rails
Back to Basics Webinar 3: Schema Design Thinking in Documents
CouchDB at New York PHP
CouchDB-Lucene
Solr Graph Query: Presented by Kevin Watters, KMW Technology
An introduction to MongoDB
Modeling Data in MongoDB
Building Apps with MongoDB
Elasticsearch - basics and beyond
MongoDB - A Document NoSQL Database
Ad

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

PDF
Closing the Loop in Extended Reality with Kafka Streams and Machine Learning ...
PPTX
1403 app dev series - session 5 - analytics
PPTX
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
PDF
Gab document db scaling database
PDF
WWW2012 Tutorial Visualizing SPARQL Queries
PDF
MongoDB Performance Tuning
PDF
2012 mongo db_bangalore_roadmap_new
PPTX
Dex Technical Seminar (April 2011)
PDF
Json the-x-in-ajax1588
ODP
ELK Stack - Turn boring logfiles into sexy dashboard
PDF
Real-Time Spark: From Interactive Queries to Streaming
PPTX
Peggy elasticsearch應用
PPTX
Using Neo4j from Java
PDF
Intro to Spark and Spark SQL
PDF
Latinoware
PDF
Apache Drill @ PJUG, Jan 15, 2013
PPTX
Spark - Philly JUG
PPT
json.ppt download for free for college project
PPTX
MongoDB 3.0
PPTX
Modeling JSON data for NoSQL document databases
Closing the Loop in Extended Reality with Kafka Streams and Machine Learning ...
1403 app dev series - session 5 - analytics
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
Gab document db scaling database
WWW2012 Tutorial Visualizing SPARQL Queries
MongoDB Performance Tuning
2012 mongo db_bangalore_roadmap_new
Dex Technical Seminar (April 2011)
Json the-x-in-ajax1588
ELK Stack - Turn boring logfiles into sexy dashboard
Real-Time Spark: From Interactive Queries to Streaming
Peggy elasticsearch應用
Using Neo4j from Java
Intro to Spark and Spark SQL
Latinoware
Apache Drill @ PJUG, Jan 15, 2013
Spark - Philly JUG
json.ppt download for free for college project
MongoDB 3.0
Modeling JSON data for NoSQL document databases
Ad

More from Toshiaki Katayama (6)

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

Recently uploaded (20)

PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Sustainable Sites - Green Building Construction
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Welding lecture in detail for understanding
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Well-logging-methods_new................
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Construction Project Organization Group 2.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Internet of Things (IOT) - A guide to understanding
Sustainable Sites - Green Building Construction
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Welding lecture in detail for understanding
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Foundation to blockchain - A guide to Blockchain Tech
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Well-logging-methods_new................
Operating System & Kernel Study Guide-1 - converted.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx

d3sparql.js demo at SWAT4LS 2014 in Berlin

  • 1. 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
  • 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 :)