-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
109 lines (96 loc) · 2.95 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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>d3 charts boilerplate materialize CSS</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="node_modules/materialize-css/bin/materialize.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="css/chart.css" rel="stylesheet" type="text/css" />
<link href="css/materialize.css" rel="stylesheet" type="text/css" />
</head>
<body>
<nav class="white" role="navigation">
<div class="nav-wrapper container">
<a id="logo-container" href="#" class="brand-logo">Charts</a>
<ul class="right hide-on-med-and-down">
<li><a href="#">About</a></li>
</ul>
<ul id="nav-mobile" class="side-nav">1
<li><a href="#">Navbar Link</a></li>
</ul>
<a href="#" data-activates="nav-mobile" class="button-collapse"><i class="material-icons">menu</i></a>
</div>
</nav>
<div id="index-banner" class="parallax-container">
<div class="section no-pad-bot">
<div class="container" id="viz"></div>
</div>
</div>
<script src="node_modules/d3/build/d3.js"></script>
<script src="js/chart.js"></script>
<script>
var data = [
{id: 0, x : 20, y : 30, label : 'item 0'},
{id: 1, x : 100, y: 190, label : 'item 1'},
{id: 2, x : 300, y: 100, label : 'item 2'},
{id: 3, x : 300, y: 100, label : 'item 3'},
{id: 4, x : 30, y: 90, label : 'item 4'}
];
var margin = {top: 30, right: 20, bottom: 30, left: 50},
width = 600 - margin.left - margin.right,
height = 600 - margin.top - margin.bottom;
var svg = d3.select("#viz")
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var charts = [
chart()
.params({
"data": data,
"var_id": "id",
"var_x": "x",
"var_x": "y",
"title": "my first chart",
"translate": [0, 0]
}),
chart()
.params({
"data": data,
"var_x": "y",
"var_x": "x",
"title": "my second chart",
"translate": [0, 200]
}),
chart()
.params({
"data": data,
"var_x": "x",
"var_x": "x",
"title": "my third chart",
"translate": [0, 400]
})
];
var chart = svg.selectAll('charts').data(charts)
.enter()
.append('g')
.attr('transform', function(d) { return 'translate(' + d.params().translate + ')'; })
.each(function(c, i) {
c.on("click", renderAll);
c.on("hover", function(d) {
chart.each(function(e) {
e.highlight(d);
});
});
});
function render(method) {
d3.select(this).call(method);
}
function renderAll() {
chart.each(render);
}
renderAll();
</script>
</body>
</html>