-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathburtin-vega.html
73 lines (68 loc) · 2.17 KB
/
burtin-vega.html
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
<!DOCTYPE html>
<html>
<head>
<title>Burtin Vega</title>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
</head>
<body>
<div id="chart"></div>
<script>
var spec = {
"$schema": "https://vega.github.io/schema/vega/v4.json",
"width": 400,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"url": "data.csv",
"format": {"type": "csv"}
}
],
"scales": [
{
"name": "yscale",
"type": "band",
"domain": {"data": "table", "field": "Bacteria"},
"range": "height",
"padding": 0.5
},
{
"name": "xscale",
"type": "linear",
"domain": {"data": "table", "field": "Penicilin"},
"range": "width",
"zero": true,
"nice": true
}
],
"axes": [
{ "orient": "left", "scale": "yscale" },
{ "orient": "bottom", "scale": "xscale" }
],
"marks": [{
"type": "rect",
"from": {"data":"table"},
"encode": {
"enter": {
"y": {"scale": "yscale", "field": "Bacteria"},
"height ": {"scale": "yscale", "band": 1},
"x": {"scale": "xscale", "field": "Penicilin"},
"x2": {"scale": "xscale", "value": 0}
},
"update": {
"fill": {"value": "steelblue"}
},
"hover": {
"fill": {"value": "red"}
}
}
}]
}
vegaEmbed("#chart", spec);
</script>
</body>
</html>