Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enter code here<script type="text/javascript">
- var endpoint = "http://sws.ifi.uio.no/sparql/world";
- var query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>PREFIX owl: <http://www.w3.org/2002/07/owl#>PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>PREFIX w: <http://sws.ifi.uio.no/ont/world.owl#>PREFIX dbpo: <http://dbpedia.org/ontology/>PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>PREFIX dct: <http://purl.org/dc/terms/>PREFIX fn: <http://www.w3.org/2005/xpath-functions#>PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>PREFIX npdv: <http://sws.ifi.uio.no/vocab/npd#>PREFIX npdv2: <http://sws.ifi.uio.no/vocab/npd-v2#>PREFIX geos: <http://www.opengis.net/ont/geosparql#>SELECT * WHERE{ [] a w:Country ; w:hasName ?Name ; w:hasCountryPopulation ?Population ; } ORDER BY DESC(?Population) LIMIT 10" ;
- var endpoint = "http://sws.ifi.uio.no/sparql/world";
- var query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>PREFIX owl: <http://www.w3.org/2002/07/owl#>PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>PREFIX w: <http://sws.ifi.uio.no/ont/world.owl#>PREFIX dbpo: <http://dbpedia.org/ontology/>PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>PREFIX dct: <http://purl.org/dc/terms/>PREFIX fn: <http://www.w3.org/2005/xpath-functions#>PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>PREFIX npdv: <http://sws.ifi.uio.no/vocab/npd#>PREFIX npdv2: <http://sws.ifi.uio.no/vocab/npd-v2#>PREFIX geos: <http://www.opengis.net/ont/geosparql#>SELECT * WHERE{ [] a w:City ; w:hasName ?Name ; w:hasCityPopulation ?Population ; } ORDER BY DESC(?Population) LIMIT 10";
- var resultArray = ['test'];
- // Define a callback function to receive the SPARQL JSON result.
- function myCallback(str) {
- // Convert result to JSON
- var jsonObj = eval('(' + str + ')');
- // Build up an array of results.
- resultArray = new Array();
- resultArray[0] = jsonObj.head.vars;
- for(var i = 0; i < jsonObj.results.bindings.length; i++) {
- resultArray[i+1] = new Array();
- resultArray[i+1][0] = jsonObj.results.bindings[i].Name.value;
- resultArray[i+1][1] = jsonObj.results.bindings[i].Population.value / 1000;
- }
- }
- // Make the query.
- sparqlQueryJson(query, endpoint, myCallback, false);
- google.load("visualization", "1", {packages:["corechart"]});
- function drawChart() {
- var item = document.getElementById('selQuery').value;
- var item2 = document.getElementById('graphs').value;
- if (item == 'query1')
- {
- var endpoint = "http://sws.ifi.uio.no/sparql/world";
- var query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>PREFIX owl: <http://www.w3.org/2002/07/owl#>PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>PREFIX w: <http://sws.ifi.uio.no/ont/world.owl#>PREFIX dbpo: <http://dbpedia.org/ontology/>PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>PREFIX dct: <http://purl.org/dc/terms/>PREFIX fn: <http://www.w3.org/2005/xpath-functions#>PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>PREFIX npdv: <http://sws.ifi.uio.no/vocab/npd#>PREFIX npdv2: <http://sws.ifi.uio.no/vocab/npd-v2#>PREFIX geos: <http://www.opengis.net/ont/geosparql#>SELECT * WHERE{ [] a w:Country ; w:hasName ?Name ; w:hasCountryPopulation ?Population ; } ORDER BY DESC(?Population) LIMIT 10" ;
- sparqlQueryJson(query, endpoint, myCallback, false);
- var data = google.visualization.arrayToDataTable(resultArray);
- var options = {
- title: document.selectionForm.graphName.value,
- hAxis: {title: 'Note: All Values are in thousands', titleTextStyle: {color: 'red'}}
- };
- if (item2 == 'bar'){
- var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
- chart.draw(data, options);}
- else if (item2 == 'pie'){
- var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
- chart.draw(data, options);
- }
- else if (item2 == 'column'){
- var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
- chart.draw(data, options);
- }
- }
- else if (item == 'query2')
- {
- var data = google.visualization.arrayToDataTable(resultArray);
- var options = {
- title: document.selectionForm.graphName.value,
- hAxis: {title: 'Note: All Values are in thousands', titleTextStyle: {color: 'red'}}
- };
- if (item2 == 'bar'){
- var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
- chart.draw(data, options);}
- else if (item2 == 'pie'){
- var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
- chart.draw(data, options);
- }
- else if (item2 == 'column'){
- var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
- chart.draw(data, options);
- }
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement