query-bf646367cdf2ba4a0d7ba5388c3657cf
Graph of databases linksHello hello, ) between video game databases and highlight the ones we link to. I got as far as the following, but the highlighting does not actually work. (P10568)maintains linking to I want to visualise the linkage (using − when I have done such graphs before I just SELECTed both ?item1 and ?item2 ; I saw that construct in the queries example and thought I would follow. BIND(IF(?toggle, ?item1, ?item2) AS ?item)Also, I’m not sure about the
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#defaultView:Graph
SELECT DISTINCT ?item ?itemLabel ?link ?rgb
WHERE {
{
SELECT DISTINCT ?item ?itemLabel ?link
WHERE {
VALUES ?toggle {
"true"^^xsd:boolean
"false"^^xsd:boolean
}
?item1 (wdt:P31/(wdt:P279*)) wd:Q55341040;
wdt:P10568 ?item2;
rdfs:label ?item1Label.
?item2 rdfs:label ?item2Label.
FILTER((LANG(?itemLabel)) = "en")
FILTER((LANG(?item2Label)) = "en")
# I saw that in the examples, no idea whether that’s really necessary instead of SELECTing ?item1 and ?item2
BIND(IF(?toggle, ?item1, ?item2) AS ?item)
BIND(IF(?toggle, ?item1Label, ?item2Label) AS ?itemLabel)
BIND(IF(?toggle, "", ?item1) AS ?link)
}
} OPTIONAL {
?item wdt:P1687 ?property.
}
# The idea is to highlight DBs linked from Wikidata, but that does not seem to work
BIND(IF(BOUND(?property),"FFA500","") AS ?rgb).
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?item"):::projected
v4("?item1")
v6("?item1Label")
v5("?item2")
v1("?item2Label")
v8("?itemLabel"):::projected
v8("?link"):::projected
v9("?property")
v10("?rgb"):::projected
v3("?toggle")
a1((" "))
c4(["wd:Q55341040"]):::iri
f0[["?item2Label = 'en'"]]
f0 --> v1
f1[["?itemLabel = 'en'"]]
f1 --> v8
bind2[/VALUES ?toggle/]
bind2-->v3
bind20(["true^^xsd:boolean"])
bind20 --> bind2
bind21(["false^^xsd:boolean"])
bind21 --> bind2
v4 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c4
v4 --"wdt:P10568"--> v5
v4 --"rdfs:label"--> v6
v5 --"rdfs:label"--> v1
bind3[/"if(?toggle,?item1,?item2)"/]
v3 --o bind3
v4 --o bind3
v5 --o bind3
bind3 --as--o v7
bind4[/"if(?toggle,?item1Label,?item2Label)"/]
v3 --o bind4
v6 --o bind4
v1 --o bind4
bind4 --as--o v8
bind5[/"if(?toggle,'',?item1)"/]
v3 --o bind5
v4 --o bind5
bind5 --as--o v8
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v7 -."wdt:P1687".-> v9
end
bind6[/"if(bound(?property),'FFA500','')"/]
v9 --o bind6
bind6 --as--o v10