SlideShare a Scribd company logo
Visualizing Web Data
    Query Results




     Pablo N. Mendes
pablo.mendes@fu-berlin.de

   WWW2012 Tutorial
Outline
●   Preliminaries:
    ●   Javascript, jQuery, same-origin
●   Processing query results
    ●   A closer look at SPARQL JSON
●   Manually parsing and displaying
    ●   Build your own table
●   Neat toolkits to reuse
    ●   Sparqk, Sgvizler
●   Hands on!
Preliminaries
●   Querying from Javascript                                                        $.ajax({
                                                                                         “type”: “POST”,
                                                                                         “url”: endpoint,
                                                                                         “data”: data,
                                                                                         “success”: update,
                                                                                         “dataType”: “json”
                                                                                      });

●   Same origin policy



           http://news.netcraft.com/archives/2008/01/08/italian_banks_xss_opportunity_seized_by_fraudsters.html




●   Cross-origin resource sharing (CORS)                                                                          http://www.w3.org/TR/cors/


           Access­Control­Allow­Origin: *
            The Access-Control-Allow-Origin header should contain the value that was sent in the request's Origin header.
A simple query via Javascript
function sparql() {
  
  var data =  {"query": $("#query").text(),
               "output": "json" };
  $.ajax({
      type: 'POST',
      url: $("#endpoint").text(),,
      data: data,
      success: update,
      dataType: "json"
  });
}
SPARQL-JSON
●   Raw
    ●   Not what you want to visualize
    ●   Used to build other points of view

     select ?place where { ?place rdf:type dbpedia-owl:PopulatedPlace } limit 5


