Skip to content

Commit cfa2c0f

Browse files
authored
Merge pull request #10 from CreativeCodingLab/multi-tree
Multi tree
2 parents 6f14a7c + 42f032f commit cfa2c0f

File tree

11 files changed

+923
-1458
lines changed

11 files changed

+923
-1458
lines changed

css/style.css

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ svg text {
2626

2727
#drawing {
2828
margin-top:30px;
29-
margin-bottom: 230px;
29+
margin-bottom: 210px;
3030
}
3131

3232
button {
@@ -38,12 +38,19 @@ button {
3838
}
3939

4040
.node { cursor: pointer; }
41+
.link, .link--dashed {
42+
fill: none;
43+
stroke: #999;
44+
}
45+
.link--dashed {
46+
stroke-dasharray: 2,2;
47+
}
4148

4249
#graph {
4350
cursor:-webkit-grab;
4451
cursor:grab;
4552
width:100%;
46-
height:220px;
53+
height:200px;
4754
border-top: 1px solid #ccc;
4855
background:#fff;
4956
position:fixed;
@@ -77,15 +84,17 @@ button {
7784

7885
.word--underneath {
7986
fill:white;
87+
cursor:-webkit-grab;
88+
cursor:grab;
8089
}
8190

8291
.selected .word--underneath, .link--label.selected {
83-
fill:white;
84-
stroke:teal;
92+
fill:#fff6f6;
93+
stroke:#c37;
8594
}
8695
.hovered .word--underneath, .link--label.hovered {
8796
fill:white;
88-
stroke:cyan;
97+
stroke:#f7c;
8998
}
9099

91100
.word--handle {

index.html

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<div id="drawing">
2121
</div>
2222
<div id="graph">
23-
<button>(Reset)</button>
2423
</div>
2524

2625

@@ -36,6 +35,9 @@
3635
<script src="js/Panel.js"></script>
3736
<script src="js/GraphLayout.js"></script>
3837
<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>
3941
<script src="js/annotate.js"></script>
4042
<script src="js/render.js"></script>
4143
<script src="js/interact.js"></script>
@@ -60,7 +62,6 @@
6062

6163
var rowOffsetX = 0;
6264
var rowOffsetWord = null;
63-
var prevX = -1;
6465

6566
var rows = []; //list of Row object, each of those has a list of Word objects
6667

@@ -70,16 +71,17 @@
7071
//var linkObjs = createTestLinks(3,3,3);
7172
//var linkObjs = createTestLinks(1,0,0);
7273
var linkObjs = createTestMultiLinks(1);
73-
/*
74+
7475
drawWords(wordObjs);
7576
drawLinks(linkObjs);
7677

7778
changeSizeOfSVGPanel(window.innerWidth - 16, (rows[rows.length - 1].lineBottom.y() ) + 1);
78-
*/
79+
7980
window.onload = function() {
8081

8182
const panel = new Panel('graph', 'drawing');
8283
const graph = new GraphLayout(panel.el);
84+
panel.onresize = graph.resize.bind(graph);
8385
const parser = new Parser();
8486

8587
var prevWidth = Config.svgWidth;
@@ -100,16 +102,6 @@
100102
graph.graph(getSelectedObjects());
101103
});
102104

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-
113105
function changeDataset(index = 1) {
114106
parser.readJson(`./data/data${index}.json`, function() {
115107
graph.clear();
@@ -217,13 +209,11 @@
217209
isDragging = false;
218210
rowOffsetX = 0;
219211
rowOffsetWord = null;
220-
prevX = -1;
221212
dragElem = null;
222213

223214
rows = [];
224215
wordObjs = words || createTestWords(5, 6, 10);
225216
linkObjs = links || createTestMultiLinks(1);
226-
// linkObjs.forEach(link => link.style = styles[link.style]);
227217
drawWords(wordObjs);
228218
drawLinks(linkObjs);
229219
changeSizeOfSVGPanel(window.innerWidth - 16, (rows[rows.length - 1].lineBottom.y() ) + 1);

0 commit comments

Comments
 (0)