-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexamples.html
146 lines (116 loc) · 6 KB
/
examples.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>D3-smokechart by dyninc</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<style type="text/css">
body{font-family:Tahoma,Arial,sans-serif}
h1,h2{clear:both}
h2{padding-top:2em}
h4{font-family:Arial,sans-serif;font-size:.9em;font-weight:normal}
section{width:auto;clear:both}
section div{float:left;margin-left:20px}
path.line{fill:none;opacity:.6;stroke-width:1.5px}
.chart {margin-bottom:3em}
.available{opacity:.8;fill:#060;stroke-width:1px;stroke-color:red}
.unavailable{opacity:1;fill:#000}
.avlpercent{font-size:8px;font-family:sans;fill:white;font-weight:bold;opacity:.9}
.label{font-size:8px;font-family:sans;fill:#333;opacity:.9}
.axis{shape-rendering:crispEdges;opacity.5;fill:#777}
.axis text{font-size:8px;font-family:sans;fill:#333}
.y.axis line,.y.axis path{fill:none;stroke:#777}
.guide{shape-rendering:crispEdges;opacity:1;stroke-width:1px!important;}
header,footer{opacity:.7}
</style>
</head>
<body>
<h1>D3 SmokeChart Examples</h1>
<section>
<div id="chart1" class='chart'><h4>Basic Line Chart</h4></div>
<div id="chart2" class='chart'><h4>With Error Markers</h4></div>
<div id="chart4" class='chart'><h4>With Availability Info</h4></div>
</section>
<section>
<div id="chart3" class='chart'><h4>With "SmokePing" Effect</h4></div>
<div id="chart5" class='chart'><h4>With Labels and Guides</h4></div>
<div id="chart6" class='chart'><h4>Dynamic Chart <a href='#' style='display:none'>[click to update]</a></h4> </div>
</section>
<h2>How "FlameChart" is different?</h2>
<section>
<div id="chart-smoke" class='chart'><h4>SmokeChart</h4></div>
<div id="chart-flame" class='chart'><h4>FlameChart</h4></div>
</section>
<script type="text/javascript" src="d3.v2.min.js"></script>
<script type="text/javascript" src="smokechart.js"></script>
<script>
var smoke1 = new SmokeChart("#chart1", 160, 28, 60, 150);
smoke1.addLine('l',d3.transpose([
[7,10,3,3,3,4,5,3,5,3,3,3,4,4,4,2,3,12,3,4,3,5,4,4,3,4,3,19,4,3,3,3,3,7,6,3,5,3,3,4,3,4,5,4,4,44,15,3,3,4,4,3,3,3,125,4,4,38,2,4,11,5,3,3,3,4],
]), "#900", "#999");
var smoke2 = new SmokeChart("#chart2", 160, 28, 60, 45);
smoke2.addLine('l',d3.transpose([
[3,4,7,26,6,3,5,2,4,5,3,2,7,3,3,3,5,5,2,2,4,3,3,3,3,10,2,2,20,3,2,2,6,2,3,4,3,2,3,2,3,3,3,2,7,6,4,6,3,4,2,3,3,7,3,3,25,4,2,4,2,3,2,7,4,11]
]), "#333", "#000").showMarkers([
0,
10,10,10,10,
35,
45,46,47,47,47,48,48,48,49,49,50,55
]);
var smoked_data = [
[38,3,3,3,38,38], [12,4,4,4,12,12], [8,7,7,7,8,8], [9,26,26,26,9,9], [11,6,6,6,11,11], [8,11,11,11,8,8],
[10,3,3,3,10,10], [8,5,5,5,8,8], [8,2,2,2,8,8], [80,4,4,4,80,8], [8,5,5,5,8,8], [8,3,3,3,8,8],
[11,2,2,2,11,11], [11,7,7,7,11,11], [96,3,3,3,96,96], [9,3,3,3,9,9], [8,3,3,3,8,8], [90,5,5,5,90,9],
[27,5,5,5,27,27], [8,2,2,2,8,8], [9,2,2,2,9,9], [9,4,4,4,9,9], [9,3,3,3,9,9], [15,3,3,3,15,15],
[8,3,3,3,8,8], [9,3,3,3,9,9], [90,10,10,10,90,9], [10,2,2,2,10,10], [12,2,2,2,12,12], [9,20,20,20,9,9],
[8,3,3,3,8,8], [9,2,2,2,9,9], [11,2,2,2,11,11], [9,6,6,6,9,9], [8,2,2,2,8,8], [42,3,3,3,42,42],
[30,4,4,4,30,30], [8,3,3,3,8,8], [8,2,2,2,8,8], [8,3,3,3,8,8], [10,2,2,2,10,10], [9,3,3,3,9,9],
[9,3,3,3,9,9], [8,3,3,3,8,8], [8,2,2,2,8,8], [23,7,7,7,23,23], [14,6,6,6,14,14], [9,4,4,4,9,9],
[10,6,6,6,10,10], [8,3,3,3,8,8], [9,4,4,4,9,9], [9,2,2,2,9,9], [9,3,3,3,9,9], [14,3,3,3,14,14],
[9,7,7,7,9,9], [12,3,3,3,12,12], [10,3,3,3,10,10], [44,25,25,25,44,44], [8,4,4,4,8,8], [9,2,2,2,9,9],
[9,4,4,4,9,9], [18,2,2,2,18,18], [13,3,3,3,13,13], [12,2,2,2,12,12], [8,7,7,7,8,8], [14,4,4,4,14,14]
];
var smoke3 = new SmokeChart("#chart3", 160, 28, 60, 295);
smoke3.addLine('l',smoked_data, "#000", "#f76");
var smoke4 = new SmokeChart("#chart4", 160, 28, 60, 125);
smoke4.height(85);
smoke4.addLine('l',d3.transpose([
[28,29,28,27,49,27,27,29,27,28,28,28,29,29,27,27,27,28,27,124,28,27,35,27,27,27,49,28,28,30,27,28,28,27,27,27,30,28,31,27,27,29,35,28,28,28,27,29,27,35,34,27,28,27,29,27,28,28,28,29,28,27,45,27,28,29,27,27,27]
]), "#33C", "#000").showAvailability([
100,98,100,100,100
], 25);
var smoke5 = new SmokeChart("#chart5", 195, 28, 60, 1500);
smoke5.yaxis("left",35,2);
smoke5.addGuide('z', 0, '#999').addGuide('d',1000,'#Faa').addLine('l',d3.transpose([
[254,253,228,250,272,256,233,289,332,366,326,281,274,314,304,280,260,342,324,359,363,479,319,343,315,846,327,811,300,347,353,354,889,416,907,417,434,401,422,405,374,430,407,394,440,1157,409,448,444,421,412,415,423,421,315,510,501,494,422,349,391]
]), "#040", "#000").showLabels(['', '', '14:00', '', '', '14:30']).selectAll('.label').attr("transform", "translate(0,-10)");
var smoke6 = new SmokeChart("#chart6", 195, 28, 60, 350);
var i = 0, j=0, l1=[1,2,3,4,5], l2=[6,7,8,9,10];
var data1 = d3.range(60).map(function(d){
i = Math.floor(i+Math.random()*100) % 300;
j = Math.floor(i+Math.random()*10) % 30;
return [i-d,j,d-j,d/2,d/4,d]
});
var data2 = d3.range(60).map(function(d){
i = Math.floor(i/2+Math.random()*100) % 300;
j = Math.floor(j/2+Math.random()*10) % 30;
return [i-d,j,d-j,15-d/4,60-d,30-d/2]
});
smoke6.showLabels(l1).addLine('u', data1, "#222", "#f00");
smoke6.parentNode.selectAll("#chart6 a").style("display", "inline").on('click', function() {
smoke6.updateLine('u', data2).showLabels(l2);
var tmp = data2;
data2 = data1; data1 = tmp;
tmp = l2;
l2 = l1; l1 = tmp;
d3.event.stopPropagation();
d3.event.preventDefault();
});
var smoke_big = new SmokeChart("#chart-smoke", 400, 80, 60, 295);
smoke_big.addLine('l',smoked_data, "#000", "#f76");
var flame_big = new FlameChart("#chart-flame", 400, 80, 60, 295);
flame_big.addLine('l',smoked_data, "#000", "#f76");
</script>
<a href="http://github.com/dyninc/d3-smokechart"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/abad93f42020b733148435e2cd92ce15c542d320/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub"></a>
</body>
</html>