-
Notifications
You must be signed in to change notification settings - Fork 2
/
drawCompany.js
62 lines (49 loc) · 1.22 KB
/
drawCompany.js
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
// HTML and CSS_style to go here.
// init src="d3/d3.js"
// size of the captable.svg bars
var w = 500;
var h = 100;
var barPadding = 1;
// insert source captable data here
// create SVG element for making a bar chart
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", w / dataset.length - barPadding)
.attr("height", function(d) {
return d;
});
// we would need to add colour.
.attr("fill". function(d) {
return "rgb(0, 0, " + (d *10) + ")";
});
// we would need to show data values as well. add text elements to svg
svg.selectAll("text")
.data(dataset)
.enter()
.append("text")
.text(function(d) {
return d;
})
.attr("text-anchor", "middle")
.attr("x", function(d, i) {
return i * (w / dataset.length) + (w / dataset.length - barPadding) / 2;
})
.attr("y", function(d) {
return h - (d * 4) +14;
})
.attr("font-family", "equity")
.attr("font-size", "11px")
.attr("fill", "white");
hello i am everyone is seeing the changes!