query-4f62734661f9ef74a757e554bfc1444b
TODO
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 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#>
#Map showing percentage of vote received by CPI(M) in 2014 Indian General Election
#Credit: Mahir256
#defaultView:Map{"hide": ["?rgb", "?shape"]}
SELECT ?const ?ecicode ?constLabel ?turnout ?shape ?rgb {
?const wdt:P31/wdt:P279* wd:Q47481352.
?const p:P6871 ?codestmt . ?codestmt ps:P6871 ?ecicode ; pq:P805 wd:Q3587169.
?const wdt:P3896 ?shape .
?election14 wdt:P1001 ?const ; wdt:P361/wdt:P361* wd:Q3587169 ;
wdt:P1868 ?ballots.
OPTIONAL { ?election14 p:P726 ?cstmt. ?cstmt pq:P1111 ?turnout14 ; pq:P102 wd:Q234277. }
BIND(IF(BOUND(?turnout14),(?turnout14 / ?ballots)*100,-1) AS ?turnout)
BIND(IF(?turnout = -1,"7f7f7f",
IF(?turnout > 20,IF(?turnout > 25,IF(?turnout > 30,'b22222','cd5c5c'),'f08080'),'ffa07a')
) AS ?rgb).
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;
v6("?ballots")
v2("?codestmt")
v1("?const"):::projected
v7("?cstmt")
v3("?ecicode"):::projected
v5("?election14")
v10("?rgb"):::projected
v4("?shape"):::projected
v9("?turnout"):::projected
v8("?turnout14")
a1((" "))
a2((" "))
c15(["wd:Q234277"]):::iri
c3(["wd:Q47481352"]):::iri
c17(["bd:serviceParam"]):::iri
c19(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c7(["wd:Q3587169"]):::iri
v1 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c3
v1 --"p:P6871"--> v2
v2 --"p:statement/P6871"--> v3
v2 --"p:qualifier/P805"--> c7
v1 --"p:direct/P3896"--> v4
v5 --"p:direct/P1001"--> v1
v5 --"p:direct/P361"--> a2
a2 --"p:direct/P361"--> c7
v5 --"p:direct/P1868"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:P726".-> v7
v7 --"p:qualifier/P1111"--> v8
v7 --"p:qualifier/P102"--> c15
end
bind0[/"if(bound(?turnout14),?turnout14 / ?ballots * '100^^xsd:integer','-1^^xsd:integer')"/]
v8 --o bind0
v6 --o bind0
bind0 --as--o v9
bind1[/"if(?turnout = '-1^^xsd:integer','7f7f7f',if(?turnout > '20^^xsd:integer',if(?turnout > '25^^xsd:integer',if(?turnout > '30^^xsd:integer','b22222','cd5c5c'),'f08080'),'ffa07a'))"/]
v9 --o bind1
bind1 --as--o v10
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c17 --"wikibase:language"--> c19
end