-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
68 lines (61 loc) · 1.77 KB
/
example.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
<html>
<body>
<div class="line" style="float:left;">
</div>
<div class="scatter" style="float:left;">
</div>
<div class="histogram" style="float:left;">
</div>
<div class="bar-div" style="float:left;">
</div>
</body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.10/d3.min.js"></script>
<script type="text/javascript" src="d3-charts.v3.min.js"></script>
<script type="text/javascript">
// line chart
var data = [{"x1": 1, "y1": 2},{"x1": 2, "y1": 6},{"x1": 3, "y1": 8}];
var options = {
element: ".line", // where to add the chart
data: data, // data
x: "x1", // name of x column
xMin: 0, // minimum value of x
xMax: 10, // maximum value of x
y: "y1", // name of y column
yMin: 0, // minimum value of y
yMax: 10, // maximum value of y
}
var line = new Line(options);
// scatter plot
var data = [{"x2": 1, "y2": 2},{"x2": 2, "y2": 6},{"x2": 3, "y2": 8}];
var options = {
element: ".scatter", // where to add the chart
data: data, // data
x: "x2", // name of x column
xMin: 0, // minimum value of x
xMax: 10, // maximum value of x
y: "y2", // name of y column
yMin: 0, // minimum value of y
yMax: 10, // maximum value of y
}
var scatter = new Scatter(options);
// histogram
var data = [{"x3": 1, "y3": 2},{"x3": 1, "y3": 6},{"x3": 2, "y3": 8}];
var options = {
element: ".histogram", // where to add the chart
data: data, // data
x: "x3" // name of x column
}
var histogram = new Histogram(options);
// bar chart
var data = [{"x4": "A", "y4": 100}, {"x4": "B", "y4": 50}, {"x4": "C", "y4": 77}];
var options = {
element: ".bar-div",
data: data,
x: "x4",
y: "y4",
yMin: 0,
yMax: 100
}
var bar = new Bar(options);
</script>
</html>