-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
614 lines (548 loc) · 25.2 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>PEV Deployment Simulator V4</title>
<!-- jquery -->
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<!-- leaflet setting -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-wcw6ts8Anuw10Mzh9Ytw4pylW8+NAD4ch3lqm9lzAsTxg0GFeJgoAtxuCLREZSC5lUXdVyo/7yfsqFjQ4S+aKw==" crossorigin="" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-mNqn2Wg7tSToJhvHcqfzLMU6J4mkOImSPTxVZAdo+lcPlk+GhZmYgACEe0x35K7YzW1zJ7XyJV/TT1MrdXvMcA==" crossorigin=""></script>
<script src='https://api.mapbox.com/mapbox.js/v3.1.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.1.1/mapbox.css' rel='stylesheet' />
<script type='text/javascript'>
TIME = 0;
</script>
<!-- js -->
<script type="text/javascript" src="js/Timer.js"></script>
<script type="text/javascript" src="js/mapdata2.js"></script>
<script type="text/javascript" src="js/BostonTee.js"></script>
<script type="text/javascript" src="js/Graphs.js"></script>
<script type="text/javascript" src="js/Progress.js"></script>
<script type="text/javascript" src="js/Sim.js"></script>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
<!-- libraries -->
<script type="text/javascript" src="js/lib/AnimatedMaker.js"></script>
<script type="text/javascript" src="js/lib/MovingMarker.js"></script>
<script type="text/javascript" src="js/lib/Leaflet.Marker.SlideTo.js"></script>
<script type="text/javascript" src="js/lib/leafletheat.js"></script>
<script type="text/javascript" src="js/lib/Polyline.encoded.js"></script>
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300, 300italic,400,600,800,800italic,600italic' rel='stylesheet' type='text/css'>
<!-- Access Token -->
<script src='https://api.mapbox.com/mapbox-gl-js/v0.42.0/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v0.42.0/mapbox-gl.css' rel='stylesheet' />
<!-- Double Slider -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="css/map.css">
</link>
</head>
<body style="font-family: 'Open Sans', sans-serif" onload="fuzz()">
<div id="map-canvas">
</div>
<!-- File Loading Menu -->
<!-- TODO: upload file to server for sim -->
<!-- <div id="form" class="style-upper-right">
<div id="input">
<form id="taxi-data">
<div>
<label for="trip-file" class="center"> Trip File: </label>
<input id="trip-file" name="trip-file" type="file" />
<button id="bothBtn" onclick="both()">Bike & Taxi</button>
<button id="bikeBtn" onclick="bike()">Bike</button>
<button id="driveBtn" onclick="car()">Taxi</button>
</div>
</form>
</div>
</div> -->
<!-- <div id="results">
<table>
<tr>
<th>Waiting Time Average</th>
<th>Waiting Time Median</th>
<th>Item3</th>
</tr>
<tr>
<th id="wtavg">0</th>
<th id="wtmd">0</th>
<th>3</th>
</tr>
</table>
</div> -->
<p id="debugclock" style="opacity:0">0</p>
<p id="debugtripcount" style="opacity:0">0</p>
<!-- <p id="debugspeed" style="color:white">600</p> -->
<div id="controls">
<div id="title-outer" style="margin-top: 10px">
<h1 style="font-style:italic; font-weight:700">PEV SimApp Demo</h1> <p style="font-weight:100; margin-top: -2px; font-style:italic; font-size:1em; ">Beta V4 | City Science @ MIT Media Lab</p>
</div>
<!-- <p style="font-weight:300; font-style:italic; font-size:1em; ">How many Shared Autonomous Vehicles do we need in a city? </p> -->
<!-- </div> -->
<!-- <div id="city-select"> -->
<!-- <input class="button city" value="Boston" onclick="setMapBoston()"> -->
<!-- <input class="button city" value="Paris"> -->
<!-- <input class="button city" value="Taipei"> -->
<!-- </div> -->
<!-- <div style="color: white; margin-top: 10px">
<div style="font-weight:600">
<i class="fa fa-percent"></i> UTILIZATION
</div>
<div>
<div style="display: inline-block; color: #FFFF00"> <i class="fa fa-child"></i> </div>
<div style="display: inline-block; color: #FF9900 "> <i class="fa fa-cube"></i> </div>
<div style="display: inline-block">
<div class="chartControl">
<div style="display: inline-block; font-size: .8em"><input type="radio" name="mode" value="grouped"> Combined</div>
<div style="display: inline-block; font-size: .8em"><input type="radio" name="mode" value="stacked" checked> Split</div>
</div>
</div>
</div>
<div id="utilization_chart"> </div>
</div> -->
<!-- <div style="color: white; margin-top: 10px; font-weight:600">
<i class="fa fa-sellsy"></i> EMISSIONS
<div id="emission_chart" style="margin-top: 18px"> </div>
</div> -->
<div id="sliders" style="margin-left: -7px; margin-top: 40px">
<div class="control-section">
<div class="control-label">SUPPLY</div>
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">Number of PEVs</span>
<i class="fa fa-rocket"></i> Fleet Size
</label>
<input type="text" id="fleet">
</p>
<div id="sliderfleet" class="ui-slider" style="margin-top: -10px"></div>
<!-- <p class="slider-label"> -->
<!-- <label style="font-weight:600"> <i class="fa fa-rocket"></i>Rebal PEVs:</label> -->
<!-- <input type="text" id="rebalance"> -->
<!-- </p> -->
<!-- <div id="sliderRebalance" style="margin-top: -10px"></div> -->
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">Defines the number of charging stations, using existing shared bike stations as proxy through random sampling.</span>
<i class="fas fa-bolt"></i> Charging Stations
</label>
<input type="text" id="charging">
</p>
<div id="sliderChargingStations" class="ui-slider" style="margin-top: -10px"></div>
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">Defines maximum journey distance for the PEV to serve.</span>
<i class="fas fa-road"></i> Max Job Distance
</label>
<input type="text" id="maxdist">
</p>
<div id="slidermax" class="ui-slider" style="margin-top: -10px"></div>
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">OFF: Uses exact coordinates of shared bike stations as origin/destination | ON: Approximate a walkable locations nearby shared bike station as origin/destination.</span>
<i class="fas fa-cloud"></i> Fuzzing
</label>
<input type="text" id="fuzzing">
</p>
<div style="margin-top: -10px">
<label class="switch">
<input type="checkbox" id="toggleFuzzing" name="fuzz" onclick="fuzz();"/>
<span class="slider"/>
</label>
</div>
<p class="slider-label" style="margin-top: 5px">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">Allows PEVs to move toward favorable positions (currently using randomized destinations without specific rebalancing heuristics</span>
<i class="fas fa-balance-scale"></i> Fleet Rebalancing
</label>
<input type="text" id="rebalance">
</p>
<div style="margin-top: -10px">
<label class="switch">
<input type="checkbox" id="toggleRebalancing" name="rebalance" onclick="rebalance();"/>
<span class="slider"/>
</label>
</div>
</div>
<div class="control-section" style="margin-top: 10px">
<div class="control-label">DEMAND</div>
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">Source: 2012 Boston taxi data</span>
<i class="fas fa-taxi"></i> Taxi Trips
</label>
<input type="text" id="taxidata">
</p>
<div id="slidertaxi" style="margin-top: -10px"></div>
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext" style="width:240px">Source: 2018 Hubway(BlueBike) Data</span>
<i class="fas fa-bicycle"></i> Shared Bike Trips
</label>
<input type="text" id="bikedata">
</p>
<div id="sliderbike" class="ui-slider" style="margin-top: -10px"></div>
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">Last-mile journeys to/from tran stations. Source: sampled from MBTA data from https://github.com/mbta/gtfs-documentation/</span>
<i class="fas fa-train"></i> Train Station
</label>
<input type="text" id="traindata">
</p>
<div id="slidertrain" class="ui-slider" style="margin-top: -10px"></div>
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">Source: Randomly generated jobs</span>
<i class="fas fa-globe"></i> Random Data
</label>
<input type="text" id="randomdata">
</p>
<div id="sliderrandom" class="ui-slider" style="margin-top: -10px"></div>
<!-- <p class="slider-label">
<label style="font-weight:600"> <i class="fas fa-clock"></i>Sim Length</label>
<input type="text" id="simhrs">
</p>
<div id="sliderhrs" style="margin-top: -10px"></div> -->
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">Filters the O/D data above by time period</span>
<i class="fas fa-clock"></i> Sim Length</label>
<input type="text" id="hours">
</p>
<div id="slider-time" class="ui-slider" style="margin-top: -10px"></div>
<p class="slider-label">
<label class="label-text" style="font-weight:600"> <i class="fas fa-arrows-alt-h"></i> Sim Speed</label>
<input type="text" id="simspeed">
</p>
<div id="sliderspeed" class="ui-slider" style="margin-top: -10px"></div>
<p class="slider-label">
<label class="label-text" style="font-weight:600">
<span class="tooltiptext">Defines the passengers' maximum tolerance for waiting for a service</span>
<i class="fas fa-tasks"></i> Cancellation Threshhold
</label>
<input type="text" id="dropping">
</p>
<div id="sliderJobDrop" class="ui-slider" style="margin-top: -10px"></div>
</div>
<input class="button func" class="btn btn-xs" style="font-weight:600; margin-top: 35px; width: 261px; background-color: transparent; border-color:#ff66cc; color: #ff66cc" value="Simulate" onclick="fleet_sim()">
</div>
<!--
<p id="debugclock" style="opacity:0">0</p>
<p id="debugtripcount" style="opacity:0">0</p>
-->
<!-- <input class="button func" value="Change Map" class="btn btn-xs" style="font-weight:600; margin-top: 10px; width: 200px; background-color: transparent; border-color:#ff66cc; color: #ff66cc" onclick="changeMap()"> -->
</div>
</div>
<div id="graphs">
</div>
<table id="summary">
<thead>
<td>Trial</td>
<td>PEVs</td>
<td>Charging Stations</td>
<td>Max Job Distance</td>
<td>Fuzzing</td>
<td>Rebalancing</td>
<td>Total Trips</td>
<td>Taxi / Bike / Train / Random</td>
<td>Trips/Hr</td>
<td>Cancellation Threshhold</td>
<!-- <td>Pickup Time</td>
<td>Assignment Time</td> -->
<td>Avg Wait Time</td>
<td>50th % Wait Time</td>
<td>75th % Wait Time</td>
<!-- <td>Avg Empty Trips</td>
<td>Avg Job Trips</td> -->
<td>People/Parcel Utilization</td>
<td>Vehicle Utilization</td>
</thead>
<tbody>
</tbody>
</table>
<div id="loader" class="disabled">
<svg version="1.1" id="loader-1" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 50 50" xml:space="preserve">
<path fill="#ff66cc" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z">
<animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite" />
</path>
</svg>
</div>
<div id="progress"></div>
<div id="myProgress">
<div id="barBackdrop">
<div id="myBar"></div>
</div>
<svg height="20px" width="100%">
<text text-anchor="start" x="0%" y="15" fill="white">12am</text>
<text text-anchor="middle" x="25%" y="15" fill="white">6am</text>
<text text-anchor="middle" x="50%" y="15" fill="white">12pm</text>
<text text-anchor="middle" x="75%" y="15" fill="white">6pm</text>
<text text-anchor="end" x="100%" y="15" fill="white">12am</text>
</svg>
</div>
<!-- center -->
<script>
function drawEmissionChart(emissions) {
var names = ['PEV', 'Taxi', 'Uber'],
//emissions = [2, 10, 5],
chart,
width = 225,
bar_height = 20,
height = bar_height * names.length;
/* step 1 */
chart = d3.select($("#step-1")[0])
.append('svg')
.attr('class', 'chart')
.attr('width', width)
.attr('height', height);
/* step 2 */
var x, y;
x = d3.scale.linear()
.domain([0, d3.max(emissions)])
.range([0, width]);
y = d3.scale.ordinal()
.domain(emissions)
.rangeBands([0, height]);
chart.selectAll("rect")
.data(emissions)
.enter().append("rect")
.attr("x", 0)
.attr("y", y)
.attr("width", x)
.attr("height", bar_height);
var xAxis = d3.svg.axis()
.scale(x)
/* step 3 */
chart = d3.select($("#step-3")[0])
.append('svg')
.attr('class', 'chart')
.attr('width', width)
.attr('height', height);
chart.selectAll("rect")
.data(emissions)
.enter().append("rect")
.attr("x", 0)
.attr("y", y)
.attr("width", x)
.attr("height", y.rangeBand());
chart.selectAll("text")
.data(emissions)
.enter().append("text")
.attr("x", x)
.attr("y", function(d) { return y(d) + y.rangeBand() / 2; })
.attr("dx", -5)
.attr("dy", ".36em")
.attr("text-anchor", "end")
.text(String);
/* step 4 */
var left_width = 30;
chart = d3.select($("#step-4")[0])
.append('svg')
.attr('class', 'chart')
.attr('width', left_width + width)
.attr('height', height);
chart.selectAll("rect")
.data(emissions)
.enter().append("rect")
.attr("x", left_width)
.attr("y", y)
.attr("width", x)
.attr("height", y.rangeBand());
chart.selectAll("text.score")
.data(emissions)
.enter().append("text")
.attr("x", function(d) { return x(d) + left_width; })
.attr("y", function(d) { return y(d) + y.rangeBand() / 2; })
.attr("dx", -5)
.attr("dy", ".36em")
.attr("text-anchor", "start")
.attr('class', 'score')
.text(String);
chart.selectAll("text.name")
.data(names)
.enter().append("text")
.attr("x", left_width / 2)
.attr("y", function(d, i) { return y(emissions[i]) + y.rangeBand() / 2; })
.attr("dy", ".36em")
.attr("text-anchor", "start")
.attr('class', 'name')
.text(String);
/* step 5 */
var gap = 2;
// redefine y for adjusting the gap
y = d3.scale.ordinal()
.domain(emissions)
.rangeBands([0, (bar_height + 2 * gap) * names.length]);
d3.select("#emissions_data").remove();
// TODO
chart = d3.select($("#emission_chart")[0])
.append('svg').attr("id", "emissions_data")
.attr('class', 'chart')
.attr('width', left_width + width + 40)
.attr('height', (bar_height + gap * 2) * names.length + 30)
.append("g")
.attr("transform", "translate(10, 20)");
// chart.selectAll("line")
// .data(x.ticks(d3.max(emissions)))
// .enter().append("line")
// .attr("x1", function(d) { return x(d) + left_width; })
// .attr("x2", function(d) { return x(d) + left_width; })
// .attr("y1", 0)
// .attr("y2", (bar_height + gap * 2) * names.length);
// chart.selectAll(".rule")
// .data(x.ticks(d3.max(emissions)))
// .enter().append("text")
// .attr("class", "rule")
// .attr("x", function(d) { return x(d) + left_width; })
// .attr("y", 0)
// .attr("dy", -6)
// .attr("text-anchor", "middle")
// .attr("font-size", 10)
// .text(String);
chart.selectAll("rect")
.data(emissions)
.enter().append("rect")
.attr("x", left_width)
.attr("y", function(d) { return y(d) + gap; })
.attr("width", x)
.attr("height", bar_height);
// TODO see if we can round the labels to a couple decimal places
chart.selectAll("text.score")
.data(emissions)
.enter().append("text")
.attr("x", function(d) { return x(d) + left_width; })
.attr("y", function(d, i) { return y(d) + y.rangeBand() / 2; })
.attr("dx", -5)
.attr("dy", ".36em")
.attr("text-anchor", "end")
.attr('class', 'score')
//.text(String);
.text(d3.format("2.2f"))
.attr("transform", "translate(30, 0)");
chart.selectAll("text.name")
.data(names)
.enter().append("text")
.attr("x", left_width / 2)
.attr("y", function(d, i) { return y(emissions[i]) + y.rangeBand() / 2; })
.attr("dy", ".36em")
.attr("text-anchor", "middle")
.attr('class', 'name')
.text(String);
};
</script>
<!-- Utilization Chart -->
<script>
var n = 2, // number of layers
m = 24, // number of samples per layer
parcel_color = "#FF9900",
passenger_color = "#FFFF00",
stack = d3.layout.stack(),
layers = stack(d3.range(n).map(function() { return bumpLayer(m, .1); }));
function drawUtil(layers) {
var yGroupMax = d3.max(layers, function(layer) { return d3.max(layer, function(d) { return d.y; }); }),
yStackMax = d3.max(layers, function(layer) { return d3.max(layer, function(d) { return d.y0 + d.y; }); });
var margin = { top: 30, right: 10, bottom: 20, left: 10 },
width = 280;
// height = 125 - margin.top - margin.bottom;
height = 65;
var x = d3.scale.ordinal()
.domain(d3.range(m))
.rangeRoundBands([0, width], .08);
var y = d3.scale.linear()
.domain([0, yStackMax])
.range([height, 0]);
var color = d3.scale.linear()
.domain([0, n - 1])
.range([parcel_color, passenger_color]);
var xAxis = d3.svg.axis()
.scale(x)
.tickSize(0)
.tickPadding(6)
.orient("bottom");
d3.select("#util_data").remove();
var svg = d3.select($("#utilization_chart")[0]).append("svg")
.attr("id", "util_data")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var layer = svg.selectAll(".layer")
.data(layers)
.enter().append("g")
.attr("class", "layer")
.style("fill", function(d, i) { return color(i); });
var rect = layer.selectAll("rect")
.data(function(d) { return d; })
.enter().append("rect")
.attr("x", function(d) { return x(d.x); })
.attr("y", height)
.attr("width", x.rangeBand())
.attr("height", 0);
rect.transition()
.delay(function(d, i) { return i * 10; })
.attr("y", function(d) { return y(d.y0 + d.y); })
.attr("height", function(d) { return y(d.y0) - y(d.y0 + d.y); });
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.attr("fill", "#ffffff")
.attr("font-size", "40px")
.call(xAxis);
d3.selectAll("input").on("change", change);
var timeout = setTimeout(function() {
d3.select("input[value=\"grouped\"]").property("checked", true).each(change);
}, 2000);
function change() {
clearTimeout(timeout);
if (this.value === "stacked") transitionGrouped();
else transitionStacked();
}
function transitionGrouped() {
y.domain([0, yGroupMax]);
rect.transition()
.duration(500)
.delay(function(d, i) { return i * 10; })
.attr("x", function(d, i, j) { return x(d.x) + x.rangeBand() / n * j; })
.attr("width", x.rangeBand() / n)
.transition()
.attr("y", function(d) { return y(d.y); })
.attr("height", function(d) { return height - y(d.y); });
}
function transitionStacked() {
y.domain([0, yStackMax]);
rect.transition()
.duration(500)
.delay(function(d, i) { return i * 10; })
.attr("y", function(d) { return y(d.y0 + d.y); })
.attr("height", function(d) { return y(d.y0) - y(d.y0 + d.y); })
.transition()
.attr("x", function(d) { return x(d.x); })
.attr("width", x.rangeBand());
}
}
// Inspired by Lee Byron's test data generator.
function bumpLayer(n, o) {
function bump(a) {
var x = 1 / (.1 + Math.random()),
y = 2 * Math.random() - .5,
z = 10 / (.1 + Math.random());
for (var i = 0; i < n; i++) {
var w = (i / n - y) * z;
a[i] += x * Math.exp(-w * w);
}
}
var a = [],
i;
for (i = 0; i < n; ++i) a[i] = o + o * Math.random();
for (i = 0; i < 5; ++i) bump(a);
return a.map(function(d, i) { return { x: i, y: Math.max(0, d) }; });
}
</script>
</script>
<div id="txt"></div>
</body>
</html>