map.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  1. // Raccatto i parametri dall'URL -- mi aspetto un parametro di nome 'link'!
  2. thisUrlParams = {};
  3. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  4. thisUrlParams[key] = value;
  5. });
  6. console.log('URL get params: ', thisUrlParams);
  7. // Funzioni per eseguire le queries
  8. function prepareQueryURL(query){
  9. sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/';
  10. sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?';
  11. return sparqlEndpoint + sparqlUrlParams;
  12. }
  13. function doJsonQuery(query){
  14. queryURL = prepareQueryURL(query);
  15. response = $.ajax({//OGGETTO
  16. url: queryURL,
  17. dataType: "json",
  18. success: function (data){},
  19. error: function (e) {}
  20. });
  21. return response;
  22. }
  23. // Funzioni per raccattare + stringhificare l'output
  24. queryStringOutput = "";
  25. function stringifyResponse(val){
  26. resultArray = val['results']['bindings'];
  27. out = "";
  28. for(i = 0; i < resultArray.length; i++){
  29. out = out + JSON.stringify(resultArray[i])
  30. }
  31. queryStringOutput = (queryStringOutput + out).replace("}{",",");
  32. }
  33. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  34. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  35. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/> \
  36. PREFIX owl: <http://www.w3.org/2002/07/owl#>"
  37. query = prefixes + " SELECT DISTINCT ?graph ?name_place ?coordinates {\
  38. GRAPH ?graph {<" + thisUrlParams.link + "> crm:P168_place_is_defined_by ?coordinates;\
  39. rdfs:label ?name_place .\
  40. }\
  41. }"
  42. queryRiferimenti = prefixes + " SELECT DISTINCT ?references {\
  43. <" + thisUrlParams.link + "> owl:sameAs ?references\
  44. }"
  45. queryToponimi = prefixes + " SELECT DISTINCT ?toponimi {\
  46. <" + thisUrlParams.link + "> crm:P1_is_identified_by ?uri_toponym .\
  47. ?uri_toponym rdfs:label ?toponimi\
  48. }"
  49. queryRicezione = prefixes + " SELECT DISTINCT ?object ?label {\
  50. <" + thisUrlParams.link + "> owl:sameAs ?place .\
  51. ?event_to crm:P26_moved_to ?place ;\
  52. rdf:type crm:EL3_Receive_Letter ;\
  53. rdfs:subClassOf ?event .\
  54. ?object crm:P25i_moved_by ?event ; \
  55. rdfs:label ?label .\
  56. } "
  57. queryInvio = prefixes + " SELECT DISTINCT ?object ?label {\
  58. <" + thisUrlParams.link + "> owl:sameAs ?place .\
  59. ?event_to crm:P27_moved_from ?place ;\
  60. rdf:type crm:EL2_Send_Letter ;\
  61. rdfs:subClassOf ?event .\
  62. ?object crm:P25i_moved_by ?event ; \
  63. rdfs:label ?label .\
  64. }"
  65. queryCitazione = prefixes + " SELECT DISTINCT ?object ?label\
  66. {<" + thisUrlParams.link + "> crm:P1_is_identified_by ?toponym .\
  67. ?object crm:P67_refers_to ?toponym ;\
  68. rdfs:label ?label\
  69. }"
  70. queryPersone = prefixes + " SELECT DISTINCT ?range ?label \
  71. WHERE{ \
  72. {?place owl:sameAs <" + thisUrlParams.link + "> .\
  73. ?event_to crm:P26_moved_to ?place ;\
  74. rdf:type crm:EL3_Receive_Letter ;\
  75. crm:P01_has_domain ?domain .\
  76. ?domain crm:P02_has_range ?range .\
  77. ?range rdfs:label ?label .\
  78. } UNION {\
  79. ?place owl:sameAs <" + thisUrlParams.link + "> .\
  80. ?event_to crm:P27_moved_from ?place ;\
  81. rdf:type crm:EL2_Send_Letter ;\
  82. crm:P01_has_domain ?domain .\
  83. ?domain crm:P02_has_range ?range .\
  84. ?range rdfs:label ?label .\
  85. }\
  86. }"
  87. queryCount = prefixes + " SELECT ?place ?label COUNT(?label) AS ?Count \
  88. WHERE{ \
  89. ?place_to owl:sameAs <" + thisUrlParams.link + "> . \
  90. ?event_to crm:P26_moved_to ?place_to ; \
  91. rdf:type crm:EL3_Receive_Letter ; \
  92. rdfs:subClassOf ?event . \
  93. ?event_from rdfs:subClassOf ?event ; \
  94. rdf:type crm:EL2_Send_Letter ; \
  95. crm:P27_moved_from ?place . \
  96. ?place rdfs:label ?label \
  97. } \
  98. ORDER BY DESC (?Count)"
  99. queryCount2 = prefixes + " SELECT ?place ?label COUNT(?label) AS ?Count \
  100. WHERE{ \
  101. ?place_from owl:sameAs <" + thisUrlParams.link + "> . \
  102. ?event_from crm:P27_moved_from ?place_from ; \
  103. rdf:type crm:EL2_Send_Letter ; \
  104. rdfs:subClassOf ?event . \
  105. ?event_to rdfs:subClassOf ?event ; \
  106. rdf:type crm:EL2_Send_Letter ; \
  107. crm:P27_moved_from ?place . \
  108. ?place rdfs:label ?label . \
  109. } \
  110. ORDER BY DESC (?Count) "
  111. queryCountLuogo = prefixes + " SELECT DISTINCT COUNT(?luogo) AS ?occorrenze \
  112. WHERE { \
  113. ?document crm:P67_refers_to ?luogo . \
  114. <" + thisUrlParams.link + "> crm:P1_is_identified_by ?luogo . \
  115. } "
  116. queryCountDataset = prefixes + " SELECT DISTINCT COUNT(?uri) AS ?documenti \
  117. WHERE {\
  118. ?uri crm:P2_has_type 'Testo Lemmatizzato' } "
  119. querySupportCount = prefixes + " SELECT ?uri_antroponym ?antroponimo COUNT(DISTINCT ?document) AS ?occorrenze COUNT(DISTINCT ?letter) AS ?count \
  120. WHERE { \
  121. ?document crm:P67_refers_to ?uri . \
  122. <" + thisUrlParams.link + "> crm:P1_is_identified_by ?uri . \
  123. ?document crm:P67_refers_to ?uri_antroponym . \
  124. ?uri_antroponym crm:P2_has_type 'Antroponimo'; \
  125. rdfs:label ?antroponimo . \
  126. ?letter crm:P67_refers_to ?uri_antroponym . \
  127. } \
  128. GROUP BY ?uri_antroponym ?antroponimo \
  129. ORDER BY DESC (?occorrenze) "
  130. /*
  131. queryCountAntroponym = SELECT DISTINCT ?antroponimi COUNT(?uri) AS ?occorrenze
  132. WHERE {
  133. ?document crm:P67_refers_to ?uri .
  134. ?uri crm:P2_has_type "Antroponimo" ;
  135. rdfs:label ?antroponimi .
  136. }
  137. GROUP BY ?antroponimi ?uri
  138. ORDER BY DESC (?occorrenze)
  139. queryCountLuogo = SELECT DISTINCT COUNT(?luogo) AS ?occorrenze
  140. WHERE {
  141. ?document crm:P67_refers_to ?luogo .
  142. <http://dev.restore.ovi.cnr.it/vocabularies/places/161> crm:P1_is_identified_by ?luogo .
  143. }
  144. queryCountDataset = SELECT DISTINCT COUNT(?uri) AS ?documenti
  145. WHERE {
  146. ?uri crm:P2_has_type "Testo Lemmatizzato" }
  147. querySupportCount = SELECT DISTINCT ?uri_antroponym ?antroponimo COUNT(?antroponimo) AS ?occorrenze
  148. WHERE {
  149. ?document crm:P67_refers_to ?uri .
  150. <http://dev.restore.ovi.cnr.it/vocabularies/places/257> crm:P1_is_identified_by ?uri .
  151. ?document crm:P67_refers_to ?uri_antroponym .
  152. ?uri_antroponym crm:P2_has_type "Antroponimo";
  153. rdfs:label ?antroponimo .
  154. }
  155. GROUP BY ?uri_antroponym ?antroponimo
  156. ORDER BY DESC (?occorrenze)
  157. */
  158. queryURL = prepareQueryURL(query);
  159. queryRef = prepareQueryURL(queryRiferimenti);
  160. queryTopo = prepareQueryURL(queryToponimi);
  161. queryRec = prepareQueryURL(queryRicezione);
  162. querySend = prepareQueryURL(queryInvio);
  163. queryCit = prepareQueryURL(queryCitazione);
  164. queryPer = prepareQueryURL(queryPersone);
  165. queryCon1 = prepareQueryURL(queryCount);
  166. queryCon2 = prepareQueryURL(queryCount2);
  167. queryDataset = prepareQueryURL(queryCountDataset);
  168. querySup = prepareQueryURL(querySupportCount);
  169. queryOcc = prepareQueryURL(queryCountLuogo);
  170. response = $.ajax({//OGGETTO
  171. url: queryURL,
  172. dataType: "json",
  173. success: function (data){
  174. handle_data(data);
  175. },
  176. error: function (e) {}
  177. });
  178. response_ref = $.ajax({//OGGETTO
  179. url: queryRef,
  180. dataType: "json",
  181. success: function (data){
  182. handle_ref(data);
  183. },
  184. error: function (e) {}
  185. });
  186. response_top = $.ajax({//OGGETTO
  187. url: queryTopo,
  188. dataType: "json",
  189. success: function (data){
  190. handle_toponym(data);
  191. },
  192. error: function (e) {}
  193. });
  194. response_receive = $.ajax({//OGGETTO
  195. url: queryRec,
  196. dataType: "json",
  197. success: function (data){
  198. handle_receive(data);
  199. },
  200. error: function (e) {}
  201. });
  202. response_send = $.ajax({//OGGETTO
  203. url: querySend,
  204. dataType: "json",
  205. success: function (data){
  206. handle_send(data);
  207. },
  208. error: function (e) {}
  209. });
  210. response_cit = $.ajax({//OGGETTO
  211. url: queryCit,
  212. dataType: "json",
  213. success: function (data){
  214. handle_cit(data);
  215. },
  216. error: function (e) {}
  217. });
  218. response_per = $.ajax({//OGGETTO
  219. url: queryPer,
  220. dataType: "json",
  221. success: function (data){
  222. handle_persons(data);
  223. },
  224. error: function (e) {}
  225. });
  226. responseCountA = $.ajax({//OGGETTO
  227. url: queryCon1,
  228. dataType: "json",
  229. success: function (data){
  230. handle_count(data);
  231. },
  232. error: function (e) {}
  233. });
  234. responseCountP = $.ajax({//OGGETTO
  235. url: queryCon2,
  236. dataType: "json",
  237. success: function (data){
  238. handle_count2(data);
  239. },
  240. error: function (e) {}
  241. });
  242. responseDataset = $.ajax({//OGGETTO
  243. url: queryDataset,
  244. dataType: "json",
  245. success: function (data){
  246. get_dataset(data);
  247. },
  248. error: function (e) {}
  249. });
  250. responseOcc = $.ajax({//OGGETTO
  251. url: queryOcc,
  252. dataType: "json",
  253. success: function (data){
  254. get_occurrence(data);
  255. },
  256. error: function (e) {}
  257. });
  258. responseSupp = $.ajax({//OGGETTO
  259. url: querySup,
  260. dataType: "json",
  261. success: function (data){
  262. get_support(data);
  263. },
  264. error: function (e) {}
  265. });
  266. function handle_data(json) {
  267. console.log(json);
  268. const locations = [];
  269. $.each(
  270. json['results']['bindings'],
  271. function (index, value) {
  272. const loc = []
  273. var graph = value['graph']['value'];
  274. var label = value['name_place']['value'];
  275. var coord = value['coordinates']['value'];
  276. const coordinates = coord.split(", ");
  277. loc.push(label);
  278. loc.push(coordinates[0]);
  279. loc.push(coordinates[1]);
  280. locations.push(loc);
  281. document.getElementById("grafo").innerHTML = graph;
  282. document.getElementById("nome_luogo").innerHTML = label;
  283. document.getElementById("nome_lu").innerHTML = label;
  284. document.getElementById("nome_lp").innerHTML = label;
  285. document.getElementById("nome_ll").innerHTML = label;
  286. document.getElementById("nome_lg").innerHTML = label;
  287. document.getElementById("nome_st1").innerHTML = label;
  288. document.getElementById("nome_st2").innerHTML = label;
  289. document.getElementById("nome_ass1").innerHTML = label;
  290. document.getElementById("nome_ass2").innerHTML = label;
  291. });
  292. var map = L.map('map').setView([locations[0][1], locations[0][2]], 7);
  293. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  294. L.tileLayer(
  295. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  296. attribution: '&copy; ' + mapLink + ' Contributors',
  297. maxZoom: 18,
  298. }).addTo(map);
  299. for (var i = 0; i < locations.length; i++) {
  300. marker = new L.marker([locations[i][1], locations[i][2]])
  301. .bindPopup(locations[i][0])
  302. .addTo(map);
  303. }
  304. }
  305. function handle_ref(json) {
  306. console.log(json);
  307. const references = [];
  308. var list_ref = "";
  309. $.each(
  310. json['results']['bindings'],
  311. function (index, value) {
  312. var ref = value['references']['value'];
  313. references.push(ref);
  314. });
  315. for (i=0; i<references.length; i++) {
  316. list_ref += "<div class='row'><div class='col'><a href='" + references[i] + "'>" + references[i] + "</a></div></div>";
  317. }
  318. document.getElementById("riferimenti").innerHTML = list_ref;
  319. }
  320. function handle_toponym(json) {
  321. console.log(json);
  322. const toponym = [];
  323. $.each(
  324. json['results']['bindings'],
  325. function (index, value) {
  326. var topo = value['toponimi']['value'];
  327. toponym.push(" " + topo);
  328. });
  329. document.getElementById("toponimi").innerHTML = toponym;
  330. }
  331. function handle_receive(json) {
  332. console.log(json);
  333. const received = {};
  334. var i=0;
  335. $.each(
  336. json['results']['bindings'],
  337. function (index, value) {
  338. key = value['object']['value'];
  339. data = value['label']['value'];
  340. received[key] = data;
  341. i++;
  342. });
  343. var myArray = "";
  344. for (var key in received) {
  345. myArray += "<div class='row'><div class='col-10'>" + received[key] + "</div><div class='col'><a href='" + key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
  346. }
  347. document.getElementById("n_receive").innerHTML = i;
  348. document.getElementById("object_receive").innerHTML = myArray;
  349. if (i==0) {
  350. var messaggio = "<p>Nessun risultato trovato</p>";
  351. document.getElementById("object_receive").innerHTML = messaggio;
  352. }
  353. }
  354. function handle_send(json) {
  355. console.log(json);
  356. const sent = {};
  357. var i=0;
  358. $.each(
  359. json['results']['bindings'],
  360. function (index, value) {
  361. key = value['object']['value'];
  362. data = value['label']['value'];
  363. sent[key] = data;
  364. i++;
  365. });
  366. var myArray = "";
  367. for (var key in sent) {
  368. myArray += "<div class='row'><div class='col-10'>" + sent[key] + "</div><div class='col'><a href='" + key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
  369. }
  370. document.getElementById("n_send").innerHTML = i;
  371. document.getElementById("object_send").innerHTML = myArray;
  372. if (i==0) {
  373. var messaggio = "<p>Nessun risultato trovato</p>";
  374. document.getElementById("object_send").innerHTML = messaggio;
  375. }
  376. }
  377. function handle_cit(json) {
  378. console.log(json);
  379. const citations = {};
  380. var i=0;
  381. $.each(
  382. json['results']['bindings'],
  383. function (index, value) {
  384. key = value['object']['value'];
  385. data = value['label']['value'];
  386. citations[key] = data;
  387. i++;
  388. });
  389. var myArray = "";
  390. for (var key in citations) {
  391. myArray += "<div class='row'><div class='col-10'>" + citations[key] + "</div><div class='col'><a href='" + key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
  392. }
  393. document.getElementById("n_cit").innerHTML = i;
  394. document.getElementById("object_cit").innerHTML = myArray;
  395. if (i==0) {
  396. var messaggio = "<p>Nessun risultato trovato</p>";
  397. document.getElementById("object_cit").innerHTML = messaggio;
  398. }
  399. }
  400. function handle_persons(json) {
  401. console.log(json);
  402. const people = {};
  403. var i=0;
  404. $.each(
  405. json['results']['bindings'],
  406. function (index, value) {
  407. key = value['range']['value'];
  408. data = value['label']['value'];
  409. people[key] = data;
  410. i++;
  411. });
  412. var myArray = "";
  413. for (var key in people) {
  414. myArray += "<div class='row'><div class='col-9'>" + people[key] + "</div><div class='persona col' id='" +
  415. key + "'><i class='fa fa-user'></i></div><div class='col'><a href='" +
  416. key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
  417. }
  418. document.getElementById("n_per").innerHTML = i;
  419. document.getElementById("object_per").innerHTML = myArray;
  420. if (i==0) {
  421. var messaggio = "<p>Nessun risultato trovato</p>";
  422. document.getElementById("object_per").innerHTML = messaggio;
  423. }
  424. }
  425. function handle_count(json) {
  426. console.log(json);
  427. const toponimi = [];
  428. const dataToponimi = [];
  429. var max = 0;
  430. $.each(
  431. json['results']['bindings'],
  432. function (index, value) {
  433. const topo = [];
  434. var toponimo = value['label']['value'];
  435. var count = value['Count']['value'];
  436. var temp = parseInt(count);
  437. toponimi.push(toponimo);
  438. dataToponimi.push([toponimo, count]);
  439. if (temp>max) {
  440. max = temp;
  441. }
  442. });
  443. // set the dimensions and margins of the graph
  444. var margin = {top: 20, right: 30, bottom: 40, left: 90},
  445. width = 460 - margin.left - margin.right,
  446. height = 400 - margin.top - margin.bottom;
  447. // append the svg object to the body of the page
  448. var svg = d3.select("#my_dataviz")
  449. .append("svg")
  450. .attr("width", width + margin.left + margin.right)
  451. .attr("height", height + margin.top + margin.bottom)
  452. .append("g")
  453. .attr("transform",
  454. "translate(" + margin.left + "," + margin.top + ")");
  455. // Parse the Data
  456. //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
  457. // Add X axis
  458. var x = d3.scaleLinear()
  459. .domain([0, max])
  460. .range([ 0, width]);
  461. svg.append("g")
  462. .attr("transform", "translate(0," + height + ")")
  463. .call(d3.axisBottom(x))
  464. .selectAll("text")
  465. .attr("transform", "translate(-10,0)rotate(-45)")
  466. .style("text-anchor", "end");
  467. // Y axis
  468. var y = d3.scaleBand()
  469. .range([ 0, height ])
  470. .domain(toponimi)
  471. .padding(.1);
  472. svg.append("g")
  473. .call(d3.axisLeft(y))
  474. //Bars
  475. svg.selectAll("myRect")
  476. .data(dataToponimi)
  477. .enter()
  478. .append("rect")
  479. .attr("x", x(0) )
  480. .attr("y", function(d) { return y(d[0]); })
  481. .attr("width", function(d) { return x(d[1]); })
  482. .attr("height", y.bandwidth() )
  483. .attr("fill", "#69b3a2")
  484. /*var texts = svg.selectAll("myRect")
  485. .data(dataToponimi)
  486. .enter()
  487. .append("text");
  488. texts.attr("x", function(d){ return d[1] / 4 - 20})
  489. .attr("y", function(d,i){ return 22.26*i +20})
  490. .attr("text-anchor", "middle")
  491. .attr("fill", "#fff")
  492. .text(function(d){ return d[1]});*/
  493. }
  494. function handle_count2(json) {
  495. console.log(json);
  496. const toponimi = [];
  497. const dataToponimi = [];
  498. const values = [];
  499. var max = 0;
  500. $.each(
  501. json['results']['bindings'],
  502. function (index, value) {
  503. const topo = [];
  504. var toponimo = value['label']['value'];
  505. var count = value['Count']['value'];
  506. var temp = parseInt(count);
  507. toponimi.push(toponimo);
  508. dataToponimi.push([toponimo, count]);
  509. if (temp>max) {
  510. max = temp;
  511. }
  512. });
  513. // set the dimensions and margins of the graph
  514. var margin = {top: 20, right: 30, bottom: 40, left: 90},
  515. width = 460 - margin.left - margin.right,
  516. height = 400 - margin.top - margin.bottom;
  517. // append the svg object to the body of the page
  518. var svg = d3.select("#my_dataviz2")
  519. .append("svg")
  520. .attr("width", width + margin.left + margin.right)
  521. .attr("height", height + margin.top + margin.bottom)
  522. .append("g")
  523. .attr("transform",
  524. "translate(" + margin.left + "," + margin.top + ")");
  525. // Parse the Data
  526. //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
  527. // Add X axis
  528. var x = d3.scaleLinear()
  529. .domain([0, max])
  530. .range([ 0, width]);
  531. svg.append("g")
  532. .attr("transform", "translate(0," + height + ")")
  533. .call(d3.axisBottom(x))
  534. .selectAll("text")
  535. .attr("transform", "translate(-10,0)rotate(-45)")
  536. .style("text-anchor", "end");
  537. // Y axis
  538. var y = d3.scaleBand()
  539. .range([ 0, height ])
  540. .domain(toponimi)
  541. .padding(.1);
  542. svg.append("g")
  543. .call(d3.axisLeft(y))
  544. //Bars
  545. svg.selectAll("myRect")
  546. .data(dataToponimi)
  547. .enter()
  548. .append("rect")
  549. .attr("x", x(0) )
  550. .attr("y", function(d) { return y(d[0]); })
  551. .attr("width", function(d) { return x(d[1]); })
  552. .attr("height", y.bandwidth() )
  553. .attr("fill", "#69b3a2")
  554. svg.selectAll("text2")
  555. .data(dataToponimi)
  556. .enter().append("text2")
  557. .text(function(d) {return d[1]})
  558. .attr("class", "text")
  559. }
  560. function get_dataset(json) {
  561. console.log(json);
  562. data = json.results.bindings[0].documenti.value;
  563. console.log(data);
  564. }
  565. function get_occurrence(json) {
  566. }
  567. function get_support(json) {
  568. }
  569. function open_info() {
  570. document.getElementById("info_luogo").style.display = "block";
  571. document.getElementById("place_info").style.display = "block";
  572. document.getElementById("topo").style.display = "none";
  573. document.getElementById("rif").style.display = "none";
  574. }
  575. function open_toponimi() {
  576. document.getElementById("info_luogo").style.display = "block";
  577. document.getElementById("place_info").style.display = "none";
  578. document.getElementById("topo").style.display = "block";
  579. document.getElementById("rif").style.display = "none";
  580. }
  581. function open_riferimenti() {
  582. document.getElementById("info_luogo").style.display = "block";
  583. document.getElementById("place_info").style.display = "none";
  584. document.getElementById("topo").style.display = "none";
  585. document.getElementById("rif").style.display = "block";
  586. }
  587. function open_collegamenti() {
  588. document.getElementById("references").style.display = "flex";
  589. document.getElementById("statistiche").style.display = "none";
  590. document.getElementById("regole_associazione").style.display = "none";
  591. }
  592. function open_statistiche() {
  593. document.getElementById("references").style.display = "none";
  594. document.getElementById("statistiche").style.display = "flex";
  595. document.getElementById("regole_associazione").style.display = "none";
  596. }
  597. function open_correlazioni() {
  598. document.getElementById("references").style.display = "none";
  599. document.getElementById("statistiche").style.display = "none";
  600. document.getElementById("regole_associazione").style.display = "flex";
  601. }
  602. var header = document.getElementById("ref_buttons");
  603. var btns = header.getElementsByClassName("btn");
  604. for (var i = 0; i < btns.length; i++) {
  605. btns[i].addEventListener("click", function() {
  606. var current = document.getElementsByClassName("active");
  607. current[0].className = current[0].className.replace(" active", "");
  608. this.className += " active";
  609. });
  610. }
  611. //out = "";
  612. //for(i = 0; i < resultArray.length; i++){
  613. // out = out + JSON.stringify(resultArray[i])
  614. //}
  615. //queryStringOutput = (queryStringOutput + out).replace("}{",",");
  616. /*
  617. var locations = [
  618. ["LOCATION_1", 11.8166, 122.0942],
  619. ["LOCATION_2", 11.9804, 121.9189],
  620. ["LOCATION_3", 10.7202, 122.5621],
  621. ["LOCATION_4", 11.3889, 122.6277],
  622. ["LOCATION_5", 10.5929, 122.6325]
  623. ];
  624. var map = L.map('map').setView([11.206051, 122.447886], 8);
  625. mapLink =
  626. '<a href="http://openstreetmap.org">OpenStreetMap</a>';
  627. L.tileLayer(
  628. 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  629. attribution: '&copy; ' + mapLink + ' Contributors',
  630. maxZoom: 18,
  631. }).addTo(map);
  632. for (var i = 0; i < locations.length; i++) {
  633. marker = new L.marker([locations[i][1], locations[i][2]])
  634. .bindPopup(locations[i][0])
  635. .addTo(map);
  636. }
  637. */
  638. $(document).on("click", ".persona", function (ev) {
  639. var link = this.id;
  640. //alert(nome_autore);
  641. //$('#myModal').text("");
  642. window.open("Persona.html?link="+this.id);
  643. });