-
Notifications
You must be signed in to change notification settings - Fork 0
/
vega.hjson
100 lines (100 loc) · 2.84 KB
/
vega.hjson
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"config": {
"kibana": {
"type": "map",
"latitude": 37.77,
"longitude": -122.45,
"zoom": 12,
"mapStyle": "default",
"minZoom": 5,
"maxZoom": 17,
"zoomControl": true,
"delayRepaint": true,
"controlsDirection": "horizontal"
}
},
"data": [
{
"name": "ships",
"url": {
"index": "ships-*",
"body": {
"query": {
"bool": {
"must": [
{ "exists": { "field": "location" } },
{ "exists": { "field": "mmsi" } },
{ "range": {"curtime": {"%timefilter%": true}} }
]
}
},
"size": 10000
}
}
"format": { "type": "json", "property": "hits.hits" },
"transform": [
{
"type": "geopoint",
"projection": "projection",
"fields": [
{"expr": "datum._source.location.lon"},
{"expr": "datum._source.location.lat"}
],
"as": ["x", "y"]
},
{
"type": "formula",
"expr": "if (datum._source.dim_a != null && datum._source.dim_b != null && datum._source.dim_c != null, log(1 + datum._source.dim_a + datum._source.dim_b + datum._source.dim_c) * 10, 100)"
"as": "shipsize"
},
{
"type": "formula",
"expr": "datum._source.mmsi % 20"
"as": "shipcolor"
},
{
type: "formula",
expr: "if (datum._source.name != null, datum._source.name, 'Unnamed')",
as: "shipname"
},
{
type: "formula",
expr: "if (datum._source.true_heading != null, datum._source.true_heading, 'Unnamed')",
as: "heading"
}
],
},
],
scales: [
{
"name": "shipcolorscale",
"type": "ordinal",
"domain": {"data": "ships", "field": "shipcolor"},
"range": { "scheme": "category20" }
}
],
"marks": [
{
"type": "text",
"from": {"data": "ships"},
"encode": {
"update": {
"x": {"signal": "datum.x"},
"y": {"signal": "datum.y"},
"text": { "value": "⏏" },
"fontSize": { "signal": "datum.shipsize" },
"fill": { "scale": "shipcolorscale", "field": "shipcolor" },
"align": { "value": "center" },
"fontWeight": { "value": "bold" },
"angle": { "signal": "datum.heading" },
"tooltip": { "signal": "datum.shipname" },
}
"hover": {
"fill": {"value": "red"},
"tooltip": { "signal": "datum.shipname" }
}
}
}
]
}