1 |
47e239fc
|
Štěpán Červenka
|
{
|
2 |
|
|
"$schema": "https://vega.github.io/schema/vega/v5.json",
|
3 |
|
|
"description": "Area charts of stock prices, with an interactive overview and filtered detail views.",
|
4 |
|
|
"width": 720,
|
5 |
|
|
"height": 480,
|
6 |
|
|
"padding": 5,
|
7 |
|
|
|
8 |
|
|
"data": [
|
9 |
|
|
{
|
10 |
|
|
"name": "table",
|
11 |
|
|
"url": "data_big.json",
|
12 |
|
|
"transform": [
|
13 |
|
|
{
|
14 |
|
|
"type": "formula",
|
15 |
|
|
"expr": "toDate(datum[\"time\"])",
|
16 |
|
|
"as": "dateTime"
|
17 |
|
|
}]
|
18 |
|
|
|
19 |
|
|
}
|
20 |
|
|
],
|
21 |
|
|
|
22 |
|
|
"signals": [
|
23 |
|
|
{
|
24 |
|
|
"name": "detailDomain"
|
25 |
|
|
}
|
26 |
|
|
],
|
27 |
|
|
|
28 |
|
|
"marks": [
|
29 |
|
|
{
|
30 |
|
|
"type": "group",
|
31 |
|
|
"name": "detail",
|
32 |
|
|
"encode": {
|
33 |
|
|
"enter": {
|
34 |
|
|
"height": {"value": 390},
|
35 |
|
|
"width": {"value": 720}
|
36 |
|
|
}
|
37 |
|
|
},
|
38 |
|
|
"scales": [
|
39 |
|
|
{
|
40 |
|
|
"name": "xDetail",
|
41 |
|
|
"type": "time",
|
42 |
|
|
"range": "width",
|
43 |
|
|
"domain": {"data": "table", "field": "dateTime"},
|
44 |
|
|
"domainRaw": {"signal": "detailDomain"}
|
45 |
|
|
},
|
46 |
|
|
{
|
47 |
|
|
"name": "yDetail",
|
48 |
|
|
"type": "linear",
|
49 |
|
|
"range": [390, 0],
|
50 |
|
|
"domain": {"data": "table", "field": "value"},
|
51 |
|
|
"nice": true, "zero": true
|
52 |
|
|
}
|
53 |
|
|
],
|
54 |
|
|
"axes": [
|
55 |
|
|
{"orient": "bottom", "scale": "xDetail"},
|
56 |
|
|
{"orient": "left", "scale": "yDetail"}
|
57 |
|
|
],
|
58 |
|
|
"marks": [
|
59 |
|
|
{
|
60 |
|
|
"type": "group",
|
61 |
|
|
"encode": {
|
62 |
|
|
"enter": {
|
63 |
|
|
"height": {"field": {"group": "height"}},
|
64 |
|
|
"width": {"field": {"group": "width"}},
|
65 |
|
|
"clip": {"value": true}
|
66 |
|
|
}
|
67 |
|
|
},
|
68 |
|
|
"marks": [
|
69 |
|
|
{
|
70 |
|
|
"type": "symbol",
|
71 |
|
|
"from": {"data": "table"},
|
72 |
|
|
"encode": {
|
73 |
|
|
"update": {
|
74 |
|
|
"shape": {"value": "circle"},
|
75 |
|
|
"size": {"value": 10},
|
76 |
|
|
"x": {"scale": "xDetail", "field": "dateTime"},
|
77 |
|
|
"y": {"scale": "yDetail", "field": "value"},
|
78 |
|
|
"color": {"value": "both"},
|
79 |
|
|
"strokeWidth": {"value": 1}
|
80 |
|
|
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
]
|
85 |
|
|
}
|
86 |
|
|
]
|
87 |
|
|
},
|
88 |
|
|
|
89 |
|
|
{
|
90 |
|
|
"type": "group",
|
91 |
|
|
"name": "overview",
|
92 |
|
|
"encode": {
|
93 |
|
|
"enter": {
|
94 |
|
|
"x": {"value": 0},
|
95 |
|
|
"y": {"value": 430},
|
96 |
|
|
"height": {"value": 70},
|
97 |
|
|
"width": {"value": 720},
|
98 |
|
|
"fill": {"value": "transparent"}
|
99 |
|
|
}
|
100 |
|
|
},
|
101 |
|
|
"signals": [
|
102 |
|
|
{
|
103 |
|
|
"name": "brush", "value": 0,
|
104 |
|
|
"on": [
|
105 |
|
|
{
|
106 |
|
|
"events": "@overview:mousedown",
|
107 |
|
|
"update": "[x(), x()]"
|
108 |
|
|
},
|
109 |
|
|
{
|
110 |
|
|
"events": "[@overview:mousedown, window:mouseup] > window:mousemove!",
|
111 |
|
|
"update": "[brush[0], clamp(x(), 0, width)]"
|
112 |
|
|
},
|
113 |
|
|
{
|
114 |
|
|
"events": {"signal": "delta"},
|
115 |
|
|
"update": "clampRange([anchor[0] + delta, anchor[1] + delta], 0, width)"
|
116 |
|
|
}
|
117 |
|
|
]
|
118 |
|
|
},
|
119 |
|
|
{
|
120 |
|
|
"name": "anchor", "value": null,
|
121 |
|
|
"on": [{"events": "@brush:mousedown", "update": "slice(brush)"}]
|
122 |
|
|
},
|
123 |
|
|
{
|
124 |
|
|
"name": "xdown", "value": 0,
|
125 |
|
|
"on": [{"events": "@brush:mousedown", "update": "x()"}]
|
126 |
|
|
},
|
127 |
|
|
{
|
128 |
|
|
"name": "delta", "value": 0,
|
129 |
|
|
"on": [
|
130 |
|
|
{
|
131 |
|
|
"events": "[@brush:mousedown, window:mouseup] > window:mousemove!",
|
132 |
|
|
"update": "x() - xdown"
|
133 |
|
|
}
|
134 |
|
|
]
|
135 |
|
|
},
|
136 |
|
|
{
|
137 |
|
|
"name": "detailDomain",
|
138 |
|
|
"push": "outer",
|
139 |
|
|
"on": [
|
140 |
|
|
{
|
141 |
|
|
"events": {"signal": "brush"},
|
142 |
|
|
"update": "span(brush) ? invert('xOverview', brush) : null"
|
143 |
|
|
}
|
144 |
|
|
]
|
145 |
|
|
}
|
146 |
|
|
],
|
147 |
|
|
"scales": [
|
148 |
|
|
{
|
149 |
|
|
"name": "xOverview",
|
150 |
|
|
"type": "time",
|
151 |
|
|
"range": "width",
|
152 |
|
|
"domain": {"data": "table", "field": "dateTime"}
|
153 |
|
|
},
|
154 |
|
|
{
|
155 |
|
|
"name": "yOverview",
|
156 |
|
|
"type": "linear",
|
157 |
|
|
"range": [70, 0],
|
158 |
|
|
"domain": {"data": "table", "field": "dateTime"},
|
159 |
|
|
"nice": true, "zero": true
|
160 |
|
|
}
|
161 |
|
|
],
|
162 |
|
|
"axes": [
|
163 |
|
|
{"orient": "bottom", "scale": "xOverview"}
|
164 |
|
|
],
|
165 |
|
|
"marks": [
|
166 |
|
|
|
167 |
|
|
{
|
168 |
|
|
"type": "rect",
|
169 |
|
|
"name": "brush",
|
170 |
|
|
"encode": {
|
171 |
|
|
"enter": {
|
172 |
|
|
"y": {"value": 0},
|
173 |
|
|
"height": {"value": 70},
|
174 |
|
|
"fill": {"value": "#333"},
|
175 |
|
|
"fillOpacity": {"value": 0.2}
|
176 |
|
|
},
|
177 |
|
|
"update": {
|
178 |
|
|
"x": {"signal": "brush[0]"},
|
179 |
|
|
"x2": {"signal": "brush[1]"}
|
180 |
|
|
}
|
181 |
|
|
}
|
182 |
|
|
},
|
183 |
|
|
{
|
184 |
|
|
"type": "rect",
|
185 |
|
|
"interactive": false,
|
186 |
|
|
"encode": {
|
187 |
|
|
"enter": {
|
188 |
|
|
"y": {"value": 0},
|
189 |
|
|
"height": {"value": 70},
|
190 |
|
|
"width": {"value": 1},
|
191 |
|
|
"fill": {"value": "firebrick"}
|
192 |
|
|
},
|
193 |
|
|
"update": {
|
194 |
|
|
"x": {"signal": "brush[0]"}
|
195 |
|
|
}
|
196 |
|
|
}
|
197 |
|
|
},
|
198 |
|
|
{
|
199 |
|
|
"type": "rect",
|
200 |
|
|
"interactive": false,
|
201 |
|
|
"encode": {
|
202 |
|
|
"enter": {
|
203 |
|
|
"y": {"value": 0},
|
204 |
|
|
"height": {"value": 70},
|
205 |
|
|
"width": {"value": 1},
|
206 |
|
|
"fill": {"value": "firebrick"}
|
207 |
|
|
},
|
208 |
|
|
"update": {
|
209 |
|
|
"x": {"signal": "brush[1]"}
|
210 |
|
|
}
|
211 |
|
|
}
|
212 |
|
|
}
|
213 |
|
|
]
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
]
|
222 |
|
|
}
|