Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Query a SPARQL endpoint with a SELECT query and get the data ready to be used with d3js

License

NotificationsYou must be signed in to change notification settings

zazuko/d3-sparql

Repository files navigation

This module lets you request data fromSPARQLendpoints in the vein ofd3-csv and friends. It is generating a JSON structure from SPARQL query results, you can use that in any way you like in your code, with or without D3.

The access through a SPARQL endpoint allows a faster and more efficient data preparation (once you gotthe hang of SPARQL and the RDF data model). Ultimately it keeps visualizations up to date. Think of SPARQL endpoints as the most flexible API imaginable.

Define the SPARQL query and endpoint:

// Author of Q3011087 (D3.js)varmikeQuery=`SELECT ?developerName WHERE {  wd:Q3011087 wdt:P178 ?developer.  ?developer rdfs:label ?developerName.  FILTER(LANG(?developerName) = 'en')}`wikidataUrl='https://query.wikidata.org/bigdata/namespace/wdq/sparql'

To query the endpoint and get the result:

d3.sparql(wikidataUrl,mikeQuery).then((data)=>{console.log(data);// [{'developerName': 'Mike Bostock'}]})

Moreexamples are provided in therepository.

Features

  • Transformation ofXSD Datatypes (e.g.xsd:dateTime,xsd:boolean, ...) to native JavaScript types.
  • Reformatting of the JSON Structure to a d3 style layout while using the provided variables names of the SPARQL Query.

Limitations

  • OnlySELECT queries are supported. (This provides a projection of the graph data onto a table structure used by d3.)
  • Currently only supports endpoints which are able to respond withapplication/sparql-results+json.

Installing

Using NPM:npm install d3-sparql. You can also use a CDN, for instancehttps://www.jsdelivr.com.

SeeCHANGELOG for details about available versions.

API Reference

This package adds asparql function to the globald3 object:d3.sparql(endpoint, query, options = {}).

# d3. sparql(endpoint,query[,options = {}])<>

options is an optional object that will get merged with the second argument offetch().

d3.sparql(endpoint,query).then((data)=>);

Acknowledgement

The initial development of this library byZazuko was supported by theCity of Zürich.

About

Query a SPARQL endpoint with a SELECT query and get the data ready to be used with d3js

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp