|
1 | 1 | (async function() { |
2 | | - // Use the ACCEPT environment |
3 | | - const apiRoot = "https://digitalcollections-accept.library.maastrichtuniversity.nl/api"; |
4 | | - const itemSetId = 60514; // Maastricht History Clinic (accept) |
5 | | - |
6 | 2 | try { |
7 | | - // Step 1: Get all people in that item set |
8 | | - const peopleRes = await fetch(`${apiRoot}/item_sets/${itemSetId}/items`); |
9 | | - const people = await peopleRes.json(); |
10 | | - |
11 | | - const rootData = { name: "Maastricht History Clinic", children: [] }; |
12 | | - |
13 | | - // Step 2: For each person, find linked objects |
14 | | - for (const person of people) { |
15 | | - const personNode = { name: person["o:title"] || "Unnamed", children: [] }; |
16 | | - |
17 | | - const relatedUrl = |
18 | | - `${apiRoot}/items?property[0][joiner]=and&property[0][property]=schema:about` + |
19 | | - `&property[0][type]=resource&property[0][text]=${encodeURIComponent(person["@id"])}`; |
20 | | - const relatedRes = await fetch(relatedUrl); |
21 | | - const relatedObjects = await relatedRes.json(); |
| 3 | + const res = await fetch("data.json"); |
| 4 | + const rootData = await res.json(); |
22 | 5 |
|
23 | | - for (const obj of relatedObjects) { |
24 | | - personNode.children.push({ |
25 | | - name: obj["o:title"] || "Memory Object", |
26 | | - url: obj["@id"].replace("/api", "") |
27 | | - }); |
28 | | - } |
29 | | - |
30 | | - rootData.children.push(personNode); |
31 | | - } |
32 | | - |
33 | | - // Step 3: Draw the D3 tree |
34 | 6 | const width = 1000, height = 700; |
35 | 7 | const treeLayout = d3.tree().size([height - 80, width - 160]); |
36 | 8 | const root = d3.hierarchy(rootData); |
|
70 | 42 | .on("click", (e, d) => { |
71 | 43 | if (d.data.url) window.open(d.data.url, "_blank"); |
72 | 44 | }); |
73 | | - |
74 | 45 | } catch (err) { |
75 | 46 | console.error("Error loading data:", err); |
76 | 47 | } |
77 | 48 | })(); |
78 | | - |
0 commit comments