map.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  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. });
  312. var map = L.map('map').setView([locations[0][1], locations[0][2]], 7);
  313. mapLink = '<a href="https://openstreetmap.org">OpenStreetMap</a>';
  314. L.tileLayer(
  315. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  316. attribution: '&copy; ' + mapLink + ' Contributors',
  317. maxZoom: 18,
  318. }).addTo(map);
  319. for (var i = 0; i < locations.length; i++) {
  320. marker = new L.marker([locations[i][1], locations[i][2]])
  321. .bindPopup(locations[i][0])
  322. .addTo(map);
  323. }
  324. }
  325. function handle_ref(json) {
  326. console.log(json);
  327. const references = [];
  328. var list_ref = "";
  329. $.each(
  330. json['results']['bindings'],
  331. function (index, value) {
  332. var ref = value['references']['value'];
  333. references.push(ref);
  334. });
  335. for (i=0; i<references.length; i++) {
  336. list_ref += "<div class='row'><div class='col'><a href='" + references[i] + "'>" + references[i] + "</a></div></div>";
  337. }
  338. document.getElementById("riferimenti").innerHTML = list_ref;
  339. }
  340. function handle_toponym(json) {
  341. console.log(json);
  342. const toponym = [];
  343. $.each(
  344. json['results']['bindings'],
  345. function (index, value) {
  346. var topo = value['toponimi']['value'];
  347. toponym.push(" " + topo);
  348. });
  349. document.getElementById("toponimi").innerHTML = toponym;
  350. }
  351. function handle_receive(json) {
  352. console.log(json);
  353. const received = {};
  354. var i=0;
  355. $.each(
  356. json['results']['bindings'],
  357. function (index, value) {
  358. key = value['object']['value'];
  359. data = value['label']['value'];
  360. received[key] = data;
  361. i++;
  362. });
  363. var myArray = "";
  364. for (var key in received) {
  365. 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>";
  366. }
  367. document.getElementById("n_receive").innerHTML = i;
  368. document.getElementById("object_receive").innerHTML = myArray;
  369. if (i==0) {
  370. var messaggio = "<p>Nessun risultato trovato</p>";
  371. document.getElementById("object_receive").innerHTML = messaggio;
  372. }
  373. }
  374. function handle_send(json) {
  375. console.log(json);
  376. const sent = {};
  377. var i=0;
  378. $.each(
  379. json['results']['bindings'],
  380. function (index, value) {
  381. key = value['object']['value'];
  382. data = value['label']['value'];
  383. sent[key] = data;
  384. i++;
  385. });
  386. var myArray = "";
  387. for (var key in sent) {
  388. 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>";
  389. }
  390. document.getElementById("n_send").innerHTML = i;
  391. document.getElementById("object_send").innerHTML = myArray;
  392. if (i==0) {
  393. var messaggio = "<p>Nessun risultato trovato</p>";
  394. document.getElementById("object_send").innerHTML = messaggio;
  395. }
  396. }
  397. function handle_cit(json) {
  398. console.log(json);
  399. const citations = {};
  400. var i=0;
  401. $.each(
  402. json['results']['bindings'],
  403. function (index, value) {
  404. key = value['object']['value'];
  405. data = value['label']['value'];
  406. citations[key] = data;
  407. i++;
  408. });
  409. var myArray = "";
  410. for (var key in citations) {
  411. 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>";
  412. }
  413. document.getElementById("n_cit").innerHTML = i;
  414. document.getElementById("object_cit").innerHTML = myArray;
  415. if (i==0) {
  416. var messaggio = "<p>Nessun risultato trovato</p>";
  417. document.getElementById("object_cit").innerHTML = messaggio;
  418. }
  419. }
  420. function handle_persons(json) {
  421. console.log(json);
  422. const people = {};
  423. var i=0;
  424. $.each(
  425. json['results']['bindings'],
  426. function (index, value) {
  427. key = value['range']['value'];
  428. data = value['label']['value'];
  429. people[key] = data;
  430. i++;
  431. });
  432. var myArray = "";
  433. for (var key in people) {
  434. myArray += "<div class='row'><div class='col-9'>" + people[key] + "</div><div class='persona col' id='" +
  435. key + "'><i class='fa fa-user'></i></div><div class='col'><a href='" +
  436. key + "'><i class='fas fa-external-link-alt' aria-hidden='true'></i></a></div></div>";
  437. }
  438. document.getElementById("n_per").innerHTML = i;
  439. document.getElementById("object_per").innerHTML = myArray;
  440. if (i==0) {
  441. var messaggio = "<p>Nessun risultato trovato</p>";
  442. document.getElementById("object_per").innerHTML = messaggio;
  443. }
  444. }
  445. function handle_count(json) {
  446. console.log(json);
  447. const toponimi = [];
  448. const dataToponimi = [];
  449. var max = 0;
  450. $.each(
  451. json['results']['bindings'],
  452. function (index, value) {
  453. const topo = [];
  454. var toponimo = value['label']['value'];
  455. var count = value['Count']['value'];
  456. var temp = parseInt(count);
  457. toponimi.push(toponimo);
  458. dataToponimi.push([toponimo, count]);
  459. if (temp>max) {
  460. max = temp;
  461. }
  462. });
  463. // set the dimensions and margins of the graph
  464. var margin = {top: 20, right: 30, bottom: 40, left: 90},
  465. width = 460 - margin.left - margin.right,
  466. height = 400 - margin.top - margin.bottom;
  467. // append the svg object to the body of the page
  468. var svg = d3.select("#my_dataviz")
  469. .append("svg")
  470. .attr("width", width + margin.left + margin.right)
  471. .attr("height", height + margin.top + margin.bottom)
  472. .append("g")
  473. .attr("transform",
  474. "translate(" + margin.left + "," + margin.top + ")");
  475. // Parse the Data
  476. //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
  477. // Add X axis
  478. var x = d3.scaleLinear()
  479. .domain([0, max])
  480. .range([ 0, width]);
  481. svg.append("g")
  482. .attr("transform", "translate(0," + height + ")")
  483. .call(d3.axisBottom(x))
  484. .selectAll("text")
  485. .attr("transform", "translate(-10,0)rotate(-45)")
  486. .style("text-anchor", "end");
  487. // Y axis
  488. var y = d3.scaleBand()
  489. .range([ 0, height ])
  490. .domain(toponimi)
  491. .padding(.1);
  492. svg.append("g")
  493. .call(d3.axisLeft(y))
  494. //Bars
  495. svg.selectAll("myRect")
  496. .data(dataToponimi)
  497. .enter()
  498. .append("rect")
  499. .attr("x", x(0) )
  500. .attr("y", function(d) { return y(d[0]); })
  501. .attr("width", function(d) { return x(d[1]); })
  502. .attr("height", y.bandwidth() )
  503. .attr("fill", "#69b3a2")
  504. /*var texts = svg.selectAll("myRect")
  505. .data(dataToponimi)
  506. .enter()
  507. .append("text");
  508. texts.attr("x", function(d){ return d[1] / 4 - 20})
  509. .attr("y", function(d,i){ return 22.26*i +20})
  510. .attr("text-anchor", "middle")
  511. .attr("fill", "#fff")
  512. .text(function(d){ return d[1]});*/
  513. }
  514. function handle_count2(json) {
  515. console.log(json);
  516. const toponimi = [];
  517. const dataToponimi = [];
  518. const values = [];
  519. var max = 0;
  520. $.each(
  521. json['results']['bindings'],
  522. function (index, value) {
  523. const topo = [];
  524. var toponimo = value['label']['value'];
  525. var count = value['Count']['value'];
  526. var temp = parseInt(count);
  527. toponimi.push(toponimo);
  528. dataToponimi.push([toponimo, count]);
  529. if (temp>max) {
  530. max = temp;
  531. }
  532. });
  533. // set the dimensions and margins of the graph
  534. var margin = {top: 20, right: 30, bottom: 40, left: 90},
  535. width = 460 - margin.left - margin.right,
  536. height = 400 - margin.top - margin.bottom;
  537. // append the svg object to the body of the page
  538. var svg = d3.select("#my_dataviz2")
  539. .append("svg")
  540. .attr("width", width + margin.left + margin.right)
  541. .attr("height", height + margin.top + margin.bottom)
  542. .append("g")
  543. .attr("transform",
  544. "translate(" + margin.left + "," + margin.top + ")");
  545. // Parse the Data
  546. //d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/7_OneCatOneNum_header.csv", function(data) {
  547. // Add X axis
  548. var x = d3.scaleLinear()
  549. .domain([0, max])
  550. .range([ 0, width]);
  551. svg.append("g")
  552. .attr("transform", "translate(0," + height + ")")
  553. .call(d3.axisBottom(x))
  554. .selectAll("text")
  555. .attr("transform", "translate(-10,0)rotate(-45)")
  556. .style("text-anchor", "end");
  557. // Y axis
  558. var y = d3.scaleBand()
  559. .range([ 0, height ])
  560. .domain(toponimi)
  561. .padding(.1);
  562. svg.append("g")
  563. .call(d3.axisLeft(y))
  564. //Bars
  565. svg.selectAll("myRect")
  566. .data(dataToponimi)
  567. .enter()
  568. .append("rect")
  569. .attr("x", x(0) )
  570. .attr("y", function(d) { return y(d[0]); })
  571. .attr("width", function(d) { return x(d[1]); })
  572. .attr("height", y.bandwidth() )
  573. .attr("fill", "#69b3a2")
  574. svg.selectAll("text2")
  575. .data(dataToponimi)
  576. .enter().append("text2")
  577. .text(function(d) {return d[1]})
  578. .attr("class", "text")
  579. }
  580. function get_dataset(json) {
  581. console.log(json);
  582. data = json.results.bindings[0].documenti.value;
  583. console.log(data);
  584. }
  585. function get_occurrence(json) {
  586. }
  587. function get_support(json) {
  588. }
  589. function open_info() {
  590. document.getElementById("info_luogo").style.display = "block";
  591. document.getElementById("place_info").style.display = "block";
  592. document.getElementById("topo").style.display = "none";
  593. document.getElementById("rif").style.display = "none";
  594. }
  595. function open_toponimi() {
  596. document.getElementById("info_luogo").style.display = "block";
  597. document.getElementById("place_info").style.display = "none";
  598. document.getElementById("topo").style.display = "block";
  599. document.getElementById("rif").style.display = "none";
  600. }
  601. function open_riferimenti() {
  602. document.getElementById("info_luogo").style.display = "block";
  603. document.getElementById("place_info").style.display = "none";
  604. document.getElementById("topo").style.display = "none";
  605. document.getElementById("rif").style.display = "block";
  606. }
  607. function open_collegamenti() {
  608. document.getElementById("references").style.display = "flex";
  609. document.getElementById("statistiche").style.display = "none";
  610. document.getElementById("regole_associazione").style.display = "none";
  611. }
  612. function open_statistiche() {
  613. document.getElementById("references").style.display = "none";
  614. document.getElementById("statistiche").style.display = "flex";
  615. document.getElementById("regole_associazione").style.display = "none";
  616. }
  617. function open_correlazioni() {
  618. document.getElementById("references").style.display = "none";
  619. document.getElementById("statistiche").style.display = "none";
  620. document.getElementById("regole_associazione").style.display = "flex";
  621. }
  622. var header = document.getElementById("ref_buttons");
  623. var btns = header.getElementsByClassName("btn");
  624. for (var i = 0; i < btns.length; i++) {
  625. btns[i].addEventListener("click", function() {
  626. var current = document.getElementsByClassName("active");
  627. current[0].className = current[0].className.replace(" active", "");
  628. this.className += " active";
  629. });
  630. }
  631. //out = "";
  632. //for(i = 0; i < resultArray.length; i++){
  633. // out = out + JSON.stringify(resultArray[i])
  634. //}
  635. //queryStringOutput = (queryStringOutput + out).replace("}{",",");
  636. /*
  637. var locations = [
  638. ["LOCATION_1", 11.8166, 122.0942],
  639. ["LOCATION_2", 11.9804, 121.9189],
  640. ["LOCATION_3", 10.7202, 122.5621],
  641. ["LOCATION_4", 11.3889, 122.6277],
  642. ["LOCATION_5", 10.5929, 122.6325]
  643. ];
  644. var map = L.map('map').setView([11.206051, 122.447886], 8);
  645. mapLink =
  646. '<a href="http://openstreetmap.org">OpenStreetMap</a>';
  647. L.tileLayer(
  648. 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  649. attribution: '&copy; ' + mapLink + ' Contributors',
  650. maxZoom: 18,
  651. }).addTo(map);
  652. for (var i = 0; i < locations.length; i++) {
  653. marker = new L.marker([locations[i][1], locations[i][2]])
  654. .bindPopup(locations[i][0])
  655. .addTo(map);
  656. }
  657. */
  658. $(document).on("click", ".persona", function (ev) {
  659. var link = this.id;
  660. //alert(nome_autore);
  661. //$('#myModal').text("");
  662. window.open("Persona.html?link="+this.id);
  663. });