map.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  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. querySupportLemma = prefixes + " SELECT ?uri_lemma ?lemma COUNT(DISTINCT ?document) AS ?occorrenze COUNT(DISTINCT ?letter) AS ?count \
  131. WHERE { \
  132. ?document crm:P67_refers_to ?uri . \
  133. <" + thisUrlParams.link + "> crm:P1_is_identified_by ?uri . \
  134. ?document crm:P67_refers_to ?uri_object . \
  135. ?uri_object crm:P128_carries ?uri_lemma . \
  136. ?uri_lemma rdf:type ?uri_type; \
  137. rdfs:label ?lemma . \
  138. ?uri_type rdfs:label 'Lemma' . \
  139. ?letter crm:P67_refers_to ?uri_object . \
  140. } \
  141. GROUP BY ?uri_lemma ?lemma \
  142. ORDER BY DESC (?occorrenze) "
  143. /*
  144. queryCountAntroponym = SELECT DISTINCT ?antroponimi COUNT(?uri) AS ?occorrenze
  145. WHERE {
  146. ?document crm:P67_refers_to ?uri .
  147. ?uri crm:P2_has_type "Antroponimo" ;
  148. rdfs:label ?antroponimi .
  149. }
  150. GROUP BY ?antroponimi ?uri
  151. ORDER BY DESC (?occorrenze)
  152. queryCountLuogo = SELECT DISTINCT COUNT(?luogo) AS ?occorrenze
  153. WHERE {
  154. ?document crm:P67_refers_to ?luogo .
  155. <http://dev.restore.ovi.cnr.it/vocabularies/places/161> crm:P1_is_identified_by ?luogo .
  156. }
  157. queryCountDataset = SELECT DISTINCT COUNT(?uri) AS ?documenti
  158. WHERE {
  159. ?uri crm:P2_has_type "Testo Lemmatizzato" }
  160. querySupportCount = SELECT DISTINCT ?uri_antroponym ?antroponimo COUNT(?antroponimo) AS ?occorrenze
  161. WHERE {
  162. ?document crm:P67_refers_to ?uri .
  163. <http://dev.restore.ovi.cnr.it/vocabularies/places/257> crm:P1_is_identified_by ?uri .
  164. ?document crm:P67_refers_to ?uri_antroponym .
  165. ?uri_antroponym crm:P2_has_type "Antroponimo";
  166. rdfs:label ?antroponimo .
  167. }
  168. GROUP BY ?uri_antroponym ?antroponimo
  169. ORDER BY DESC (?occorrenze)
  170. */
  171. queryURL = prepareQueryURL(query);
  172. queryRef = prepareQueryURL(queryRiferimenti);
  173. queryTopo = prepareQueryURL(queryToponimi);
  174. queryRec = prepareQueryURL(queryRicezione);
  175. querySend = prepareQueryURL(queryInvio);
  176. queryCit = prepareQueryURL(queryCitazione);
  177. queryPer = prepareQueryURL(queryPersone);
  178. queryCon1 = prepareQueryURL(queryCount);
  179. queryCon2 = prepareQueryURL(queryCount2);
  180. queryDataset = prepareQueryURL(queryCountDataset);
  181. querySup = prepareQueryURL(querySupportCount);
  182. queryLem = prepareQueryURL(querySupportLemma);
  183. queryOcc = prepareQueryURL(queryCountLuogo);
  184. response = $.ajax({//OGGETTO
  185. url: queryURL,
  186. dataType: "json",
  187. success: function (data){
  188. handle_data(data);
  189. },
  190. error: function (e) {}
  191. });
  192. response_ref = $.ajax({//OGGETTO
  193. url: queryRef,
  194. dataType: "json",
  195. success: function (data){
  196. handle_ref(data);
  197. },
  198. error: function (e) {}
  199. });
  200. response_top = $.ajax({//OGGETTO
  201. url: queryTopo,
  202. dataType: "json",
  203. success: function (data){
  204. handle_toponym(data);
  205. },
  206. error: function (e) {}
  207. });
  208. response_receive = $.ajax({//OGGETTO
  209. url: queryRec,
  210. dataType: "json",
  211. success: function (data){
  212. handle_receive(data);
  213. },
  214. error: function (e) {}
  215. });
  216. response_send = $.ajax({//OGGETTO
  217. url: querySend,
  218. dataType: "json",
  219. success: function (data){
  220. handle_send(data);
  221. },
  222. error: function (e) {}
  223. });
  224. response_cit = $.ajax({//OGGETTO
  225. url: queryCit,
  226. dataType: "json",
  227. success: function (data){
  228. handle_cit(data);
  229. },
  230. error: function (e) {}
  231. });
  232. response_per = $.ajax({//OGGETTO
  233. url: queryPer,
  234. dataType: "json",
  235. success: function (data){
  236. handle_persons(data);
  237. },
  238. error: function (e) {}
  239. });
  240. responseCountA = $.ajax({//OGGETTO
  241. url: queryCon1,
  242. dataType: "json",
  243. success: function (data){
  244. handle_count(data);
  245. },
  246. error: function (e) {}
  247. });
  248. responseCountP = $.ajax({//OGGETTO
  249. url: queryCon2,
  250. dataType: "json",
  251. success: function (data){
  252. handle_count2(data);
  253. },
  254. error: function (e) {}
  255. });
  256. responseDataset = $.ajax({//OGGETTO
  257. url: queryDataset,
  258. dataType: "json",
  259. success: function (data){
  260. get_dataset(data);
  261. },
  262. error: function (e) {}
  263. });
  264. responseOcc = $.ajax({//OGGETTO
  265. url: queryOcc,
  266. dataType: "json",
  267. success: function (data){
  268. get_occurrence(data);
  269. },
  270. error: function (e) {}
  271. });
  272. responseSupp = $.ajax({//OGGETTO
  273. url: querySup,
  274. dataType: "json",
  275. success: function (data){
  276. get_support(data);
  277. },
  278. error: function (e) {}
  279. });
  280. responseLemm = $.ajax({//OGGETTO
  281. url: queryLem,
  282. dataType: "json",
  283. success: function (data){
  284. get_support(data);
  285. },
  286. error: function (e) {}
  287. });
  288. function handle_data(json) {
  289. console.log(json);
  290. const locations = [];
  291. $.each(
  292. json['results']['bindings'],
  293. function (index, value) {
  294. const loc = []
  295. var graph = value['graph']['value'];
  296. var label = value['name_place']['value'];
  297. var coord = value['coordinates']['value'];
  298. const coordinates = coord.split(", ");
  299. loc.push(label);
  300. loc.push(coordinates[0]);
  301. loc.push(coordinates[1]);
  302. locations.push(loc);
  303. document.getElementById("grafo").innerHTML = graph;
  304. document.getElementById("nome_luogo").innerHTML = label;
  305. document.getElementById("nome_lu").innerHTML = label;
  306. document.getElementById("nome_lp").innerHTML = label;
  307. document.getElementById("nome_ll").innerHTML = label;
  308. document.getElementById("nome_lg").innerHTML = label;
  309. document.getElementById("nome_st1").innerHTML = label;
  310. document.getElementById("nome_st2").innerHTML = label;
  311. document.getElementById("nome_ass1").innerHTML = label;
  312. document.getElementById("nome_ass2").innerHTML = label;
  313. });
  314. var map = L.map('map').setView([locations[0][1], locations[0][2]], 7);
  315. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  316. L.tileLayer(
  317. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  318. attribution: '&copy; ' + mapLink + ' Contributors',
  319. maxZoom: 18,
  320. }).addTo(map);
  321. for (var i = 0; i < locations.length; i++) {
  322. marker = new L.marker([locations[i][1], locations[i][2]])
  323. .bindPopup(locations[i][0])
  324. .addTo(map);
  325. }
  326. }
  327. function handle_ref(json) {
  328. console.log(json);
  329. const references = [];
  330. var list_ref = "";
  331. $.each(
  332. json['results']['bindings'],
  333. function (index, value) {
  334. var ref = value['references']['value'];
  335. references.push(ref);
  336. });
  337. for (i=0; i<references.length; i++) {
  338. list_ref += "<div class='row'><div class='col'><a href='" + references[i] + "'>" + references[i] + "</a></div></div>";
  339. }
  340. document.getElementById("riferimenti").innerHTML = list_ref;
  341. }
  342. function handle_toponym(json) {
  343. console.log(json);
  344. const toponym = [];
  345. $.each(
  346. json['results']['bindings'],
  347. function (index, value) {
  348. var topo = value['toponimi']['value'];
  349. toponym.push(" " + topo);
  350. });
  351. document.getElementById("toponimi").innerHTML = toponym;
  352. }
  353. function handle_receive(json) {
  354. console.log(json);
  355. const received = {};
  356. var i=0;
  357. $.each(
  358. json['results']['bindings'],
  359. function (index, value) {
  360. key = value['object']['value'];
  361. data = value['label']['value'];
  362. received[key] = data;
  363. i++;
  364. });
  365. var myArray = "";
  366. for (var key in received) {
  367. 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>";
  368. }
  369. document.getElementById("n_receive").innerHTML = i;
  370. document.getElementById("object_receive").innerHTML = myArray;
  371. if (i==0) {
  372. var messaggio = "<p>Nessun risultato trovato</p>";
  373. document.getElementById("object_receive").innerHTML = messaggio;
  374. }
  375. }
  376. function handle_send(json) {
  377. console.log(json);
  378. const sent = {};
  379. var i=0;
  380. $.each(
  381. json['results']['bindings'],
  382. function (index, value) {
  383. key = value['object']['value'];
  384. data = value['label']['value'];
  385. sent[key] = data;
  386. i++;
  387. });
  388. var myArray = "";
  389. for (var key in sent) {
  390. 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>";
  391. }
  392. document.getElementById("n_send").innerHTML = i;
  393. document.getElementById("object_send").innerHTML = myArray;
  394. if (i==0) {
  395. var messaggio = "<p>Nessun risultato trovato</p>";
  396. document.getElementById("object_send").innerHTML = messaggio;
  397. }
  398. }
  399. function handle_cit(json) {
  400. console.log(json);
  401. const citations = {};
  402. var i=0;
  403. $.each(
  404. json['results']['bindings'],
  405. function (index, value) {
  406. key = value['object']['value'];
  407. data = value['label']['value'];
  408. citations[key] = data;
  409. i++;
  410. });
  411. var myArray = "";
  412. for (var key in citations) {
  413. 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>";
  414. }
  415. document.getElementById("n_cit").innerHTML = i;
  416. document.getElementById("object_cit").innerHTML = myArray;
  417. if (i==0) {
  418. var messaggio = "<p>Nessun risultato trovato</p>";
  419. document.getElementById("object_cit").innerHTML = messaggio;
  420. }
  421. }
  422. function handle_persons(json) {
  423. console.log(json);
  424. const people = {};
  425. var i=0;
  426. $.each(
  427. json['results']['bindings'],
  428. function (index, value) {
  429. key = value['range']['value'];
  430. data = value['label']['value'];
  431. people[key] = data;
  432. i++;
  433. });
  434. var myArray = "";
  435. for (var key in people) {
  436. myArray += "<div class='row'><div class='col-9'>" + people[key] + "</div><div class='persona col' id='" +
  437. key + "'><i class='fa fa-user'></i></div><div class='col'><a href='" +
  438. key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
  439. }
  440. document.getElementById("n_per").innerHTML = i;
  441. document.getElementById("object_per").innerHTML = myArray;
  442. if (i==0) {
  443. var messaggio = "<p>Nessun risultato trovato</p>";
  444. document.getElementById("object_per").innerHTML = messaggio;
  445. }
  446. }
  447. function handle_count(json) {
  448. console.log(json);
  449. const toponimi = [];
  450. const dataToponimi = [];
  451. var max = 0;
  452. $.each(
  453. json['results']['bindings'],
  454. function (index, value) {
  455. const topo = [];
  456. var toponimo = value['label']['value'];
  457. var count = value['Count']['value'];
  458. var temp = parseInt(count);
  459. toponimi.push(toponimo);
  460. dataToponimi.push([toponimo, count]);
  461. if (temp>max) {
  462. max = temp;
  463. }
  464. });
  465. // set the dimensions and margins of the graph
  466. var margin = {top: 20, right: 30, bottom: 40, left: 90},
  467. width = 460 - margin.left - margin.right,
  468. height = 400 - margin.top - margin.bottom;
  469. // append the svg object to the body of the page
  470. var svg = d3.select("#my_dataviz")
  471. .append("svg")
  472. .attr("width", width + margin.left + margin.right)
  473. .attr("height", height + margin.top + margin.bottom)
  474. .append("g")
  475. .attr("transform",
  476. "translate(" + margin.left + "," + margin.top + ")");
  477. // Parse the Data
  478. //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
  479. // Add X axis
  480. var x = d3.scaleLinear()
  481. .domain([0, max])
  482. .range([ 0, width]);
  483. svg.append("g")
  484. .attr("transform", "translate(0," + height + ")")
  485. .call(d3.axisBottom(x))
  486. .selectAll("text")
  487. .attr("transform", "translate(-10,0)rotate(-45)")
  488. .style("text-anchor", "end");
  489. // Y axis
  490. var y = d3.scaleBand()
  491. .range([ 0, height ])
  492. .domain(toponimi)
  493. .padding(.1);
  494. svg.append("g")
  495. .call(d3.axisLeft(y))
  496. //Bars
  497. svg.selectAll("myRect")
  498. .data(dataToponimi)
  499. .enter()
  500. .append("rect")
  501. .attr("x", x(0) )
  502. .attr("y", function(d) { return y(d[0]); })
  503. .attr("width", function(d) { return x(d[1]); })
  504. .attr("height", y.bandwidth() )
  505. .attr("fill", "#69b3a2")
  506. /*var texts = svg.selectAll("myRect")
  507. .data(dataToponimi)
  508. .enter()
  509. .append("text");
  510. texts.attr("x", function(d){ return d[1] / 4 - 20})
  511. .attr("y", function(d,i){ return 22.26*i +20})
  512. .attr("text-anchor", "middle")
  513. .attr("fill", "#fff")
  514. .text(function(d){ return d[1]});*/
  515. }
  516. function handle_count2(json) {
  517. console.log(json);
  518. const toponimi = [];
  519. const dataToponimi = [];
  520. const values = [];
  521. var max = 0;
  522. $.each(
  523. json['results']['bindings'],
  524. function (index, value) {
  525. const topo = [];
  526. var toponimo = value['label']['value'];
  527. var count = value['Count']['value'];
  528. var temp = parseInt(count);
  529. toponimi.push(toponimo);
  530. dataToponimi.push([toponimo, count]);
  531. if (temp>max) {
  532. max = temp;
  533. }
  534. });
  535. // set the dimensions and margins of the graph
  536. var margin = {top: 20, right: 30, bottom: 40, left: 90},
  537. width = 460 - margin.left - margin.right,
  538. height = 400 - margin.top - margin.bottom;
  539. // append the svg object to the body of the page
  540. var svg = d3.select("#my_dataviz2")
  541. .append("svg")
  542. .attr("width", width + margin.left + margin.right)
  543. .attr("height", height + margin.top + margin.bottom)
  544. .append("g")
  545. .attr("transform",
  546. "translate(" + margin.left + "," + margin.top + ")");
  547. // Parse the Data
  548. //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
  549. // Add X axis
  550. var x = d3.scaleLinear()
  551. .domain([0, max])
  552. .range([ 0, width]);
  553. svg.append("g")
  554. .attr("transform", "translate(0," + height + ")")
  555. .call(d3.axisBottom(x))
  556. .selectAll("text")
  557. .attr("transform", "translate(-10,0)rotate(-45)")
  558. .style("text-anchor", "end");
  559. // Y axis
  560. var y = d3.scaleBand()
  561. .range([ 0, height ])
  562. .domain(toponimi)
  563. .padding(.1);
  564. svg.append("g")
  565. .call(d3.axisLeft(y))
  566. //Bars
  567. svg.selectAll("myRect")
  568. .data(dataToponimi)
  569. .enter()
  570. .append("rect")
  571. .attr("x", x(0) )
  572. .attr("y", function(d) { return y(d[0]); })
  573. .attr("width", function(d) { return x(d[1]); })
  574. .attr("height", y.bandwidth() )
  575. .attr("fill", "#69b3a2")
  576. svg.selectAll("text2")
  577. .data(dataToponimi)
  578. .enter().append("text2")
  579. .text(function(d) {return d[1]})
  580. .attr("class", "text")
  581. }
  582. function get_dataset(json) {
  583. console.log(json);
  584. data = json.results.bindings[0].documenti.value;
  585. console.log(data);
  586. }
  587. function get_occurrence(json) {
  588. }
  589. function get_support(json) {
  590. }
  591. function open_info() {
  592. document.getElementById("info_luogo").style.display = "block";
  593. document.getElementById("place_info").style.display = "block";
  594. document.getElementById("topo").style.display = "none";
  595. document.getElementById("rif").style.display = "none";
  596. }
  597. function open_toponimi() {
  598. document.getElementById("info_luogo").style.display = "block";
  599. document.getElementById("place_info").style.display = "none";
  600. document.getElementById("topo").style.display = "block";
  601. document.getElementById("rif").style.display = "none";
  602. }
  603. function open_riferimenti() {
  604. document.getElementById("info_luogo").style.display = "block";
  605. document.getElementById("place_info").style.display = "none";
  606. document.getElementById("topo").style.display = "none";
  607. document.getElementById("rif").style.display = "block";
  608. }
  609. function open_collegamenti() {
  610. document.getElementById("references").style.display = "flex";
  611. document.getElementById("statistiche").style.display = "none";
  612. document.getElementById("regole_associazione").style.display = "none";
  613. }
  614. function open_statistiche() {
  615. document.getElementById("references").style.display = "none";
  616. document.getElementById("statistiche").style.display = "flex";
  617. document.getElementById("regole_associazione").style.display = "none";
  618. }
  619. function open_correlazioni() {
  620. document.getElementById("references").style.display = "none";
  621. document.getElementById("statistiche").style.display = "none";
  622. document.getElementById("regole_associazione").style.display = "flex";
  623. }
  624. var header = document.getElementById("ref_buttons");
  625. var btns = header.getElementsByClassName("btn");
  626. for (var i = 0; i < btns.length; i++) {
  627. btns[i].addEventListener("click", function() {
  628. var current = document.getElementsByClassName("active");
  629. current[0].className = current[0].className.replace(" active", "");
  630. this.className += " active";
  631. });
  632. }
  633. //out = "";
  634. //for(i = 0; i < resultArray.length; i++){
  635. // out = out + JSON.stringify(resultArray[i])
  636. //}
  637. //queryStringOutput = (queryStringOutput + out).replace("}{",",");
  638. /*
  639. var locations = [
  640. ["LOCATION_1", 11.8166, 122.0942],
  641. ["LOCATION_2", 11.9804, 121.9189],
  642. ["LOCATION_3", 10.7202, 122.5621],
  643. ["LOCATION_4", 11.3889, 122.6277],
  644. ["LOCATION_5", 10.5929, 122.6325]
  645. ];
  646. var map = L.map('map').setView([11.206051, 122.447886], 8);
  647. mapLink =
  648. '<a href="http://openstreetmap.org">OpenStreetMap</a>';
  649. L.tileLayer(
  650. 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  651. attribution: '&copy; ' + mapLink + ' Contributors',
  652. maxZoom: 18,
  653. }).addTo(map);
  654. for (var i = 0; i < locations.length; i++) {
  655. marker = new L.marker([locations[i][1], locations[i][2]])
  656. .bindPopup(locations[i][0])
  657. .addTo(map);
  658. }
  659. */
  660. $(document).on("click", ".persona", function (ev) {
  661. var link = this.id;
  662. //alert(nome_autore);
  663. //$('#myModal').text("");
  664. window.open("Persona.html?link="+this.id);
  665. });