Wikidata:SPARQL query service/Wikidata Query Help/Result Views/de
This page describes the WDQS interface and helps you to understand the various possibilities to display results on SPARQL query service.
Die Abfragebeispielseite enthält viele gute Beispiele, die du ausprobieren kannst!
Open the WDQS interface and then:
- select your language in of the upper tool bar.
- write a valid SPARQL code in the text area.
- check your script by hovering the elements with your mouse; tooltips appear and should be consistent with what you intend to do. They adopt the language you have selected (default to english).
- then click on blue button Execute query of the sidebar to launch the request. Red square is lit in the sidebar while the command executes.
- after running a query, you can choose in the "Display" formats which result view you want to display. Depending on your query and the data type, some of the views will not be available.
Source example |
---|
# Recent events
SELECT ?event ?eventLabel ?date
WHERE
{
# find events
?event wdt:P31/wdt:P279* wd:Q1190554.
# with a point in time or start date
OPTIONAL { ?event wdt:P585 ?date. }
OPTIONAL { ?event wdt:P580 ?date. }
# but at least one of those
FILTER(BOUND(?date) && DATATYPE(?date) = xsd:dateTime).
# not in the future, and not more than 31 days ago
BIND(NOW() - ?date AS ?distance).
FILTER(0 <= ?distance && ?distance < 31).
# and get a label as well
OPTIONAL {
?event rdfs:label ?eventLabel.
FILTER(LANG(?eventLabel) = "en").
}
}
# limit to 10 results so we don't timeout
LIMIT 10
|
Note: You can also run directly a hardcoded request via the TryIt links of this page. When it brings you directly to the result display you can always return to the source script unsing the link at the bottom of the interface.
Tabelle (Standard)
Zeigt die Ergebnisse als Tabelle an. Das ist die Standardansicht für Ergebnisse und kann jeden Datentyp anzeigen.
Will map every variable from the SPARQL select clause to a formatted table column.
-
Ergebnistabelle
-
Ergebnistabelle auf kleinen Bildschirmen, mit vertauschten Spalten
Image Grid
Zeigt die Ergebnisdaten als Gitter mit Bildern an.
Every grid item has a big picture and opens the gallery when clicking on it.
Contents an item is the formatted row data.
Variable | Datentyp | Mapping | Beschreibung |
---|---|---|---|
* | Commons Media | Grid Item | Image columns will create a grid item. |
Rows containing no image will be ignored.
It’s nonetheless possible to include no image rows in the result by modifying the sparql by including a default image in case the image variable is not bound:
optional {
?item wdt:P18 ?img_ .
}
bind (if(bound(?img_),
?img_,
<http://commons.wikimedia.org/wiki/Special:FilePath/File:Profile_avatar_placeholder_large.png>) as ?image) # [[:commons:File:Profile_avatar_placeholder_large.png]] as a placeholder
Here the file commons:File:Profile avatar placeholder large.png is used as a placeholder, you can use your own.
Optionen
Optionsname | Typ | Beschreibung |
---|---|---|
hide
|
One or more variable names (strings, starting with ? ), single value or array
|
Zeige nicht diese Variablen als Ergebnis. |
Karte
Zeigt die Ergebnisdaten als Karte mit OpenStreetMap-Daten an.
Variable | Datentyp | Mapping | Beschreibung |
---|---|---|---|
* | Koordinate | Kartenmarker | Spalten erstellen einen Marker auf der Karte
Der Inhalt des Markers sind die #Formatting Rohdaten. |
?layer | Kartenmarkerlayer | Erstellen eines gefärbten Kartenlayers mit Filterfunktion | |
?rgb | Farbe | Kartenmarken färben | Example 000000 for black color. |
-
Karten mit Layers Ausprobieren
-
Karte von Flughäfen in Belgien Ausprobieren
Technically, any well-known text literal can be displayed, not just a point coordinate.
Non-point geometry values are never stored on Wikidata, but they can be constructed in SPARQL using functions like CONCAT()
and STRDT()
–
see this map of Czech railway lines for an example of LINESTRING()
geometry.
Optionen
specify using e.g. #defaultView:Map{"hide":["?foo", "?bar"],"layer":"?bar"}
, using an array when there are multiple variables.
Optionsname | Typ | Beschreibung |
---|---|---|
hide
|
One or more variable names (strings, starting with ? ), single value or array
|
Don’t show these variables in the result. |
layer
|
One or more variable names (strings, starting with ? ), single value or array
|
Use these variables for the map layer, instead of the default ?layerLabel , ?layer .
|
markercluster
|
boolean or object |
|
Line, Bar, Scatter and Area Chart
Zeigt einen dieser Diagrammtypen.
Variable | Datentyp | Mapping | Beschreibung |
---|---|---|---|
* | Number
Label DateTime |
X-Axis
Y-Axis |
First will be X-axis, second Y-axis |
* | Label | Category / Legend Item (optional) | Will only be used after the above are mapped |
* | Label | Storyboard / Animation (optional) | Will only be used after the above are mapped |
Bubble Chart
Shows a bubble chart where the size and the color of the bubble can configured.
When an item is provided a bubble is linked to Wikidata.org.
Variable | Datentyp | Mapping |
---|---|---|
* | Label | Bubble Label |
* | Number | Bubble Size |
* | Item | Bubble Link (optional) |
?rgb | Color | Bubble Color (optional) |
Tree Map
Shows a zoomable tree map.
Variable | Datentyp | Mapping | Beschreibung |
---|---|---|---|
* | Label | Label | 1st label in a row will be 1st level in tree map. 2nd label will be 2nd level. 3rd label will be 3rd level etc.. |
* | Item | Link (optional) | |
* | Quantity | Size |
Tree
Shows an expandable tree.
Variable | Datentyp | Mapping | Beschreibung |
---|---|---|---|
* | Item | Node ID | First item will be a root node the following items in the same row will be nested. |
* | Label | Node Label (optional) | Labels will be appended to current node. |
* | Number | Node Label (optional) | |
* | Commons Media | Item image |
Timeline
Shows a explorable timeline.
Variable | Datentyp | Mapping | Beschreibung |
---|---|---|---|
* | DateTime | Item Point in Time
Item End Point in Time |
First date in a row sets the item position in the timeline.
If a second date is present a start and end date will be set. |
* | Commons Media | Item image |
Options
Option name | Type | Description |
---|---|---|
hide
|
One or more variable names (strings, starting with ? ), single value or array
|
Don’t show these variables in the result. |
Dimensions
Shows dimension and their links.
It also allows filtering them by selecting an axis fraction.
This type of graph is also known as parallel coordinates.
Variable | Datentyp | Mapping | Beschreibung |
---|---|---|---|
* | Label | Dimension | Every column in the result row is mapped to a dimension |
* | Number | ||
* | DateTime |
Graph
Shows an interactive graph that allow hierarchically ordering and exploring items.
Variable | Datentyp | Mapping | Beschreibung |
---|---|---|---|
* | Item | Node ID | First item in a row of output variables will have an arrow pointing to the items in the same row. |
* | Label | Node Label (optional) | |
* | Commons Media | Node Image (optional) | |
?rgb | Color | Node Color (optional) | Color of the item just before the rgb variable. Example 000000 for black color. |
* | Number | Node Size (optional) | |
?edgeLabel | Label | Edge Label (optional) |
-
Graph
-
Weitere Informationen
RDF-Datentypen-Mapping
RDF Type | RDF Data Type | Constraint | Data Type |
---|---|---|---|
URI | String starts with http://www.wikidata.org/entity/Q |
Entity | |
URI | String starts with http://commons.wikimedia.org/wiki/Special:FilePath |
Commons Media | |
Literal | http://www.w3.org/2001/XMLSchema#dateTime | DateTime | |
Literal | http://www.opengis.net/ont/geosparql#wktLiteral | Coordinate | |
Literal | http://www.w3.org/2001/XMLSchema#double
http://www.w3.org/2001/XMLSchema#float http://www.w3.org/2001/XMLSchema#decimal http://www.w3.org/2001/XMLSchema#integer http://www.w3.org/2001/XMLSchema#long http://www.w3.org/2001/XMLSchema#int http://www.w3.org/2001/XMLSchema#short http://www.w3.org/2001/XMLSchema#nonNegativeInteger http://www.w3.org/2001/XMLSchema#positiveInteger http://www.w3.org/2001/XMLSchema#unsignedLong http://www.w3.org/2001/XMLSchema#unsignedInt http://www.w3.org/2001/XMLSchema#unsignedShort http://www.w3.org/2001/XMLSchema#nonPositiveInteger http://www.w3.org/2001/XMLSchema#negativeInteger |
Number | |
Literal | Has no RDF Data Type | Label | |
Literal | Has property xml:lang |
Label | |
Literal | String matches /^[0-9A-F]{6}$/ |
Farbe |
Formatierung
Für die folgenden Datentypen gibt es spezielle Formatierungen:
Datentyp | Format |
---|---|
Entity | Link zu Wikidata.org
Label is shortened to wd:Qxx Explore an item (magnify icon) |
DateTime | MM DD, YYYY
Der Tooltip zeigt die den rohen ISO-Timestamp |
Commons Media | Link zu Commons.Wikimedia.org
Displaying Gallery ( image icon ) |
Mobile / Responsive
Result views are made to work on different devices and resolutions. Their appearance may change depending on the space they can use.
Embed Mode
Result views can be linked or embedded via iframes. You can get the regarding link or code by clicking Link in the above menu.
See the difference: link to a query and link to a result or the embed code:
<iframe style="width:80vw; height:50vh;" scrolling="yes" frameborder="0" src="http://tinyurl.com/zwf4k2w">
Ergebnisse herunterladen
Es gibt verschiedene Möglichkeiten, die Ergebnisse einer Abfrage zu exportieren.
JSON, TSV und CSV sind drei unterschiedliche, offene Standardformate um die Daten herunterzuladen. Sie finden diese optionen unter Download. Um die Daten im XML-Format zu erhalten, klicken sie auf Link > SPARQL endpoint.
You can also download some of the graphic views as a SVG file: this feature works with all the views except table, image grid, timeline, graph builder, map, and graph.
Default View
The default view can be change for each SPARQL query by using a comment:
#defaultView:[NAME]
Zum Beispiel:
#defaultView:ImageGrid
Result view options
Result views can be configured with various options, which are specified in JSON (Q2063) format, either following the defaultView
comment (see previous section) or following a separate view
comment.
#defaultView:Map{"layer": "?typeLabel"}
#view:ImageGrid{"hide": "?coords"}
Title
Result views can show a title. The title can be set via a title
comment.
#title:A title of your choice
List of WDQS tags
WDQS tag | Display options | Notes |
---|---|---|
#defaultView:Table | Table | default format when omitted |
#defaultView:ImageGrid | Image grid | |
Graph builder | access to the graph builder tool | |
#defaultView:Map | Map | |
#defaultView:LineChart | Line chart | |
#defaultView:BarChart | Bar chart | |
#defaultView:ScatterChart | Scatter chart | |
#defaultView:AreaChart | Area chart | |
#defaultView:BubbleChart | Bubble chart | |
#defaultView:TreeMap | Tree map | |
#defaultView:Tree | Tree | |
#defaultView:Timeline | Timeline | |
#defaultView:Dimensions | Dimensions | |
#defaultView:Graph | Graph | |
#title: | title of the WDQS results frame | |
#view: | equivalent to prefix #defaultView: |
Auto language
When using the magic keyword [AUTO_LANGUAGE]
it is replaced by the users language when submitting the query. This allows writing a query with where the result is displayed in the users language.
Beispiel:
#<span lang="en" dir="ltr" class="mw-content-ltr">Use language of the user for display labels and fallback to english as default</span>
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
}
Auto coordinates
When using the magic keyword [AUTO_COORDINATES]
it is replaced by the users location when submitting the query (with clients accepting the geolocalization). This allows writing a query with the users' location.
Beispiel:
#defaultView:Map
SELECT ?place ?coordinate_location ?dist {
SERVICE wikibase:around {
?place wdt:P625 ?coordinate_location.
bd:serviceParam wikibase:center "[AUTO_COORDINATES]".
bd:serviceParam wikibase:radius "1".
bd:serviceParam wikibase:distance ?dist.
}
}