1
|
{
|
2
|
"$schema": "https://vega.github.io/schema/vega/v5.json",
|
3
|
"width": 400,
|
4
|
"height": 200,
|
5
|
"padding": 5,
|
6
|
|
7
|
"data": [
|
8
|
{
|
9
|
"name": "table",
|
10
|
"values": [
|
11
|
{"category": "A", "amount": 28},
|
12
|
{"category": "B", "amount": 55},
|
13
|
{"category": "C", "amount": 43},
|
14
|
{"category": "D", "amount": 91},
|
15
|
{"category": "E", "amount": 81},
|
16
|
{"category": "F", "amount": 53},
|
17
|
{"category": "G", "amount": 19},
|
18
|
{"category": "H", "amount": 87}
|
19
|
]
|
20
|
}
|
21
|
],
|
22
|
|
23
|
"signals": [
|
24
|
{
|
25
|
"name": "tooltip",
|
26
|
"value": {},
|
27
|
"on": [
|
28
|
{"events": "rect:mouseover", "update": "datum"},
|
29
|
{"events": "rect:mouseout", "update": "{}"}
|
30
|
]
|
31
|
}
|
32
|
],
|
33
|
|
34
|
"scales": [
|
35
|
{
|
36
|
"name": "yscale",
|
37
|
"type": "band",
|
38
|
"domain": {"data": "table", "field": "category"},
|
39
|
"range": "height",
|
40
|
"padding": 0.05,
|
41
|
"round": true
|
42
|
},
|
43
|
{
|
44
|
"name": "xscale",
|
45
|
"domain": {"data": "table", "field": "amount"},
|
46
|
"nice": true,
|
47
|
"range": "width"
|
48
|
}
|
49
|
],
|
50
|
|
51
|
"axes": [
|
52
|
{ "orient": "bottom", "scale": "xscale" },
|
53
|
{ "orient": "left", "scale": "yscale" }
|
54
|
],
|
55
|
|
56
|
"marks": [
|
57
|
{
|
58
|
"type": "rect",
|
59
|
"from": {"data":"table"},
|
60
|
"encode": {
|
61
|
"enter": {
|
62
|
"y": {"scale": "yscale", "field": "category"},
|
63
|
"height": {"scale": "yscale", "band": 1},
|
64
|
"x": {"scale": "xscale", "field": "amount"},
|
65
|
"x2": {"scale": "xscale", "value": 0}
|
66
|
},
|
67
|
"update": {
|
68
|
"fill": {"value": "steelblue"}
|
69
|
},
|
70
|
"hover": {
|
71
|
"fill": {"value": "red"}
|
72
|
}
|
73
|
}
|
74
|
}
|
75
|
]
|
76
|
}
|