query-d0ecdf7057153289be1640bd7d4eb729
BarChart failI've failed to grok bar charts. Here's the Age of Actors query from above, which now returns two rows per year of age, one with a count of male and the other a count of female actors. I'm wanting a bar chart with age on the x-axis, bars for the count of male and female actors for each age, and a legend saying Male/Female. Instead I get a couple of dots and a raspberry. Pointers please.
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
#defaultView:BarChart
SELECT ?age (count(?age) as ?count) ?Label WHERE {
?actor p:P569/psv:P569 [ wikibase:timePrecision ?tp; wikibase:timeValue ?dob ].
FILTER(?tp>8)
?actor wdt:P21 ?genre .
?actor wdt:P106/wdt:P279* wd:Q33999 . #include subclasses of "actors" such as "child actors"
?actor wdt:P27 wd:Q142 .
?movie wdt:P161 ?actor .
?movie wdt:P577 ?dateMovie .
BIND(YEAR(?dateMovie)-YEAR(?dob) as ?age) .
BIND(if(?genre=wd:Q6581072,"female","male") as ?Label)
FILTER(?age > 0) .
FILTER(?age < 100) .
}
GROUP BY ?age ?Label
ORDER BY ?age ?Label
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?Label"):::projected
v5("?actor")
v9("?age"):::projected
v9("?count")
v8("?dateMovie")
v4("?dob")
v6("?genre")
v7("?movie")
v3("?tp")
a2((" "))
a1((" "))
a3((" "))
c11(["wd:Q33999"]):::iri
c13(["wd:Q142"]):::iri
f0[["?age < '100^^xsd:integer'"]]
f0 --> v9
f1[["?age > '0^^xsd:integer'"]]
f1 --> v9
f2[["?tp > '8^^xsd:integer'"]]
f2 --> v3
a1 --"wikibase:timePrecision"--> v3
a1 --"wikibase:timeValue"--> v4
v5 --"p:P569"--> a2
a2 --"p:statement/value/P569"--> a1
v5 --"p:direct/P21"--> v6
v5 --"p:direct/P106"--> a3
a3 --"p:direct/P279"--> c11
v5 --"p:direct/P27"--> c13
v7 --"p:direct/P161"--> v5
v7 --"p:direct/P577"--> v8
bind3[/"year-from-dateTime(?dateMovie) - year-from-dateTime(?dob)"/]
v8 --o bind3
v4 --o bind3
bind3 --as--o v9
bind4[/"if(?genre = 'wd:Q6581072','female','male')"/]
v6 --o bind4
bind4 --as--o v9
bind6[/"count(?age)"/]
v9 --o bind6
bind6 --as--o v9