-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab2.2.html
69 lines (63 loc) · 1.69 KB
/
Lab2.2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="description" content="Data Visualisation Exercise 1"/>
<meta name="keywords" content="HTML, CSS"/>
<meta name="author" content="Your name here"/>
<title>Task 2.2 D3 Drawing with Data - Bar Chart</title>
<!--Insert description of exercise -->
<script src="https://d3js.org/d3.v7.min.js"></script>
<style>
h1{
font-family: Arial, Helvetica, sans-serif;
color:rgb(51, 230, 114);
}
rect{
fill: grey;
}
p{
color:rgb(236, 4, 253);
}
</style>
</head>
<body>
<h1>Drawing with Data - Bar Chart</h1>
<script>
var w = 500;
var h = 100;
var barPadding = 2;
var dataset = [60, 5, 26, 63, 20, 10, 72, 100];
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
svg.selectAll("rect")
.data(dataset)
.enter()
.append("rect")
.attr("x", function(d,i){
return i*(w/dataset.length)
})
.attr("y", function (d){
return h-(d)
})
.attr("width", function (d){
return w/dataset.length - barPadding
})
.attr("height", function (d){
return d
});
</script>
<p>
Go to <a href="/index.html">Lab 1 </a><a href="/lab2.1.html">,Lab 2 </a>
<a href="/Lab3/Lab3.1.html">,Lab 3 </a><a href="/Lab5/Lab5.1.html">,Lab 5 </a>
<a href="/Lab6/Lab6.1.html">,Lab 6 </a><a href="/Lab7/Lab7.1.html">,Lab 7 </a>
<a href="/Lab8/Lab8.1.html">,Lab 8 </a>
<br>Lab task 2.1 <a href="/lab2.1.html">D3 Data Binding</a>
<br>Lab task 2.3 <a href="/lab2.3.html">Drawing with Data - Scatter Plot</a>
<br>Lab task 2.4 <a href="/Lab2.4.html">D3 Load CSV</a>
</p>
<footer style="color: gray;">COS30045 Data Visualisation <br> Semester 4 2022</footer>
</body>
</html>