|
2 | 2 | export default function define(runtime, observer) { |
3 | 3 | const main = runtime.module(); |
4 | 4 |
|
5 | | - main.builtin("FileAttachment", runtime.fileAttachments(() => new URL("http://localhost:3000/cascadeAPI", import.meta.url))); |
| 5 | + let graphData; |
| 6 | + |
| 7 | + const queryString = window.location.search; |
| 8 | + const urlParams = new URLSearchParams(queryString); |
| 9 | + const startFunction = urlParams.get('start') |
| 10 | + |
| 11 | + fetch('http://localhost:3000/cascadeAPI/' + startFunction) |
| 12 | + .then((response) => { |
| 13 | + return response.json(); |
| 14 | + }) |
| 15 | + .then((data) => { |
| 16 | + graphData = data; |
| 17 | + }); |
| 18 | + |
6 | 19 |
|
7 | 20 | main.variable(observer()).define(["html"], function(html) { |
8 | 21 | return ( |
@@ -64,13 +77,7 @@ export default function define(runtime, observer) { |
64 | 77 |
|
65 | 78 | main.variable(observer("data")).define("data", ["d3"], function (d3) { |
66 | 79 |
|
67 | | - // console.log(main); |
68 | | - // console.log(main._scope.get('temporaryHackName')._value); |
69 | | - // levels = JSON.parse('[[{"id":"abc"}],[{"id":"abc2","parents":["abc"]},{"id":"abc3"}],[{"id": "lol", "parents": ["abc3", "abc2"]}]]'); |
70 | | - |
71 | | - let levels = main._scope.get('temporaryHackName')._value; |
72 | | - |
73 | | - // console.log(levels); |
| 80 | + let levels = graphData; |
74 | 81 |
|
75 | 82 | // precompute level depth |
76 | 83 | levels.forEach((l, i) => l.forEach((n) => (n.level = i))); |
@@ -242,9 +249,5 @@ export default function define(runtime, observer) { |
242 | 249 | return require("d3-scale", "d3-scale-chromatic", "d3-array"); |
243 | 250 | }); |
244 | 251 |
|
245 | | - main.variable(observer()).define("temporaryHackName", ["FileAttachment"], function (lol) { |
246 | | - return lol().json() |
247 | | - }); |
248 | | - |
249 | 252 | return main; |
250 | 253 | } |
0 commit comments