Davidal07 commited on
Commit
90c2999
·
verified ·
1 Parent(s): 94c2bba

why it doenst show the sankey diagram? there are a problem with the used library? maybe yu can change to other library.

Browse files
Files changed (2) hide show
  1. index.html +1 -0
  2. 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 { nodes, links } = sankey({
33
- nodes: sankeyData.nodes.map(d => ({...d})),
34
- links: sankeyData.links.map(d => ({...d}))
35
  });
36
-
37
- // Clear previous diagram
 
 
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])