query-2f7f09dcce5af9ca5b4aab94a7f305d8

rq turtle/ttl

LineChart ]reply[02:15, 5 January 2020 (UTC)) talk (Dipsacus fullonumThe example code for a LineChart doesn't work. It gives StackOverflowError. I have rewritten it to this which seems to work. --

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:LineChart
SELECT ?country ?year ?population ?countryLabel
WHERE
{

{
    SELECT ?country ?year (avg(?populationValue) as ?population)
    WHERE
    {
          ?country wdt:P47 wd:Q183.
          ?country p:P1082 ?populationStatement.
          ?populationStatement ps:P1082 ?populationValue.
          ?populationStatement pq:P585 ?date.
          bind(str(YEAR(?date)) AS ?year)
    }
    group by ?country ?year
}
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?country"):::projected v4("?date") v6("?population"):::projected v2("?populationStatement") v3("?populationValue") v5("?year"):::projected c7(["bd:serviceParam"]):::iri c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q183"]):::iri v1 --"p:direct/P47"--> c2 v1 --"p:P1082"--> v2 v2 --"p:statement/P1082"--> v3 v2 --"p:qualifier/P585"--> v4 bind0[/"str(year-from-dateTime(?date))"/] v4 --o bind0 bind0 --as--o v5 bind2[/"average(?populationValue)"/] v3 --o bind2 bind2 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end