{ "head": { "link": [], "vars": ["place"] },
  "results": { "distinct": false, "ordered": true, "bindings": [
    { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Puerto_Williams" }},
    { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Bouvet_Island" }},
    { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Falkland_Islands" }},
    { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Puerto_Chacabuco" }},
    { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Puerto_Cisnes" }} ] } }
Parsing the results...
             Generating a table header

var header = "<table id='results'><thead>";
$.each(json.head.vars, 
       function (index,v) {
          header += "<th>"+v+"</th>";
       });
header += "</thead>";


                   ?place
Parsing the results...
              Generating a table body.
var body = "<tbody>";
$.each(json.results.bindings, 
       function(index, element) {
       function(index, element) {
         body += "<tr>";
        $.each(json.head.vars, 
                function (vIndex,v) {
                  body += "<td>"+element[v].value+"</td>";
               });
       }
         body += "</tr>";
       });                                      ?place
body += "</tbody>";             http://dbpedia.org/resource/Puerto_Williams

// insert a table               http://dbpedia.org/resource/Bouvet_Island
$('#view').html(header+body);

                                http://dbpedia.org/resource/Puerto_Cisnes
                                http://dbpedia.org/resource/Puerto_Chacabuco
Debugging Javascript
Spark (intro)
●   A library for embedding SPARQL results in HTML
●   Created by:
    ●   Denny Vrandečić and Andreas Harth
●   Source code:
    ●   http://code.google.com/p/rdf-spark/
●   License:
    ●   New BSD License
Spark (main elements)
●   data-spark-endpoint
    ●   where to send queries?
    ●   must be CORS-enabled
●   data-spark-format
    ●   Javascript class to transform results into HTML
●   data-spark-query
    ●   The SPARQL query to fetch data for you
Spark (setup)

<div class="spark"
     data-spark-endpoint="http://dbpedia.org/sparql"
     data-spark-format="http://km.aifb.kit.edu/sites/spark/src/jquery.spark.simpletable.js"
     data-spark-query="select distinct ?City ?State ?Population
                     where {
                         ?c dbpedia-owl:federalState ?s .
                         ?c rdfs:label ?City .
                         ?s rdfs:label ?State .
                         ?c dbpedia-owl:populationTotal ?Population .
                         filter(langMatches(lang(?City),&quot;en&quot;)) .
                         filter(langMatches(lang(?State),&quot;en&quot;)) .
                     }
                     order by desc[?Population]
                     limit 20"
     >
Spark (rendering)




http://km.aifb.kit.edu/sites/spark/docs/example/simpletable.html
Sgvizler (intro)
●   Inspired by Spark, offers prepackaged visualizations
●   Created by:
    ●   Martin G. Skjæveland
●   Source code:
    ●   http://code.google.com/p/sgvizler/
●   License:
    ●   MIT License
Sgvizler (more)




     All the major chart types offered by the
Google Visualization API are supported by Sgvizler.
Sgvizler (setup)

<div id="sgvzl_example1"
    data-sgvizler-endpoint="http://sws.ifi.uio.no/sparql/npd"
    data-sgvizler-query="SELECT ?class (count(?instance)
                                               AS ?noOfInstances)
                                   WHERE{ ?instance a ?class }
                                   GROUP BY ?class
                                   ORDER BY ?class"
    data-sgvizler-chart="gPieChart"
    style="width:800px; height:400px;">
</div>
Sgvizler (rendering)
Sgvizler (Designing Queries)
                                 http://code.google.com/p/sgvizler/wiki/DesigningQueries



●   Each type expects the SPARQL results to be in
    a specific format, e.g.
    ●
        1st column = labels,
    ●   other columns = series
Good practices
●   Display readable things
    ●   Prefer labels over qNames over URIs
    ●   Ask for an optional rdfs:label. Others:
        skos:preferredLabel
    ●   If possible, select the label matching language in
        the browser
Good practices
●   Paginate results
    ●   SPARQL servers have a heart, be gentle with them:
        –   Watch for unnecessary repeated subsecond requests
        –   use LIMIT, OFFSET

    ●   Many JS libraries include support for pagination
        –   e.g. YUI, Google Charts
In Practice
●   http://www2012.pablomendes.com/
Hands on!
http://www2012.pablomendes.com/handson/
WWW2012 Tutorial Visualizing SPARQL Queries

More Related Content

What's hot (17)

PDF
mongodb-introduction
Tse-Ching Ho
 
KEY
An introduction to CouchDB
David Coallier
 
PDF
Elastify you application: from SQL to NoSQL in less than one hour!
David Pilato
 
PPT
Mongo-Drupal
Forest Mars
 
ODP
Terms of endearment - the ElasticSearch Query DSL explained
clintongormley
 
KEY
Mongo db presentation
Julie Sommerville
 
ODP
DrupalCon Chicago Practical MongoDB and Drupal
Doug Green
 
PDF
MongoDB and RDBMS
francescapasha
 
PDF
10gen Presents Schema Design and Data Modeling
DATAVERSITY
 
PDF
Full metal mongo
Israel Gutiérrez
 
KEY
Schema Design with MongoDB
rogerbodamer
 
PPTX
jQuery
Jeremiah Gatong
 
PPTX
JSON-LD update DC 2017
Gregg Kellogg
 
PPTX
Mongo db
Girish Talekar
 
PPTX
MongoDB (Advanced)
TO THE NEW | Technology
 
PDF
Building Apps with MongoDB
Nate Abele
 
PDF
DBIx::Class walkthrough @ bangalore pm
Sheeju Alex
 
mongodb-introduction
Tse-Ching Ho
 
An introduction to CouchDB
David Coallier
 
Elastify you application: from SQL to NoSQL in less than one hour!
David Pilato
 
Mongo-Drupal
Forest Mars
 
Terms of endearment - the ElasticSearch Query DSL explained
clintongormley
 
Mongo db presentation
Julie Sommerville
 
DrupalCon Chicago Practical MongoDB and Drupal
Doug Green
 
MongoDB and RDBMS
francescapasha
 
10gen Presents Schema Design and Data Modeling
DATAVERSITY
 
Full metal mongo
Israel Gutiérrez
 
Schema Design with MongoDB
rogerbodamer
 
JSON-LD update DC 2017
Gregg Kellogg
 
Mongo db
Girish Talekar
 
MongoDB (Advanced)
TO THE NEW | Technology
 
Building Apps with MongoDB
Nate Abele
 
DBIx::Class walkthrough @ bangalore pm
Sheeju Alex
 

Viewers also liked (20)

PPT
20071222 Zhengyun 语义讲稿
zhengyun
 
PPT
Rapid semantic web app dev using Callimachus
Bernadette Hyland-Wood
 
PPT
Semantic Web: In Quest for the Next Generation Killer Apps
Jie Bao
 
PDF
API's, Freebase, and the Collaborative Semantic web
Dan Delany
 
PPTX
Dice.com Bay Area Search - Beyond Learning to Rank Talk
Simon Hughes
 
PPTX
Twarql Architecture - Streaming Annotated Tweets
Pablo Mendes
 
PDF
Facebook Graph Search per il Business - Daniele Ghidoli - Be-Wizard 2013
Daniele Ghidoli
 
PDF
Generalized Low Rank Models
Sri Ambati
 
PDF
ISWC 2016 Tutorial: Semantic Web of Things M3 framework & FIESTA-IoT EU project
FIESTA-IoT
 
PDF
Semantic web user interfaces - Do they have to be ugly?
Andraz Tori
 
PDF
Lecture: Question Answering
Marina Santini
 
ZIP
Facebook ( Open ) Graph and the Semantic Web
Matteo Brunati
 
PDF
Instant Question Answering System
Dhwaj Raj
 
PPT
The Semantic Web
ostephens
 
PPTX
Skutil - H2O meets Sklearn - Taylor Smith
Sri Ambati
 
PDF
Intro to Deep Learning for Question Answering
Traian Rebedea
 
PPTX
Introduction to the Semantic Web
Tomek Pluskiewicz
 
PPTX
Feature Selection for Document Ranking
Andrea Gigli
 
PPTX
Latest on Semantic Web
Shamod Lacoul
 
PDF
An introduction to Semantic Web and Linked Data
Fabien Gandon
 
20071222 Zhengyun 语义讲稿
zhengyun
 
Rapid semantic web app dev using Callimachus
Bernadette Hyland-Wood
 
Semantic Web: In Quest for the Next Generation Killer Apps
Jie Bao
 
API's, Freebase, and the Collaborative Semantic web
Dan Delany
 
Dice.com Bay Area Search - Beyond Learning to Rank Talk
Simon Hughes
 
Twarql Architecture - Streaming Annotated Tweets
Pablo Mendes
 
Facebook Graph Search per il Business - Daniele Ghidoli - Be-Wizard 2013
Daniele Ghidoli
 
Generalized Low Rank Models
Sri Ambati
 
ISWC 2016 Tutorial: Semantic Web of Things M3 framework & FIESTA-IoT EU project
FIESTA-IoT
 
Semantic web user interfaces - Do they have to be ugly?
Andraz Tori
 
Lecture: Question Answering
Marina Santini
 
Facebook ( Open ) Graph and the Semantic Web
Matteo Brunati
 
Instant Question Answering System
Dhwaj Raj
 
The Semantic Web
ostephens
 
Skutil - H2O meets Sklearn - Taylor Smith
Sri Ambati
 
Intro to Deep Learning for Question Answering
Traian Rebedea
 
Introduction to the Semantic Web
Tomek Pluskiewicz
 
Feature Selection for Document Ranking
Andrea Gigli
 
Latest on Semantic Web
Shamod Lacoul
 
An introduction to Semantic Web and Linked Data
Fabien Gandon
 
Ad

Similar to WWW2012 Tutorial Visualizing SPARQL Queries (20)

PDF
Visualize open data with Plone - eea.daviz PLOG 2013
Antonio De Marinis
 
PPTX
A Real-World Implementation of Linked Data
Dimitri van Hees
 
PDF
Querying Linked Data with SPARQL (2010)
Olaf Hartig
 
PDF
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...
Olaf Hartig
 
PDF
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
Olaf Hartig
 
PDF
Querying Linked Data with SPARQL
Olaf Hartig
 
PPTX
APIs and the Semantic Web: publishing information instead of data
Dimitri van Hees
 
PPT
Re-using Media on the Web: Media fragment re-mixing and playout
MediaMixerCommunity
 
PDF
MongoDB and Web Scrapping with the Gyes Platform
MongoDB
 
PDF
Context-Aware Access Control for RDF Graph Stores
Serena Villata
 
PPTX
Semantic Web and Related Work at W3C
Ivan Herman
 
PDF
Linking the world with Python and Semantics
Tatiana Al-Chueyr
 
KEY
Creating web applications with LODSPeaKr
Alvaro Graves
 
ODP
SPARQL 1.1 Update (2013-03-05)
andyseaborne
 
PDF
Webinar: Semantic web for developers
Semantic Web Company
 
PPTX
Triplestore and SPARQL
Lino Valdivia
 
PDF
SFScon 2020 - Peter Hopfgartner - Open Data de luxe
South Tyrol Free Software Conference
 
PPTX
Introduction to SPARQL
Jose Emilio Labra Gayo
 
PPTX
Introduction to SPARQL
Jose Emilio Labra Gayo
 
PPTX
Madrid SPARQL handson
Victor de Boer
 
Visualize open data with Plone - eea.daviz PLOG 2013
Antonio De Marinis
 
A Real-World Implementation of Linked Data
Dimitri van Hees
 
Querying Linked Data with SPARQL (2010)
Olaf Hartig
 
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...
Olaf Hartig
 
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
Olaf Hartig
 
Querying Linked Data with SPARQL
Olaf Hartig
 
APIs and the Semantic Web: publishing information instead of data
Dimitri van Hees
 
Re-using Media on the Web: Media fragment re-mixing and playout
MediaMixerCommunity
 
MongoDB and Web Scrapping with the Gyes Platform
MongoDB
 
Context-Aware Access Control for RDF Graph Stores
Serena Villata
 
Semantic Web and Related Work at W3C
Ivan Herman
 
Linking the world with Python and Semantics
Tatiana Al-Chueyr
 
Creating web applications with LODSPeaKr
Alvaro Graves
 
SPARQL 1.1 Update (2013-03-05)
andyseaborne
 
Webinar: Semantic web for developers
Semantic Web Company
 
Triplestore and SPARQL
Lino Valdivia
 
SFScon 2020 - Peter Hopfgartner - Open Data de luxe
South Tyrol Free Software Conference
 
Introduction to SPARQL
Jose Emilio Labra Gayo
 
Introduction to SPARQL
Jose Emilio Labra Gayo
 
Madrid SPARQL handson
Victor de Boer
 
Ad

More from Pablo Mendes (9)

PDF
Entity Aware Click Graph
Pablo Mendes
 
PDF
Sieve - Data Quality and Fusion - LWDM2012
Pablo Mendes
 
PDF
A Virtuous Cycle of Semantic Enhancement with DBpedia Spotlight - SemTech Ber...
Pablo Mendes
 
PDF
Ligado nos Políticos at ESWC'2011 Workshop
Pablo Mendes
 
PDF
SMWCon Fall 2011 Lightning Talk
Pablo Mendes
 
PPTX
DBpedia Spotlight at I-SEMANTICS 2011
Pablo Mendes
 
PDF
Dados Ligados (Linked Data) CONSEGI 2011
Pablo Mendes
 
PPTX
Cuebee Architecture
Pablo Mendes
 
PPTX
Dynamic Associative Relationships on the Linked Open Data Web
Pablo Mendes
 
Entity Aware Click Graph
Pablo Mendes
 
Sieve - Data Quality and Fusion - LWDM2012
Pablo Mendes
 
A Virtuous Cycle of Semantic Enhancement with DBpedia Spotlight - SemTech Ber...
Pablo Mendes
 
Ligado nos Políticos at ESWC'2011 Workshop
Pablo Mendes
 
SMWCon Fall 2011 Lightning Talk
Pablo Mendes
 
DBpedia Spotlight at I-SEMANTICS 2011
Pablo Mendes
 
Dados Ligados (Linked Data) CONSEGI 2011
Pablo Mendes
 
Cuebee Architecture
Pablo Mendes
 
Dynamic Associative Relationships on the Linked Open Data Web
Pablo Mendes
 

Recently uploaded (20)

PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Digital Circuits, important subject in CS
contactparinay1
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 

WWW2012 Tutorial Visualizing SPARQL Queries

  • 1. Visualizing Web Data Query Results Pablo N. Mendes [email protected] WWW2012 Tutorial
  • 2. Outline ● Preliminaries: ● Javascript, jQuery, same-origin ● Processing query results ● A closer look at SPARQL JSON ● Manually parsing and displaying ● Build your own table ● Neat toolkits to reuse ● Sparqk, Sgvizler ● Hands on!
  • 3. Preliminaries ● Querying from Javascript $.ajax({      “type”: “POST”,      “url”: endpoint,      “data”: data,      “success”: update,      “dataType”: “json”   }); ● Same origin policy http://news.netcraft.com/archives/2008/01/08/italian_banks_xss_opportunity_seized_by_fraudsters.html ● Cross-origin resource sharing (CORS) http://www.w3.org/TR/cors/ Access­Control­Allow­Origin: * The Access-Control-Allow-Origin header should contain the value that was sent in the request's Origin header.
  • 4. A simple query via Javascript function sparql() {      var data =  {"query": $("#query").text(),                "output": "json" };   $.ajax({       type: 'POST',       url: $("#endpoint").text(),,       data: data,       success: update,       dataType: "json"   }); }
  • 5. SPARQL-JSON ● Raw ● Not what you want to visualize ● Used to build other points of view select ?place where { ?place rdf:type dbpedia-owl:PopulatedPlace } limit 5 { "head": { "link": [], "vars": ["place"] }, "results": { "distinct": false, "ordered": true, "bindings": [ { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Puerto_Williams" }}, { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Bouvet_Island" }}, { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Falkland_Islands" }}, { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Puerto_Chacabuco" }}, { "place": { "type": "uri", "value": "http://dbpedia.org/resource/Puerto_Cisnes" }} ] } }
  • 6. Parsing the results... Generating a table header var header = "<table id='results'><thead>"; $.each(json.head.vars,         function (index,v) {           header += "<th>"+v+"</th>";        }); header += "</thead>"; ?place
  • 7. Parsing the results... Generating a table body. var body = "<tbody>"; $.each(json.results.bindings,   function(index, element) {        function(index, element) { body += "<tr>";         $.each(json.head.vars,                  function (vIndex,v) {                   body += "<td>"+element[v].value+"</td>";                });        }          body += "</tr>";        }); ?place body += "</tbody>"; http://dbpedia.org/resource/Puerto_Williams // insert a table http://dbpedia.org/resource/Bouvet_Island $('#view').html(header+body); http://dbpedia.org/resource/Puerto_Cisnes http://dbpedia.org/resource/Puerto_Chacabuco
  • 9. Spark (intro) ● A library for embedding SPARQL results in HTML ● Created by: ● Denny Vrandečić and Andreas Harth ● Source code: ● http://code.google.com/p/rdf-spark/ ● License: ● New BSD License
  • 10. Spark (main elements) ● data-spark-endpoint ● where to send queries? ● must be CORS-enabled ● data-spark-format ● Javascript class to transform results into HTML ● data-spark-query ● The SPARQL query to fetch data for you
  • 11. Spark (setup) <div class="spark" data-spark-endpoint="http://dbpedia.org/sparql" data-spark-format="http://km.aifb.kit.edu/sites/spark/src/jquery.spark.simpletable.js" data-spark-query="select distinct ?City ?State ?Population where { ?c dbpedia-owl:federalState ?s . ?c rdfs:label ?City . ?s rdfs:label ?State . ?c dbpedia-owl:populationTotal ?Population . filter(langMatches(lang(?City),&quot;en&quot;)) . filter(langMatches(lang(?State),&quot;en&quot;)) . } order by desc[?Population] limit 20" >
  • 13. Sgvizler (intro) ● Inspired by Spark, offers prepackaged visualizations ● Created by: ● Martin G. Skjæveland ● Source code: ● http://code.google.com/p/sgvizler/ ● License: ● MIT License
  • 14. Sgvizler (more) All the major chart types offered by the Google Visualization API are supported by Sgvizler.
  • 15. Sgvizler (setup) <div id="sgvzl_example1" data-sgvizler-endpoint="http://sws.ifi.uio.no/sparql/npd" data-sgvizler-query="SELECT ?class (count(?instance) AS ?noOfInstances) WHERE{ ?instance a ?class } GROUP BY ?class ORDER BY ?class" data-sgvizler-chart="gPieChart" style="width:800px; height:400px;"> </div>
  • 17. Sgvizler (Designing Queries) http://code.google.com/p/sgvizler/wiki/DesigningQueries ● Each type expects the SPARQL results to be in a specific format, e.g. ● 1st column = labels, ● other columns = series
  • 18. Good practices ● Display readable things ● Prefer labels over qNames over URIs ● Ask for an optional rdfs:label. Others: skos:preferredLabel ● If possible, select the label matching language in the browser
  • 19. Good practices ● Paginate results ● SPARQL servers have a heart, be gentle with them: – Watch for unnecessary repeated subsecond requests – use LIMIT, OFFSET ● Many JS libraries include support for pagination – e.g. YUI, Google Charts
  • 20. In Practice ● http://www2012.pablomendes.com/