-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_vega.html
65 lines (58 loc) · 1.86 KB
/
project_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
<!DOCTYPE html>
<head>
<title>Vega Lite Bar Chart</title>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega/3.0.8/vega.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega-lite/2.0.4/vega-lite.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega-embed/3.0.0-rc7/vega-embed.js"></script>
<!--uncomment if you decide to use advanced tooltips-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega-tooltip/0.4.4/vega-tooltip.js"></script>
<link rel="stylesheet" type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/vega-tooltip/0.4.4/vega-tooltip.css">
<!--d3 and jquery might be helpful if you want to load data only once-->
<script src="https://d3js.org/d3.v4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<style media="screen">
/* Add space between Vega-Embed links */
.vega-actions a {
margin-right: 5px;
}
</style>
</head>
<body>
<!-- Container for the visualization -->
<div id="chart1"></div>
<div id="chart2"></div>
<script>
//initiate renderer, use it for all vega-embed.
var opt = {"renderer": "svg", mode: "vega-lite"};
var width = 600;
//chart 1
spec1 =
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"data": {
"url": "a1-burtin.csv"
},
"mark": "point",
"encoding": {
"column": {
"field": "Staining",
"type": "nominal"
},
"x": {
"field": "Bacteria",
"type": "nominal"
},
"y": {
"aggregate": "mean",
"field": "Penicilin",
"type": "quantitative"
}
},
"width":width
}
vegaEmbed("#chart1",spec1, opt)
</script>
</body>
</html>