If I run this SPARQL query
#defaultView:BubbleChart
#TEMPLATE={"template":"Overall causes of death ranking of ?thing ","variables":{"?thing": {"query":"SELECT ?id (COUNT(?id) AS ?count) WHERE { ?sub wdt:P509 ?y. ?sub wdt:P31 ?id. } GROUP BY ?id "} } }
SELECT ?cid ?cause (COUNT(*) AS ?count) WHERE {
BIND(wd:Q5 AS ?thing)
?pid wdt:P31 ?thing.
?pid wdt:P509 ?cid.
OPTIONAL {
?cid rdfs:label ?cause.
FILTER((LANG(?cause)) = "en")
}
}
GROUP BY ?cid ?cause
ORDER BY DESC(?count) ?cause
LIMIT 50
in the Wikidata Query Editor, I have the option to download the bubblechart as an SVG file using the menu Download > SVG Image
I am looking for a way to generate or retrieve the URL to this SVG file when I execute the same SPARQL script programatically. In that case, only the raw data is returned (as JSON).
{ "head" : { "vars" : [ "cid", "cause", "count" ] }, "results" : { "bindings" : [ { "cid" : { "type" : "uri", "value" : "http://www.wikidata.org/entity/Q12152" }, "cause" : { "xml:lang" : "en", "type" : "literal", "value" : "myocardial infarction" }, "count" : { "datatype" : "http://www.w3.org/2001/XMLSchema#integer", "type" : "literal", "value" : "5837" } }, { "cid" : { "type" : "uri", "value" : "http://www.wikidata.org/entity/Q12192" }, "cause" : { "xml:lang" : "en", "type" : "literal", "value" : "pneumonia" }, "count" : { "datatype" : "http://www.w3.org/2001/XMLSchema#integer", "type" : "literal", "value" : "2177" }.... etc
There's no URL to this SVG because it is generated by the Javascript running in the browser after retrieving JSON results. If you want to get it programmatically, I think using browser automation to run the Javascript code and obtain the file using simulated user actions would be the quickest way to achieve it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With