Extension:SparqlResultFormat

Description
SparqlResultFormat is a free, open-source extension to MediaWiki that lets you query different Sparql endpoints and represent output data in various formats.

Installation

 * 1) Unzip the downloaded zip file to the extensions folder of your mediawiki and rename it to 'SparqlResultFormat'.
 * 2) Include the following line at the end of your LocalSettings.php:
 * 3) Check documentation at the Special:SparqlResultFormat page on your mediawiki

Formats & Examples
These examples works with Wikidata sparql query endpoint.

Define it in your LocalSettings.php $wgSparqlEndpointDefinition['wikidata'] = array(		'url' => 'https://query.wikidata.org/sparql',		'connectionTimeout' => 0,		'requestTimeout' => 30);

Node graph
Members of European Union with their capitals



{{#sparql2graph: { category:"country",nodeColor:"#00FF00", image:"https://cdn1.vectorstock.com/i/1000x1000/59/35/visited-country-icon-symbol-premium-quality-vector-16435935.jpg"}, { category:"city",nodeColor:"#00FFFF", image:"https://cdn0.iconfinder.com/data/icons/good-view/500/View-08-512.png"} ] select distinct ?parent_uri ?parent_name ?child_uri ?child_name ?parent_type ?parent_type_uri ?child_type ?child_type_uri ?relation_uri ?relation_name where { { ?parent_uri ?relation_uri ?child_uri.
 * divId=mynetwork
 * divStyle=width:100%;height:530px;
 * linkBasePath={{SERVER}}{{SCRIPTPATH}}/index.php/
 * nodeConfiguration=[
 * edgeConfiguration={}
 * defaultNodeColor=#CCC
 * defaultEdgeColor=#CCC
 * maxLabelLength=200
 * showLegend=true
 * rootElement=http://www.wikidata.org/entity/Q458
 * rootElementImage=https://cdn3.iconfinder.com/data/icons/50-flags-of-the-world-circular-shape-2/60/Circular_world_Flag_134-512.png
 * rootElementColor=
 * layout=dagre
 * nodeStyle={}
 * edgeStyle={}
 * layoutOptions={}
 * splitQueryByUnion=false
 * minZoom=0.2
 * maxZoom=1.2
 * sparqlEndpoint=wikidata
 * sparqlEscapedQuery=

SERVICE wikibase:label { bd:serviceParam wikibase:language "en". ?parent_uri rdfs:label ?parent_name. ?child_uri rdfs:label ?child_name. ?parent_type_uri rdfs:label ?parent_type. ?child_type_uri rdfs:label ?child_type. } BIND (wdt:P150 AS ?relation_uri) BIND (wd:Q458 AS ?parent_uri) BIND (wd:Q3623811 AS ?parent_type_uri) BIND (wd:Q6256 AS ?child_type_uri) BIND ("Has members" AS ?relation_name) } UNION { ?root wdt:P150 ?parent_uri. ?parent_uri ?relation_uri ?child_uri. SERVICE wikibase:label { bd:serviceParam wikibase:language "en". ?parent_uri rdfs:label ?parent_name. ?child_uri rdfs:label ?child_name. ?parent_type_uri rdfs:label ?parent_type. ?child_type_uri rdfs:label ?child_type. #?relation_uri rdfs:label ?relation_name }   BIND (wd:Q458 AS ?root) BIND (wdt:P36 AS ?relation_uri) BIND (wd:Q6256 AS ?parent_type_uri) BIND (wd:Q515 AS ?child_type_uri) BIND ("Has capital" AS ?relation_name) } }

Bar Chart
Top 20 countries by population size