forked from maxmcd/rickshaw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulti.html
112 lines (94 loc) · 2.52 KB
/
multi.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
<!doctype html>
<head>
<link type="text/css" rel="stylesheet" href="../rickshaw.css">
<link type="text/css" rel="stylesheet" href="css/lines.css">
<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css">
<script src="../node_modules/d3/build/d3.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js"></script>
<script src="../rickshaw.js"></script>
<style>
.column { display: inline-block }
#legend { background: white }
#legend .line { color: #333 }
</style>
</head>
<body>
<div class="column">
<div id="chart"></div>
<div id="slider"></div>
</div>
<div class="column" id="legend"></div>
<script>
var seriesData = [ [], [], [], [], [] ];
var random = new Rickshaw.Fixtures.RandomData(50);
for (var i = 0; i < 75; i++) {
random.addData(seriesData);
}
var d = new Date();
d.setMinutes(d.getMinutes() + 30);
var graph = new Rickshaw.Graph( {
element: document.getElementById("chart"),
renderer: 'multi',
width: 900,
height: 500,
dotSize: 5,
bands: [{
color: "#30c020",
from: d/1000,
to: Number(d)/1000+(60*10),
name: "10min 30min from now",
opacity: 0.2
}],
series: [
{
name: 'temperature',
data: seriesData.shift(),
color: 'rgba(255, 0, 0, 0.4)',
renderer: 'stack'
}, {
name: 'heat index',
data: seriesData.shift(),
color: 'rgba(255, 127, 0, 0.4)',
renderer: 'stack'
}, {
name: 'dewpoint',
data: seriesData.shift(),
color: 'rgba(127, 0, 0, 0.3)',
renderer: 'scatterplot'
}, {
name: 'pop',
data: seriesData.shift().map(function(d) { return { x: d.x, y: d.y / 4 } }),
color: 'rgba(0, 0, 127, 0.4)',
renderer: 'bar'
}, {
name: 'humidity',
data: seriesData.shift().map(function(d) { return { x: d.x, y: d.y * 1.5 } }),
renderer: 'line',
color: 'rgba(0, 0, 127, 0.25)'
}
]
} );
var slider = new Rickshaw.Graph.RangeSlider.Preview({
graph: graph,
element: document.querySelector('#slider')
});
graph.render();
var detail = new Rickshaw.Graph.HoverDetail({
graph: graph
});
var legend = new Rickshaw.Graph.Legend({
graph: graph,
element: document.querySelector('#legend')
});
var highlighter = new Rickshaw.Graph.Behavior.Series.Highlight({
graph: graph,
legend: legend,
disabledColor: function() { return 'rgba(0, 0, 0, 0.2)' }
});
var highlighter = new Rickshaw.Graph.Behavior.Series.Toggle({
graph: graph,
legend: legend
});
</script>
</body>