-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
232 lines (202 loc) · 7.34 KB
/
index.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!doctype html>
<html>
<head>
<title>Embedding Vega-Lite</title>
<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 class="header">
<h2>ELL824: SELECTED TOPICS IN INFORMATION PROCESSING - II ( Data Visualization)</br>Name: Palash Nandi. (EEZ228472)</br></br></br></h2>
<h3></h3>
</div>
<div>
<p>
   <b>Q1.</b> Load the HW data.</br></br>
   <b>Step 1:</b> HW_Excel.csv is uploaded at Github ( PalGitts / ELL824 ).</br>
   <b>Step 2:</b> Raw link of the dataset is used in VegaLite-Emb code to fetch the data.</br>
</p>
</div>
<div id="vis"></div>
<div style="text-align:right;">
<script type="text/javascript">
var combined = {
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
data: {
"url":"https://raw.githubusercontent.com/PalGitts/ELL824/main/HW_Excel.csv"
},
vconcat: [
{
"title": {
"text": "Q2: Create a Bar Graph showing Rep vs Total and sort the data by Total.",
"anchor": "middle", "orient": "top"
},
mark: { "type":"bar", "cornerRadiusEnd": 5, "color":"silver", "tooltip": true },
"width": 450,
"height": 300,
encoding: {
x: {field: "Rep", sort:"-y"},
y: {aggregate: "sum", field:"Total"},
"color": {"aggregate": "sum", "field": "Total"}
}
}, // Q2
{
"title": {
"text": "Q3: Create a Pie Chart showing Item and Units.",
"anchor": "middle", "orient": "top"
},
mark: {type: "arc", "tooltip": true},
"width": 300,
"height": 300,
encoding: {
theta: {field: "Units", type: "quantitative",aggregate: "sum"},
color: {field: "Item", type: "nominal", "stack": true}
}
}, // Q3
{
"layer": [
{
"title": {
"text": "Q4: Create a view showing the correlation between Units and Unit Cost. Color by Item.",
"anchor": "middle", "orient": "top"
},
"mark": {"type": "point", "filled": true, "tooltip": true},
"width": 550,
"height": 300,
"encoding": {
"x": {"field": "Units", "type": "quantitative"},
"y": {"field": "UnitCost", "type": "quantitative"},
color: {field: "Item", type: "nominal",legend: null},
}
},
{
"mark": {"type": "line", "color": "firebrick", "tooltip": true},
"transform": [
{"regression": "UnitCost", "on": "Units"}
],
"encoding": {
"x": {"field": "Units", "type": "quantitative"},
"y": {"field": "UnitCost", "type": "quantitative"}
}
},
{
"transform": [
{
"regression": "UnitCost",
"on": "Units",
"params": true
},
{"calculate": "'R²: '+format(datum.rSquared, '.2f')", "as": "R2"}
],
"mark": {
"type": "text",
"color": "firebrick",
"x": "width",
"align": "right",
"y": -5,
"tooltip": true
},
"encoding": {"text": {"type": "nominal", "field": "R2"}}
}
]
}, //Q4
{
"title": {
"text": "Q5 (version 1): Create a line graph showing how the Total varied over time (year wise).",
"anchor": "middle", "orient": "top"
},
mark: {
type: "line", "tooltip": true
},
"width": 450,
"height": 300,
encoding: {
y: {field: "Total", type: "quantitative",aggregate: 'sum'},
x: {field: "OrderDate",timeUnit: "year",type: "temporal", axis: {labelAngle: 5}},
"color": {"value": "black"},
}
}, // Q5
{
"title": {
"text": "Q5 (version 2): Create a line graph showing how the Total varied over time (month wise).",
"anchor": "middle", "orient": "top"
},
mark: {
type: "line", "tooltip": true
},
"width": 450,
"height": 200,
encoding: {
y: {field: "Total", type: "quantitative",aggregate: 'sum'},
x: {field: "OrderDate",timeUnit: "yearmonth",type: "temporal", axis: {labelAngle: 1}},
"color": {"value": "green"},
}
}, // Q5
{
layer: [
{
mark: {"type": "bar", "tooltip": true },
"title": {
"text": "Q6 (version 1): Create a Histogram of the Units. Add an overlay of the global mean. ( Without bin )",
"anchor": "middle", "orient": "top"
},
encoding: {
x: {
bin: false,
field: "Units"
},
y: {aggregate: "count",axis: {orient: "left", title: "Count"}},
"color": {"aggregate": "count", "field": "Units"}
}
},
{
mark: { "type": "rule", "tooltip": true },
encoding: {
y: {field: "Units", aggregate: "mean", axis: {orient: "right"} },
size: {value: 0.5},
"color": {"value": "red"},
}
}
],
resolve: {scale: {y: "independent"}}
}, // Q6
{
layer: [
{
mark: { "type": "bar", "tooltip": true },
"width": 450,
"height": 200,
"title": {
"text": "Q6 (version 2): Create a Histogram of the Units. Add an overlay of the global mean. ( With bin )",
"anchor": "middle", "orient": "top"
},
encoding: {
x: {
bin: true,
field: "Units"
},
y: {aggregate: "count",axis: {orient: "left", title: "Count"}},
"color": {"aggregate": "count", "field": "Units"}
}
},
{
mark: { "type":"rule", "tooltip": true},
"width": 450,
"height": 200,
encoding: {
y: {field: "Units", aggregate: "mean", axis: {orient: "right"} },
size: {value: 0.5},
"color": {"value": "red"},
}
}
],
resolve: {scale: {y: "independent"}}
} // Q6
]
}
vegaEmbed("#vis", combined);
</script>
</div>
</body>
</html>