Skip to content

Commit 2d4c9e5

Browse files
committed
cascade looks nice
1 parent f149c40 commit 2d4c9e5

File tree

4 files changed

+53
-11
lines changed

4 files changed

+53
-11
lines changed

bin/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ function startServer(allFunctions, functionMap) {
5151
app.use('/graphviz', express.static(path.join(__dirname, '..', 'graphing/graphviz')));
5252
app.use('/mermaid', express.static(path.join(__dirname, '..', 'graphing/mermaid')));
5353
app.use('/vendor', express.static(path.join(__dirname, '..', 'graphing/vendor')));
54+
// API endpoints
55+
app.use('/all', function (req, res) { res.json(allFunctions); });
5456
app.get('/arcAPI', function (req, res) { res.json(arc_1.convertForArc(allFunctions, functionMap)); });
5557
app.get('/cascadeAPI/:startFunc', function (req, res) {
5658
res.json(cascade_1.convertForCascade(functionMap, req.params.startFunc));

graphing/cascade/graph.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ export default function define(runtime, observer) {
1717
});
1818

1919

20-
main.variable(observer()).define(["html"], function(html) {
21-
return (
22-
html`<div class="heading">Call Graph</div>`
23-
)
24-
});
20+
// main.variable(observer()).define(["html"], function(html) {
21+
// return (
22+
// html`<div class="heading">Call Graph</div>`
23+
// )
24+
// });
2525

2626
main.variable(observer()).define(["svg", "width", "data", "color"], function (svg, width, data, color) {
27-
return svg`<svg width="${width}" height="${data.layout.height}">
27+
return svg`<svg width="${width - 200}" height="${data.layout.height}">
2828
2929
<style>
3030
text {

graphing/cascade/index.html

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,61 @@
1414
}
1515

1616
a {
17+
color: black;
1718
display: block;
18-
margin: 10px;
1919
font-family: sans-serif;
2020
font-size: 12px;
21+
margin: 10px;
22+
text-decoration: none;
23+
}
24+
25+
#functionsList {
26+
position: absolute;
27+
background: white;
28+
border-right: 1px solid black;
29+
}
30+
31+
#graphDiv {
32+
margin-left: 200px;
2133
}
2234
</style>
2335
</head>
2436

2537
<body>
2638

27-
<div id="graph" style="text-align: center;"></div>
39+
<div id="functionsList"></div>
40+
41+
<div id="graphDiv"></div>
42+
43+
<script>
44+
45+
fetch('http://localhost:3000/all')
46+
.then((response) => {
47+
return response.json();
48+
})
49+
.then((data) => {
50+
51+
data.sort();
52+
53+
const everyFunc = data.map(function (func) {
54+
return '<a href="index.html?start=' + func + '">' + func + '</a>';
55+
}).join('');
56+
57+
document.getElementById('functionsList').innerHTML = everyFunc;
58+
59+
});
60+
61+
</script>
2862

2963
<script type="module">
3064
import define from "./graph.js";
3165
import { Runtime, Library, Inspector } from "/vendor/runtime.js";
3266

3367
const runtime = new Runtime();
34-
const main = runtime.module(define, Inspector.into(document.body));
68+
69+
const temp = document.getElementById('graphDiv');
70+
71+
const main = runtime.module(define, Inspector.into(temp));
3572

3673
// Save to SVG & PNG
3774
setTimeout(() => {
@@ -58,15 +95,15 @@
5895
a.download = "callgraph.png";
5996
a.href = pngBase64;
6097
a.innerHTML = "download as PNG";
61-
document.body.appendChild(a);
98+
temp.appendChild(a);
6299

63100
const svgBase64 = "data:image/svg+xml;base64," + btoa(svgData);
64101

65102
const b = document.createElement("a");
66103
b.download = "callgraph.svg";
67104
b.href = svgBase64;
68105
b.innerHTML = "download as SVG";
69-
document.body.appendChild(b);
106+
temp.appendChild(b);
70107

71108
};
72109

index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ function startServer(allFunctions: string[], functionMap: Map<string, string[]>)
6767
app.use('/mermaid', express.static(path.join(__dirname, '..', 'graphing/mermaid')));
6868
app.use('/vendor', express.static(path.join(__dirname, '..', 'graphing/vendor')));
6969

70+
// API endpoints
71+
app.use('/all', function (req, res) { res.json(allFunctions) });
72+
7073
app.get('/arcAPI', function (req, res) { res.json(convertForArc(allFunctions, functionMap)) });
7174

7275
app.get('/cascadeAPI/:startFunc', function (req, res) {

0 commit comments

Comments
 (0)