|
20 | 20 | <div id="drawing"> |
21 | 21 | </div> |
22 | 22 | <div id="graph"> |
23 | | - <button>(Reset)</button> |
24 | 23 | </div> |
25 | 24 |
|
26 | 25 |
|
|
36 | 35 | <script src="js/Panel.js"></script> |
37 | 36 | <script src="js/GraphLayout.js"></script> |
38 | 37 | <script src="js/style.js"></script> |
| 38 | +<script src="js/word.js"></script> |
| 39 | +<script src="js/link.js"></script> |
| 40 | +<script src="js/row.js"></script> |
39 | 41 | <script src="js/annotate.js"></script> |
40 | 42 | <script src="js/render.js"></script> |
41 | 43 | <script src="js/interact.js"></script> |
|
60 | 62 |
|
61 | 63 | var rowOffsetX = 0; |
62 | 64 | var rowOffsetWord = null; |
63 | | -var prevX = -1; |
64 | 65 |
|
65 | 66 | var rows = []; //list of Row object, each of those has a list of Word objects |
66 | 67 |
|
|
70 | 71 | //var linkObjs = createTestLinks(3,3,3); |
71 | 72 | //var linkObjs = createTestLinks(1,0,0); |
72 | 73 | var linkObjs = createTestMultiLinks(1); |
73 | | -/* |
| 74 | + |
74 | 75 | drawWords(wordObjs); |
75 | 76 | drawLinks(linkObjs); |
76 | 77 |
|
77 | 78 | changeSizeOfSVGPanel(window.innerWidth - 16, (rows[rows.length - 1].lineBottom.y() ) + 1); |
78 | | -*/ |
| 79 | + |
79 | 80 | window.onload = function() { |
80 | 81 |
|
81 | 82 | const panel = new Panel('graph', 'drawing'); |
82 | 83 | const graph = new GraphLayout(panel.el); |
| 84 | + panel.onresize = graph.resize.bind(graph); |
83 | 85 | const parser = new Parser(); |
84 | 86 |
|
85 | 87 | var prevWidth = Config.svgWidth; |
|
100 | 102 | graph.graph(getSelectedObjects()); |
101 | 103 | }); |
102 | 104 |
|
103 | | - document.querySelector('#graph>button').onclick = function() { |
104 | | - let words = getSelectedObjects(); |
105 | | - if (words.length > 0) { |
106 | | - graph.graph(words); |
107 | | - } |
108 | | - else { |
109 | | - graph.clear(); |
110 | | - } |
111 | | - }; |
112 | | - |
113 | 105 | function changeDataset(index = 1) { |
114 | 106 | parser.readJson(`./data/data${index}.json`, function() { |
115 | 107 | graph.clear(); |
|
217 | 209 | isDragging = false; |
218 | 210 | rowOffsetX = 0; |
219 | 211 | rowOffsetWord = null; |
220 | | - prevX = -1; |
221 | 212 | dragElem = null; |
222 | 213 |
|
223 | 214 | rows = []; |
224 | 215 | wordObjs = words || createTestWords(5, 6, 10); |
225 | 216 | linkObjs = links || createTestMultiLinks(1); |
226 | | - // linkObjs.forEach(link => link.style = styles[link.style]); |
227 | 217 | drawWords(wordObjs); |
228 | 218 | drawLinks(linkObjs); |
229 | 219 | changeSizeOfSVGPanel(window.innerWidth - 16, (rows[rows.length - 1].lineBottom.y() ) + 1); |
|
0 commit comments