Skip to content

Commit 287ffd9

Browse files
committed
updated tree view, now we can change width and height of the canvas
1 parent 69469ed commit 287ffd9

1 file changed

Lines changed: 60 additions & 72 deletions

File tree

Lines changed: 60 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,106 @@
11
{
2-
"$schema": "https://vega.github.io/schema/vega/v5.json",
3-
"description": "An example of Cartesian layouts for a node-link diagram of hierarchical data.",
4-
"width": 1000,
5-
"height": 1000,
6-
"padding": 5,
7-
8-
"signals": [
9-
{
10-
"name": "labels", "value": true,
11-
"bind": {"input": "checkbox"}
12-
},
13-
{
14-
"name": "layout", "value": "tidy",
15-
"bind": {"input": "radio", "options": ["tidy", "cluster"]}
16-
},
17-
{
18-
"name": "links", "value": "diagonal",
19-
"bind": {
20-
"input": "select",
21-
"options": ["line", "curve", "diagonal", "orthogonal"]
22-
}
23-
},
24-
{
25-
"name": "separation", "value": false,
26-
"bind": {"input": "checkbox"}
27-
}
28-
],
29-
302
"data": [
313
{
324
"name": "tree",
33-
"values": [],
345
"transform": [
35-
{
36-
"type": "stratify",
37-
"key": "id",
38-
"parentKey": "parent"
39-
},
6+
{"type": "stratify", "key": "id", "parentKey": "parent"},
407
{
418
"type": "tree",
42-
"method": {"signal": "layout"},
9+
"as": ["y", "x", "depth", "children"],
4310
"size": [{"signal": "height"}, {"signal": "width - 100"}],
44-
"separation": {"signal": "separation"},
45-
"as": ["y", "x", "depth", "children"]
11+
"method": {"signal": "layout"},
12+
"separation": {"signal": "separation"}
4613
}
47-
]
14+
],
15+
"values": []
4816
},
4917
{
5018
"name": "links",
51-
"source": "tree",
5219
"transform": [
53-
{ "type": "treelinks" },
20+
{"type": "treelinks"},
5421
{
5522
"type": "linkpath",
5623
"orient": "horizontal",
5724
"shape": {"signal": "links"}
5825
}
59-
]
26+
],
27+
"source": "tree"
6028
}
6129
],
62-
63-
"scales": [
64-
{
65-
"name": "color",
66-
"type": "linear",
67-
"range": {"scheme": "magma"},
68-
"domain": {"data": "tree", "field": "depth"},
69-
"zero": true
70-
}
71-
],
72-
7330
"marks": [
7431
{
75-
"type": "path",
7632
"from": {"data": "links"},
33+
"type": "path",
7734
"encode": {
78-
"update": {
79-
"path": {"field": "path"},
80-
"stroke": {"value": "#ccc"}
81-
}
35+
"update": {"path": {"field": "path"}, "stroke": {"value": "#ccc"}}
8236
}
8337
},
8438
{
85-
"type": "symbol",
8639
"from": {"data": "tree"},
40+
"type": "symbol",
8741
"encode": {
88-
"enter": {
89-
"size": {"value": 100},
90-
"stroke": {"value": "#fff"}
91-
},
42+
"enter": {"size": {"value": 100}, "stroke": {"value": "#fff"}},
9243
"update": {
44+
"fill": {"scale": "color", "field": "depth"},
9345
"x": {"field": "x"},
94-
"y": {"field": "y"},
95-
"fill": {"scale": "color", "field": "depth"}
46+
"y": {"field": "y"}
9647
}
9748
}
9849
},
9950
{
100-
"type": "text",
10151
"from": {"data": "tree"},
52+
"type": "text",
10253
"encode": {
10354
"enter": {
104-
"text": {"field": "name"},
55+
"baseline": {"value": "middle"},
10556
"fontSize": {"value": 9},
106-
"baseline": {"value": "middle"}
57+
"text": {"field": "name"}
10758
},
10859
"update": {
109-
"x": {"field": "x"},
110-
"y": {"field": "y"},
111-
"dx": {"signal": "datum.children ? -7 : 7"},
11260
"align": {"signal": "datum.children ? 'right' : 'left'"},
113-
"opacity": {"signal": "labels ? 1 : 0"}
61+
"dx": {"signal": "datum.children ? -7 : 7"},
62+
"opacity": {"signal": "labels ? 1 : 0"},
63+
"x": {"field": "x"},
64+
"y": {"field": "y"}
11465
}
11566
}
11667
}
117-
]
68+
],
69+
"scales": [
70+
{
71+
"domain": {"data": "tree", "field": "depth"},
72+
"name": "color",
73+
"type": "linear",
74+
"range": {"scheme": "magma"},
75+
"zero": true
76+
}
77+
],
78+
"signals": [
79+
{"name": "wSignal", "bind": {"input": "text"}, "value": 1000},
80+
{"name": "hSignal", "bind": {"input": "text"}, "value": 1000},
81+
{"name": "labels", "bind": {"input": "checkbox"}, "value": true},
82+
{
83+
"name": "layout",
84+
"bind": {"input": "radio", "options": ["tidy", "cluster"]},
85+
"value": "tidy"
86+
},
87+
{
88+
"name": "links",
89+
"bind": {
90+
"input": "select",
91+
"options": ["line", "curve", "diagonal", "orthogonal"]
92+
},
93+
"value": "diagonal"
94+
},
95+
{"name": "separation", "bind": {"input": "checkbox"}, "value": false}
96+
],
97+
"$schema": "https://vega.github.io/schema/vega/v5.json",
98+
"description": "An example of Cartesian layouts for a node-link diagram of hierarchical data.",
99+
"height": {
100+
"signal": "hSignal"
101+
},
102+
"padding": 5,
103+
"width": {
104+
"signal": "wSignal"
105+
}
118106
}

0 commit comments

Comments
 (0)