Skip to content

Instantly share code, notes, and snippets.

@davo

davo/index.html

Created Feb 13, 2015
Embed
What would you like to do?
Linea D, Julio por hora
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.x.axis path {
display: none;
}
.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
var margin = {top: 40, right: 20, bottom: 30, left: 50},
width = 1260 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var parseDate = d3.time.format("%m/%d/%Y").parse;
var parseHour = d3.time.format("%H:%M").parse;
var x = d3.time.scale()
.range([0, width]);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x).ticks(20)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var line = d3.svg.line()
// .defined(function(d) { return d.y != null; })
.interpolate("monotone")
.x(function(d) { return x(d.fecha); })
.y(function(d) { return y(d.cantidad); });
var svg = d3.select("body").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 + ")");
d3.csv("linea_d_junio-hora.csv", function(error, data) {
data.forEach(function(d) {
d.fecha = parseDate(d.fecha);
d.hora = parseHour(d.hora);
d.cantidad = +d.cantidad;
console.log(d);
});
x.domain(d3.extent(data, function(d) { return d.fecha; }));
y.domain(d3.extent(data, function(d) { return d.cantidad; }));
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Cantidad de pasajeros");
svg.append("path")
.datum(data)
.attr("class", "line")
.attr("d", line);
});
</script>
fecha hora cantidad
6/1/2014 5:00 1
6/1/2014 6:00 1
6/1/2014 7:00 35
6/1/2014 8:00 269
6/1/2014 9:00 312
6/1/2014 10:00 325
6/1/2014 11:00 352
6/1/2014 12:00 348
6/1/2014 13:00 359
6/1/2014 14:00 354
6/1/2014 15:00 353
6/1/2014 16:00 352
6/1/2014 17:00 353
6/1/2014 18:00 350
6/1/2014 19:00 334
6/1/2014 20:00 327
6/1/2014 21:00 292
6/1/2014 22:00 74
6/2/2014 3:00 1
6/2/2014 4:00 12
6/2/2014 5:00 188
6/2/2014 6:00 316
6/2/2014 7:00 411
6/2/2014 8:00 438
6/2/2014 9:00 440
6/2/2014 10:00 440
6/2/2014 11:00 448
6/2/2014 12:00 459
6/2/2014 13:00 459
6/2/2014 14:00 457
6/2/2014 15:00 458
6/2/2014 16:00 455
6/2/2014 17:00 452
6/2/2014 18:00 449
6/2/2014 19:00 426
6/2/2014 20:00 400
6/2/2014 21:00 345
6/2/2014 22:00 152
6/2/2014 23:00 1
6/3/2014 0:00 1
6/3/2014 4:00 17
6/3/2014 5:00 197
6/3/2014 6:00 332
6/3/2014 7:00 428
6/3/2014 8:00 448
6/3/2014 9:00 437
6/3/2014 10:00 446
6/3/2014 11:00 443
6/3/2014 12:00 451
6/3/2014 13:00 457
6/3/2014 14:00 455
6/3/2014 15:00 447
6/3/2014 16:00 442
6/3/2014 17:00 452
6/3/2014 18:00 440
6/3/2014 19:00 423
6/3/2014 20:00 403
6/3/2014 21:00 350
6/3/2014 22:00 151
6/3/2014 23:00 1
6/4/2014 0:00 1
6/4/2014 1:00 1
6/4/2014 4:00 15
6/4/2014 5:00 182
6/4/2014 6:00 326
6/4/2014 7:00 418
6/4/2014 8:00 441
6/4/2014 9:00 447
6/4/2014 10:00 446
6/4/2014 11:00 451
6/4/2014 12:00 454
6/4/2014 13:00 453
6/4/2014 14:00 452
6/4/2014 15:00 453
6/4/2014 16:00 451
6/4/2014 17:00 451
6/4/2014 18:00 440
6/4/2014 19:00 414
6/4/2014 20:00 392
6/4/2014 21:00 340
6/4/2014 22:00 163
6/4/2014 23:00 1
6/5/2014 0:00 1
6/5/2014 4:00 17
6/5/2014 5:00 199
6/5/2014 6:00 332
6/5/2014 7:00 419
6/5/2014 8:00 437
6/5/2014 9:00 440
6/5/2014 10:00 445
6/5/2014 11:00 453
6/5/2014 12:00 447
6/5/2014 13:00 452
6/5/2014 14:00 453
6/5/2014 15:00 455
6/5/2014 16:00 458
6/5/2014 17:00 462
6/5/2014 18:00 455
6/5/2014 19:00 441
6/5/2014 20:00 412
6/5/2014 21:00 365
6/5/2014 22:00 175
6/6/2014 0:00 1
6/6/2014 4:00 17
6/6/2014 5:00 186
6/6/2014 6:00 340
6/6/2014 7:00 414
6/6/2014 8:00 443
6/6/2014 9:00 441
6/6/2014 10:00 442
6/6/2014 11:00 455
6/6/2014 12:00 459
6/6/2014 13:00 452
6/6/2014 14:00 453
6/6/2014 15:00 448
6/6/2014 16:00 446
6/6/2014 17:00 444
6/6/2014 18:00 440
6/6/2014 19:00 435
6/6/2014 20:00 423
6/6/2014 21:00 383
6/6/2014 22:00 228
6/6/2014 23:00 1
6/7/2014 0:00 1
6/7/2014 4:00 6
6/7/2014 5:00 132
6/7/2014 6:00 253
6/7/2014 7:00 328
6/7/2014 8:00 356
6/7/2014 9:00 358
6/7/2014 10:00 366
6/7/2014 11:00 370
6/7/2014 12:00 376
6/7/2014 13:00 376
6/7/2014 14:00 363
6/7/2014 15:00 364
6/7/2014 16:00 369
6/7/2014 17:00 372
6/7/2014 18:00 375
6/7/2014 19:00 352
6/7/2014 20:00 357
6/7/2014 21:00 333
6/7/2014 22:00 158
6/7/2014 23:00 1
6/8/2014 7:00 36
6/8/2014 8:00 277
6/8/2014 9:00 302
6/8/2014 10:00 321
6/8/2014 11:00 328
6/8/2014 12:00 351
6/8/2014 13:00 352
6/8/2014 14:00 350
6/8/2014 15:00 364
6/8/2014 16:00 366
6/8/2014 17:00 362
6/8/2014 18:00 358
6/8/2014 19:00 358
6/8/2014 20:00 319
6/8/2014 21:00 289
6/8/2014 22:00 52
6/9/2014 4:00 11
6/9/2014 5:00 186
6/9/2014 6:00 351
6/9/2014 7:00 420
6/9/2014 8:00 440
6/9/2014 9:00 447
6/9/2014 10:00 444
6/9/2014 11:00 442
6/9/2014 12:00 440
6/9/2014 13:00 438
6/9/2014 14:00 452
6/9/2014 15:00 450
6/9/2014 16:00 445
6/9/2014 17:00 451
6/9/2014 18:00 450
6/9/2014 19:00 441
6/9/2014 20:00 418
6/9/2014 21:00 379
6/9/2014 22:00 172
6/9/2014 23:00 1
6/10/2014 1:00 1
6/10/2014 4:00 14
6/10/2014 5:00 188
6/10/2014 6:00 335
6/10/2014 7:00 416
6/10/2014 8:00 426
6/10/2014 9:00 434
6/10/2014 10:00 444
6/10/2014 11:00 453
6/10/2014 12:00 454
6/10/2014 13:00 447
6/10/2014 14:00 450
6/10/2014 15:00 452
6/10/2014 16:00 449
6/10/2014 17:00 449
6/10/2014 18:00 451
6/10/2014 19:00 439
6/10/2014 20:00 414
6/10/2014 21:00 392
6/10/2014 22:00 193
6/11/2014 0:00 1
6/11/2014 2:00 1
6/11/2014 4:00 15
6/11/2014 5:00 201
6/11/2014 6:00 348
6/11/2014 7:00 411
6/11/2014 8:00 441
6/11/2014 9:00 446
6/11/2014 10:00 450
6/11/2014 11:00 458
6/11/2014 12:00 462
6/11/2014 13:00 462
6/11/2014 14:00 458
6/11/2014 15:00 452
6/11/2014 16:00 450
6/11/2014 17:00 457
6/11/2014 18:00 451
6/11/2014 19:00 430
6/11/2014 20:00 409
6/11/2014 21:00 376
6/11/2014 22:00 181
6/12/2014 0:00 1
6/12/2014 4:00 4
6/12/2014 5:00 4
6/12/2014 6:00 22
6/12/2014 7:00 302
6/12/2014 8:00 328
6/12/2014 9:00 338
6/12/2014 10:00 338
6/12/2014 11:00 342
6/12/2014 12:00 344
6/12/2014 13:00 363
6/12/2014 14:00 330
6/12/2014 15:00 324
6/12/2014 16:00 328
6/12/2014 17:00 324
6/12/2014 18:00 321
6/12/2014 19:00 304
6/12/2014 20:00 273
6/12/2014 21:00 237
6/12/2014 22:00 83
6/13/2014 0:00 1
6/13/2014 4:00 6
6/13/2014 5:00 165
6/13/2014 6:00 319
6/13/2014 7:00 415
6/13/2014 8:00 441
6/13/2014 9:00 449
6/13/2014 10:00 444
6/13/2014 11:00 449
6/13/2014 12:00 449
6/13/2014 13:00 453
6/13/2014 14:00 447
6/13/2014 15:00 447
6/13/2014 16:00 455
6/13/2014 17:00 454
6/13/2014 18:00 453
6/13/2014 19:00 434
6/13/2014 20:00 401
6/13/2014 21:00 377
6/13/2014 22:00 197
6/13/2014 23:00 3
6/14/2014 0:00 1
6/14/2014 4:00 4
6/14/2014 5:00 150
6/14/2014 6:00 236
6/14/2014 7:00 313
6/14/2014 8:00 348
6/14/2014 9:00 349
6/14/2014 10:00 361
6/14/2014 11:00 369
6/14/2014 12:00 370
6/14/2014 13:00 373
6/14/2014 14:00 369
6/14/2014 15:00 369
6/14/2014 16:00 369
6/14/2014 17:00 356
6/14/2014 18:00 361
6/14/2014 19:00 346
6/14/2014 20:00 345
6/14/2014 21:00 346
6/14/2014 22:00 156
6/15/2014 2:00 1
6/15/2014 5:00 2
6/15/2014 7:00 21
6/15/2014 8:00 253
6/15/2014 9:00 281
6/15/2014 10:00 317
6/15/2014 11:00 330
6/15/2014 12:00 341
6/15/2014 13:00 309
6/15/2014 14:00 310
6/15/2014 15:00 327
6/15/2014 16:00 346
6/15/2014 17:00 337
6/15/2014 18:00 340
6/15/2014 19:00 269
6/15/2014 20:00 219
6/15/2014 21:00 293
6/15/2014 22:00 60
6/16/2014 4:00 9
6/16/2014 5:00 186
6/16/2014 6:00 334
6/16/2014 7:00 421
6/16/2014 8:00 442
6/16/2014 9:00 447
6/16/2014 10:00 446
6/16/2014 11:00 454
6/16/2014 12:00 456
6/16/2014 13:00 452
6/16/2014 14:00 451
6/16/2014 15:00 452
6/16/2014 16:00 450
6/16/2014 17:00 445
6/16/2014 18:00 440
6/16/2014 19:00 435
6/16/2014 20:00 406
6/16/2014 21:00 378
6/16/2014 22:00 169
6/16/2014 23:00 1
6/17/2014 0:00 1
6/17/2014 3:00 1
6/17/2014 4:00 17
6/17/2014 5:00 193
6/17/2014 6:00 338
6/17/2014 7:00 416
6/17/2014 8:00 440
6/17/2014 9:00 442
6/17/2014 10:00 441
6/17/2014 11:00 447
6/17/2014 12:00 453
6/17/2014 13:00 452
6/17/2014 14:00 449
6/17/2014 15:00 453
6/17/2014 16:00 449
6/17/2014 17:00 450
6/17/2014 18:00 441
6/17/2014 19:00 437
6/17/2014 20:00 410
6/17/2014 21:00 389
6/17/2014 22:00 191
6/18/2014 0:00 1
6/18/2014 4:00 13
6/18/2014 5:00 198
6/18/2014 6:00 340
6/18/2014 7:00 428
6/18/2014 8:00 437
6/18/2014 9:00 441
6/18/2014 10:00 446
6/18/2014 11:00 448
6/18/2014 12:00 453
6/18/2014 13:00 451
6/18/2014 14:00 447
6/18/2014 15:00 446
6/18/2014 16:00 448
6/18/2014 17:00 451
6/18/2014 18:00 449
6/18/2014 19:00 444
6/18/2014 20:00 423
6/18/2014 21:00 379
6/18/2014 22:00 212
6/19/2014 0:00 2
6/19/2014 4:00 19
6/19/2014 5:00 201
6/19/2014 6:00 342
6/19/2014 7:00 411
6/19/2014 8:00 438
6/19/2014 9:00 437
6/19/2014 10:00 444
6/19/2014 11:00 448
6/19/2014 12:00 450
6/19/2014 13:00 447
6/19/2014 14:00 448
6/19/2014 15:00 453
6/19/2014 16:00 448
6/19/2014 17:00 447
6/19/2014 18:00 445
6/19/2014 19:00 429
6/19/2014 20:00 409
6/19/2014 21:00 391
6/19/2014 22:00 237
6/19/2014 23:00 4
6/20/2014 0:00 1
6/20/2014 3:00 1
6/20/2014 5:00 1
6/20/2014 6:00 1
6/20/2014 7:00 54
6/20/2014 8:00 317
6/20/2014 9:00 340
6/20/2014 10:00 345
6/20/2014 11:00 348
6/20/2014 12:00 354
6/20/2014 13:00 356
6/20/2014 14:00 363
6/20/2014 15:00 361
6/20/2014 16:00 357
6/20/2014 17:00 354
6/20/2014 18:00 352
6/20/2014 19:00 351
6/20/2014 20:00 344
6/20/2014 21:00 320
6/20/2014 22:00 77
6/20/2014 23:00 1
6/21/2014 4:00 3
6/21/2014 5:00 128
6/21/2014 6:00 221
6/21/2014 7:00 304
6/21/2014 8:00 322
6/21/2014 9:00 342
6/21/2014 10:00 343
6/21/2014 11:00 347
6/21/2014 12:00 347
6/21/2014 13:00 323
6/21/2014 14:00 308
6/21/2014 15:00 332
6/21/2014 16:00 346
6/21/2014 17:00 342
6/21/2014 18:00 353
6/21/2014 19:00 347
6/21/2014 20:00 329
6/21/2014 21:00 323
6/21/2014 22:00 153
6/22/2014 6:00 1
6/22/2014 7:00 23
6/22/2014 8:00 224
6/22/2014 9:00 282
6/22/2014 10:00 292
6/22/2014 11:00 316
6/22/2014 12:00 328
6/22/2014 13:00 320
6/22/2014 14:00 343
6/22/2014 15:00 343
6/22/2014 16:00 341
6/22/2014 17:00 340
6/22/2014 18:00 338
6/22/2014 19:00 328
6/22/2014 20:00 306
6/22/2014 21:00 262
6/22/2014 22:00 36
6/23/2014 4:00 19
6/23/2014 5:00 176
6/23/2014 6:00 321
6/23/2014 7:00 404
6/23/2014 8:00 436
6/23/2014 9:00 442
6/23/2014 10:00 451
6/23/2014 11:00 449
6/23/2014 12:00 453
6/23/2014 13:00 452
6/23/2014 14:00 448
6/23/2014 15:00 452
6/23/2014 16:00 449
6/23/2014 17:00 454
6/23/2014 18:00 446
6/23/2014 19:00 440
6/23/2014 20:00 424
6/23/2014 21:00 383
6/23/2014 22:00 177
6/24/2014 2:00 1
6/24/2014 4:00 19
6/24/2014 5:00 196
6/24/2014 6:00 345
6/24/2014 7:00 421
6/24/2014 8:00 436
6/24/2014 9:00 440
6/24/2014 10:00 445
6/24/2014 11:00 446
6/24/2014 12:00 446
6/24/2014 13:00 453
6/24/2014 14:00 427
6/24/2014 15:00 458
6/24/2014 16:00 454
6/24/2014 17:00 450
6/24/2014 18:00 448
6/24/2014 19:00 436
6/24/2014 20:00 422
6/24/2014 21:00 397
6/24/2014 22:00 196
6/25/2014 1:00 1
6/25/2014 4:00 20
6/25/2014 5:00 201
6/25/2014 6:00 338
6/25/2014 7:00 418
6/25/2014 8:00 446
6/25/2014 9:00 440
6/25/2014 10:00 449
6/25/2014 11:00 451
6/25/2014 12:00 451
6/25/2014 13:00 430
6/25/2014 14:00 427
6/25/2014 15:00 447
6/25/2014 16:00 445
6/25/2014 17:00 446
6/25/2014 18:00 447
6/25/2014 19:00 436
6/25/2014 20:00 418
6/25/2014 21:00 400
6/25/2014 22:00 214
6/26/2014 4:00 13
6/26/2014 5:00 199
6/26/2014 6:00 338
6/26/2014 7:00 421
6/26/2014 8:00 446
6/26/2014 9:00 449
6/26/2014 10:00 449
6/26/2014 11:00 449
6/26/2014 12:00 450
6/26/2014 13:00 449
6/26/2014 14:00 444
6/26/2014 15:00 448
6/26/2014 16:00 439
6/26/2014 17:00 446
6/26/2014 18:00 445
6/26/2014 19:00 435
6/26/2014 20:00 424
6/26/2014 21:00 403
6/26/2014 22:00 208
6/26/2014 23:00 1
6/27/2014 1:00 1
6/27/2014 2:00 1
6/27/2014 4:00 13
6/27/2014 5:00 189
6/27/2014 6:00 343
6/27/2014 7:00 408
6/27/2014 8:00 441
6/27/2014 9:00 448
6/27/2014 10:00 451
6/27/2014 11:00 456
6/27/2014 12:00 450
6/27/2014 13:00 451
6/27/2014 14:00 448
6/27/2014 15:00 442
6/27/2014 16:00 438
6/27/2014 17:00 450
6/27/2014 18:00 450
6/27/2014 19:00 444
6/27/2014 20:00 421
6/27/2014 21:00 396
6/27/2014 22:00 226
6/27/2014 23:00 1
6/28/2014 0:00 1
6/28/2014 1:00 2
6/28/2014 4:00 11
6/28/2014 5:00 142
6/28/2014 6:00 260
6/28/2014 7:00 328
6/28/2014 8:00 353
6/28/2014 9:00 359
6/28/2014 10:00 375
6/28/2014 11:00 375
6/28/2014 12:00 375
6/28/2014 13:00 371
6/28/2014 14:00 367
6/28/2014 15:00 356
6/28/2014 16:00 375
6/28/2014 17:00 368
6/28/2014 18:00 364
6/28/2014 19:00 367
6/28/2014 20:00 356
6/28/2014 21:00 334
6/28/2014 22:00 167
6/29/2014 5:00 2
6/29/2014 7:00 33
6/29/2014 8:00 257
6/29/2014 9:00 295
6/29/2014 10:00 321
6/29/2014 11:00 341
6/29/2014 12:00 334
6/29/2014 13:00 333
6/29/2014 14:00 328
6/29/2014 15:00 331
6/29/2014 16:00 342
6/29/2014 17:00 344
6/29/2014 18:00 339
6/29/2014 19:00 336
6/29/2014 20:00 328
6/29/2014 21:00 287
6/29/2014 22:00 49
6/30/2014 0:00 1
6/30/2014 4:00 18
6/30/2014 5:00 200
6/30/2014 6:00 336
6/30/2014 7:00 410
6/30/2014 8:00 431
6/30/2014 9:00 441
6/30/2014 10:00 450
6/30/2014 11:00 442
6/30/2014 12:00 433
6/30/2014 13:00 426
6/30/2014 14:00 433
6/30/2014 15:00 430
6/30/2014 16:00 439
6/30/2014 17:00 441
6/30/2014 18:00 431
6/30/2014 19:00 423
6/30/2014 20:00 414
6/30/2014 21:00 386
6/30/2014 22:00 206
6/30/2014 23:00 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment