This repository has been archived by the owner on Jul 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
label_rect.vg.json
73 lines (73 loc) · 1.75 KB
/
label_rect.vg.json
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
{
"$schema": "https://vega.github.io/schema/vega/v4.json",
"width": 700,
"height": 500,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{"category": "A", "amount": 28000},
{"category": "B", "amount": 55000},
{"category": "C", "amount": 43000},
{"category": "D", "amount": 91000},
{"category": "E", "amount": 81000},
{"category": "F", "amount": 53000},
{"category": "G", "amount": 5000},
{"category": "H", "amount": 87000}
]
}
],
"scales": [
{
"name": "yscale",
"type": "band",
"domain": {"data": "table", "field": "category"},
"range": "height",
"padding": 0.05,
"round": true
},
{
"name": "xscale",
"domain": {"data": "table", "field": "amount"},
"nice": true,
"range": "width"
}
],
"axes": [{"orient": "left", "scale": "yscale"}, {"orient": "bottom", "scale": "xscale"}],
"marks": [
{
"type": "rect",
"name": "bar",
"from": {"data": "table"},
"encode": {
"enter": {
"y": {"scale": "yscale", "field": "category"},
"height": {"scale": "yscale", "band": 1},
"x": {"scale": "xscale", "field": "amount"},
"x2": {"scale": "xscale", "value": 0}
},
"update": {"fill": {"value": "skyblue"}}
}
},
{
"type": "text",
"from": {"data": "bar"},
"encode": {
"enter": {
"fontSize": {"value": 25},
"text": {"field": "datum.amount"},
"fill": {"value": "#294E65"}
}
},
"transform": [
{
"type": "label",
"offset": [-15, 15],
"anchor": "right",
"size": [700, 500]
}
]
}
]
}