Extension:LinkedWiki/Visualization

From MediaWiki.org
Jump to navigation Jump to search

With Sgvizler2, the LinkedWiki extension can print a chart in your wiki.

Install : insert your keys api of Google and OpenStreepMap[edit]

In the file keys.json, you have to insert the key of Google Map and the token access of OpenStreepMap in order to see their maps.

Build your chart via the special page : Sparql Query Editor[edit]

This extension uses Sgvizler2. You can see/test all charts of this lib here.

  1. Write your query and the endpoint or the config
  2. Select the chart
  3. Read the doc of this chart via the button "See the doc" about available options.
  4. Check the result

Demo :

LinkedWikiExtension-v3.1.0-SparqlEditor-chart


  1. Copy the wiki code in your article via the tab "See Wiki code"

Demo :

LinkedWikiExtension-v3.1.0-SparqlEditor-Wikicode

Examples[edit]

OpenStreepMap[edit]

LinkedWikiExtension-v3.1.0-Sgvizler2-OpenStreetMap

Docs about available options

{{#sparql:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>

select distinct ?lat ?long  ?presidentLabel
where {
        ?president wdt:P39 wd:Q191954 ;
                    wdt:P19  ?villeNaissance ;
                     p:P39 ?s .

        ?villeNaissance  p:P625 ?coord .
        ?coord   psv:P625 ?coordValue .
        ?coordValue a wikibase:GlobecoordinateValue ;
                        wikibase:geoLatitude ?lat ;
                        wikibase:geoLongitude ?long .

        SERVICE wikibase:label {
             bd:serviceParam wikibase:language "fr" .
        }
}
|config=http://www.wikidata.org
|chart=leaflet.visualization.Map
}}


{{#sparql:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>

select distinct
?lat ?long ?siteLabel ?siteDescription
?site
(concat(xsd:string(?image),'?width=200') as ?newimage)
where {
        ?site wdt:P31/wdt:P279* wd:Q839954 .
        ?site wdt:P17 wd:Q142 .
        ?site wdt:P18 ?image .
   ?site p:P625 ?coord .

          ?coord   psv:P625 ?coordValue .

          ?coordValue a wikibase:GlobecoordinateValue ;
                        wikibase:geoLatitude ?lat ;
                        wikibase:geoLongitude ?long .

        SERVICE wikibase:label {
             bd:serviceParam wikibase:language 'en,fr' .
        }
      }
|config=http://www.wikidata.org
|chart=leaflet.visualization.Map
|options=width=100%!height=500px
}}

Google Map[edit]

Docs about available options

{{#sparql:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>

select distinct ?lat ?long  ?presidentLabel
where {
        ?president wdt:P39 wd:Q191954 ;
                    wdt:P19  ?villeNaissance ;
                     p:P39 ?s .

        ?villeNaissance  p:P625 ?coord .
        ?coord   psv:P625 ?coordValue .
        ?coordValue a wikibase:GlobecoordinateValue ;
                        wikibase:geoLatitude ?lat ;
                        wikibase:geoLongitude ?long .

        SERVICE wikibase:label {
             bd:serviceParam wikibase:language "fr" .
        }
}
|config=http://www.wikidata.org
|chart=google.visualization.Map
|options=width=100%!height=500px
|log=2
}}

Datatable[edit]

LinkedWikiExtension-v3.1.0-SparqlEditor-Datatable

You can customize the tag HTML and the the style of each column. Docs about available options

{{#sparql:
select * where 
 { ?x ?y ?z . } 
LIMIT 15
|config=http://www.wikidata.org
|chart=bordercloud.visualization.DataTable
|options=width=100%!height=500px
}}

D3js (experimental)[edit]

Docs about available options

{{#sparql:
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>

select   ?countryLabel (COUNT(?asteroid) as ?nb)
where {
        ?asteroid wdt:P31 wd:Q3863 ;
                  wdt:P61 ?discoverer .
     ?discoverer wdt:P27 ?country .

       SERVICE wikibase:label {
        bd:serviceParam wikibase:language 'en' .
      } .

}
GROUP BY  ?countryLabel
ORDER BY DESC(?nb)
limit 7
|config=http://www.wikidata.org
|chart=d3.visualization.Pie
|options=width=100%!height=500px
|log=2
}}