Spaces:
Running
Running
why it doenst show the sankey diagram? there are a problem with the used library? maybe yu can change to other library.
Browse files- index.html +1 -0
- script.js +7 -6
index.html
CHANGED
|
@@ -7,6 +7,7 @@
|
|
| 7 |
<link rel="stylesheet" href="style.css">
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
|
|
|
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 12 |
</head>
|
|
|
|
| 7 |
<link rel="stylesheet" href="style.css">
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/d3-sankey@0.12.3/dist/d3-sankey.min.js"></script>
|
| 11 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 12 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 13 |
</head>
|
script.js
CHANGED
|
@@ -27,14 +27,15 @@ function initDiagram() {
|
|
| 27 |
.nodeWidth(parseInt(document.getElementById('node-width').value))
|
| 28 |
.nodePadding(20)
|
| 29 |
.extent([[1, 1], [width - 1, height - 6]]);
|
| 30 |
-
|
| 31 |
// Generate the sankey diagram
|
| 32 |
-
const
|
| 33 |
-
nodes: sankeyData.nodes.map(d => ({
|
| 34 |
-
links: sankeyData.links.map(d => ({
|
| 35 |
});
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
svg.attr("width", width)
|
| 39 |
.attr("height", height)
|
| 40 |
.attr("viewBox", [0, 0, width, height])
|
|
|
|
| 27 |
.nodeWidth(parseInt(document.getElementById('node-width').value))
|
| 28 |
.nodePadding(20)
|
| 29 |
.extent([[1, 1], [width - 1, height - 6]]);
|
|
|
|
| 30 |
// Generate the sankey diagram
|
| 31 |
+
const graph = sankey({
|
| 32 |
+
nodes: sankeyData.nodes.map(d => Object.assign({}, d)),
|
| 33 |
+
links: sankeyData.links.map(d => Object.assign({}, d))
|
| 34 |
});
|
| 35 |
+
|
| 36 |
+
const nodes = graph.nodes;
|
| 37 |
+
const links = graph.links;
|
| 38 |
+
// Clear previous diagram
|
| 39 |
svg.attr("width", width)
|
| 40 |
.attr("height", height)
|
| 41 |
.attr("viewBox", [0, 0, width, height])
|