-
Notifications
You must be signed in to change notification settings - Fork 181
/
index.html
649 lines (578 loc) · 29.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
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>P2Pool</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<script type="text/javascript" src="d3.v2.min.js"></script>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/jquery.jqplot.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.jqplot.min.js"></script>
<script class="include" language="javascript" type="text/javascript" src="js/jqplot.pieRenderer.min.js"></script>
<style>
body {
padding-top: 60px;
}
line {
stroke: black;
stroke-width: 1;
shape-rendering: crispEdges;
}
.plotline {
stroke-width: 1.4;
fill: none;
}
text {
font-family: Sans-serif;
font-size: 12px;
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<script type="text/javascript">
// based on goblin's p2pool-stats project
var period = "day";
function LoadData()
{
$("#blocks").html("<tr><th>ID</th><th>Time</th><th>Hash / Explorer link</th><th>Share</th></tr>");
$("#payouts").html("<tr><th>address</th><th>amount in <span class=\"symbol\"></span></th></tr>");
function values(o){ res = []; for(var x in o) res.push(o[x]); return res; }
d3.json('/web/version', function(version) {
d3.selectAll('#version').text(version);
});
d3.json('/web/currency_info', function(currency_info) {
d3.selectAll('.symbol').text(currency_info.symbol);
d3.json('/current_payouts', function(pays) {
d3.json('/payout_addr', function(addr) {
d3.select('#payout_addr').text(addr);
d3.select('#payout_amount').text(addr in pays ? pays[addr] : 0);
});
var arr = []; for(var i in pays) arr.push(i); arr.sort(function(a, b){return pays[b] - pays[a]});
var tr = d3.select('#payouts').selectAll().data(arr).enter().append('tr');
tr.append('td').append('a').text(function(addr){return addr}).attr('href', function(addr){return currency_info.address_explorer_url_prefix + addr});
tr.append('td').text(function(addr){return pays[addr]});
var total_tr = d3.select('#payouts').append('tr');
total_tr.append('td').append('strong').text('Total');
total_tr.append('td').text(d3.sum(arr, function(addr){return pays[addr]}).toFixed(8));
});
d3.json('/recent_blocks', function(blocks) {
var tr = d3.select('#blocks').selectAll().data(blocks).enter().append('tr');
tr.append('td').text(function(block){return block.number});
tr.append('td').text(function(block){return new Date(1000*block.ts).toString()});
tr.append('td').append('a').text(function(block){return block.hash}).attr('href', function(block){return currency_info.block_explorer_url_prefix + block.hash});
tr.append('td').append('a').text('→').attr('href', function(block){return 'share.html#' + block.share});
});
});
$("#best_share").html("");
$("#verified_heads").html("");
$("#heads").html("");
$("#verified_tails").html("");
$("#tails").html("");
d3.json('/web/best_share_hash', function(c) {
d3.select('#best_share').append('a').attr('href', 'share.html#' + c).text(c.substr(-8));
});
function fill(url, id) {
d3.json(url, function(d) {
d.sort()
d3.select(id).selectAll().data(d).enter().append('span').text(' ').append('a').attr('href', function(c){return 'share.html#' + c}).text(function(c){return c.substr(-8)});
});
}
fill('/web/verified_heads', '#verified_heads');
fill('/web/heads', '#heads');
fill('/web/verified_tails', '#verified_tails');
fill('/web/tails', '#tails');
fill('../web/my_share_hashes', '#my_share_hashes');
}
var plot1;
var plot2;
function UpdateData()
{
function values(o){ res = []; for(var x in o) res.push(o[x]); return res; }
d3.json('/local_stats', function(local_stats) {
d3.select('#peers_in').text(local_stats.peers.incoming);
d3.select('#peers_out').text(local_stats.peers.outgoing);
var local = d3.sum(values(local_stats.miner_hash_rates));
var local_dead = d3.sum(values(local_stats.miner_dead_hash_rates));
d3.select('#local_rate').text(d3.format('.3s')(local) + 'H/s');
d3.select('#local_doa').text(d3.format('.2p')(local_dead/local));
d3.select('#shares_total').text(local_stats.shares.total);
d3.select('#shares_orphan').text(local_stats.shares.orphan);
d3.select('#shares_dead').text(local_stats.shares.dead);
d3.select('#efficiency').text(local_stats.efficiency != null ? d3.format('.4p')(local_stats.efficiency) : '???')
d3.select('#uptime_days').text(d3.format('.3f')(local_stats.uptime / 60 / 60 / 24));
d3.select('#uptime_hours').text(d3.format('.3f')(local_stats.uptime / 60 / 60 ));
d3.select('#block_value').text(local_stats.block_value);
d3.select('#warnings').selectAll().data(local_stats.warnings).enter().append('p')
.text(function(w){ return 'Warning: ' + w })
.attr('style', 'color:red;border:1px solid red;padding:5px');
var time_to_share = local_stats.attempts_to_share/local;
d3.select('#time_to_share').text(d3.format('.3r')(time_to_share/3600) + " hours");
d3.select('#time_to_share_minute').text(d3.format('.3r')(time_to_share / 60) + " ");
d3.json('/global_stats', function(global_stats) {
d3.select('#pool_rate').text(d3.format('.3s')(global_stats.pool_hash_rate) + 'H/s');
d3.select('#pool_stale').text(d3.format('.2p')(global_stats.pool_stale_prop));
d3.select('#difficulty').text(d3.format('.3r')(global_stats.min_difficulty));
var time_to_block = local_stats.attempts_to_block/global_stats.pool_hash_rate;
d3.select('#time_to_block').text(d3.format('.3r')(time_to_block/3600) + " hours");
d3.select('#expected_payout_amount').text(d3.format('.3r')(local/global_stats.pool_hash_rate*local_stats.block_value*(1-local_stats.donation_proportion)));
/// ============================================
var data = [
['Local speed', local],['Local dead speed', local_dead], ['Global speed', global_stats.pool_hash_rate]
];
if (plot2) {plot2.destroy();}
$("#targetPlot2").remove();
$("#SpeedChart").append("<div id='targetPlot2'></div>");
plot2 = jQuery.jqplot ('targetPlot2', [data],
{
seriesDefaults: {
// Make this a pie chart.
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
showDataLabels: true
}
},
legend: { show:true, location: 'e' }
}
);
});
/// ============================================
var data = [
['Good', local_stats.shares.total - (local_stats.shares.orphan + local_stats.shares.dead)],['Dead', local_stats.shares.dead], ['Orphaned', local_stats.shares.orphan]
];
if (plot1) {plot1.destroy();}
$("#targetPlot1").remove();
$("#ShareChart").append("<div id='targetPlot1'></div>");
plot1 = jQuery.jqplot ('targetPlot1', [data],
{
seriesDefaults: {
// Make this a pie chart.
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
showDataLabels: true
}
},
legend: { show:true, location: 'e' }
}
);
});
/// pool speed grapg
plot_later(d3.select("#main-local"), "H/s", "H", [
{"url": "/web/graph_data/local_hash_rate/last_" + period, "color": "#0000FF", "label": "Total"},
{"url": "/web/graph_data/local_dead_hash_rate/last_" + period, "color": "#FF0000", "label": "Dead"}
],1000,300);
}
function ChangeCurrentPeriod(p_Period, p_Sender)
{
period=p_Period;
UpdateData();
$('#scale_menu li').removeClass('active');
$('#' + p_Sender).addClass('active');
}
function AutoRefresh()
{
if($("#autorefresh").prop('checked'))
{
UpdateData();
}
}
</script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="/">P2Pool pool (<span class="symbol upper"></span>)</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="index.html">Stats</a></li>
<li><a href="graphs.html">Graph</a></li>
<li><a href="https://github.com/hardcpp/P2PoolExtendedFrontEnd">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#stats" data-toggle="tab"><i class="icon-user"></i> Pool stats</a></li>
<li><a href="#shares" data-toggle="tab"><i class="icon-refresh"></i> Share explorer</a></li>
<li><a href="#lastblocks" data-toggle="tab"><i class="icon-list-alt"></i> Last blocks</a></li>
<li><a href="#mainnodepayout" data-toggle="tab"><i class="icon-download-alt"></i> Payout</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="stats">
<center>
<div class="well" style="width:1000px">
<div class="navbar" style="width: 560px;">
<div class="navbar-inner">
<a class="brand" href="javascript:void(0)">Scale</a>
<ul class="nav" id="scale_menu">
<li id="scale1"><a href="javascript:ChangeCurrentPeriod('hour', 'scale1');">Hour</a></li>
<li id="scale2" class="active"><a href="javascript:ChangeCurrentPeriod('day', 'scale2');">Day</a></li>
<li id="scale3"><a href="javascript:ChangeCurrentPeriod('week', 'scale3');">Week</a></li>
<li id="scale4"><a href="javascript:ChangeCurrentPeriod('month', 'scale4');">Month</a></li>
<li id="scale5"><a href="javascript:ChangeCurrentPeriod('year', 'scale5');">Year</a></li>
<li><input type="checkbox" name="autorefresh" id="autorefresh" /><label for="autorefresh">Auto-refresh</label></li>
</ul>
</div>
</div>
<svg id="main-local"></svg></div>
<br/>
<div class="well" style="width:1300px">
<table class="table table-striped" style="width: 1300px">
<tbody>
<tr>
<td><h5>Local rate</h5></td>
<td><span id="local_rate" class="label"></span> (<span id="local_doa"></span> DOA)</td>
<td></td>
<td><h5>Expected time to share</h5></td>
<td><span id="time_to_share" class="label"></span> (<span id="time_to_share_minute"></span> minutes)</td>
</tr>
<tr>
<td><h5>Shares</h5></td>
<td><span id="shares_total" class="label"></span> total (<span id="shares_orphan" class="label label-warning"></span> orphaned, <span id="shares_dead" class="label label-warning"></span> dead) Efficiency: <span class="label label-info" id="efficiency"></span></td>
<td></td>
<td><h5>Payout if a block were found NOW</h5></td>
<td><span id="payout_amount" class="label"></span> <span class="symbol"></span></td>
</tr>
<tr>
<tr>
<td><h5>Pool rate</h5></td>
<td><span id="pool_rate" class="label label-inverse"></span> (<span id="pool_stale"></span> DOA+orphan)</td>
<td></td>
<td><h5>Share difficulty</h5></td>
<td><span id="difficulty" class="label label-inverse"></span></td>
</tr>
<tr>
<td><h5>Node uptime</h5></td>
<td><span id="uptime_days" class="label label-inverse"></span> (<span id="uptime_hours"></span> hours)</td>
<td></td>
<td><h5>Peers</h5></td>
<td><span id="peers_out"></span> out, <span id="peers_in"></span> in</td>
</tr>
<td><h5>Current block value</h5></td>
<td><span id="block_value" class="label label-inverse"></span> <span class="symbol"></span></td>
<td></td>
<td><h5>Expected time to block</h5></td>
<td><span id="time_to_block" class="label"></span></td>
</tr>
</tbody>
</table>
</div>
<br/>
<div style="width: 1340px">
<div class="well" style="width:600px; float: left">
<h4>Local Shares</h4>
<div id="ShareChart" width="450" height="450"></div>
</div>
<div class="well" style="width:600px; float: right">
<h4>Global pool speed</h4>
<div id="SpeedChart" width="450" height="450"></div>
</div>
</div>
</center>
</div>
<div class="tab-pane" id="shares">
<p>Best share: <span id="best_share"></span></p>
<p>Verified heads: <span id="verified_heads"></span></p>
<p>Heads: <span id="heads"></span></p>
<p>Verified tails: <span id="verified_tails"></span></p>
<p>Tails: <span id="tails"></span></p>
<p>My Shares: <span id="my_share_hashes"></span></p>
</div>
<div class="tab-pane" id="lastblocks">
<table id="blocks" class="table table-striped table-hover">
<tr><th>ID</th><th>Time</th><th>Hash / Explorer link</th><th>Share</th></tr>
</table>
</div>
<div class="tab-pane" id="mainnodepayout">
<table class="table table-striped table-hover" id="payouts">
<tr><th>Address</th><th>Amount (<span class="symbol"></span>) </th></tr>
</table>
</div>
</div>
<div style="border-bottom: 1px solid #ddd;"></div>
<center>
<tt>P2Pool version: <span id="version"></span></tt><br/>
<tt>Interface by hardcpp <a href="https://github.com/hardcpp/P2PoolExtendedFrontEnd">https://github.com/hardcpp/P2PoolExtendedFrontEnd</a></tt><br/>
<tt>Donate if you love it (LTC LdKxw2JewLdo1atDsQ33LiCG9ZUDQ4XmPb) (BTC 1FBa12SPET7YRGHoTXyawp1EBJyFPzju31)</tt>
</center>
<br/>
<script type="text/javascript">
function compose() {
var funcs = arguments;
return function(x) {
for(var i = funcs.length-1; i >= 0; i--) {
x = funcs[i](x);
}
return x;
}
}
function itemgetter(i) { return function(x) { return x[i]; } }
function as_date(x) { return new Date(1000*x); }
function not_null(x) { return x != null; }
function get_area_mean(data) {
var top = 0;
var bottom = 0;
for(var i = 0; i < data.length; i++) {
if(data[i][1] == null) continue; // no data for bin
top += data[i][1] * data[i][2];
bottom += data[i][2];
}
return {"area": top, "mean": bottom==0?null:top/bottom};
}
function plot(g, unit, total_unit, lines,ww,hh,stack) {
// lines is a list of objects which have attributes data, color, and label
var table_div = document.createElement("div");
g.node().parentNode.insertBefore(table_div, g.node().nextSibling);
table_div.style.display = "none";
for(var i = 0; i < lines.length; ++i) {
var line = lines[i];
var table_sel = d3.select(table_div).append('table').attr('border', 1).attr('style', 'float:left');
var first_tr = table_sel.insert('tr');
first_tr.append('th').text('Date');
first_tr.append('th').text(line.label + '/(' + unit + ')');
var new_data = []
for(var j = 0; j < line.data.length; ++j)
if(j % 7 == 3)
new_data.push(line.data[j]);
var tr = table_sel.selectAll().data(new_data).enter().append('tr');
tr.append('td').text(function(datum){return new Date(1000*datum[0]).toString()});
tr.append('td').text(function(datum){return d3.format(".3s")(datum[1])});
}
var margin_v = 40;
var margin_h = 140;
var w = ww;
var h = hh;
var x = d3.time.scale().domain([
as_date(d3.min(lines, function(line) { return d3.min(line.data, itemgetter(0)); })),
as_date(d3.max(lines, function(line) { return d3.max(line.data, itemgetter(0)); }))
]).range([0 + margin_h, w - margin_h]);
g.attr("width", w).attr("height", h);
g.selectAll("*").remove();
if(stack) {
var data = d3.layout.stack()
.x(itemgetter(0))
.y(itemgetter(1))
.values(function(line){ return line.data })
(lines);
var y = d3.scale.linear().domain([
0,
d3.max(data, function(d) { return d3.max(d.data, function(d) { return d.y0 + d.y; }) })
]).range([h - margin_v, margin_v]);
var y_abs = d3.scale.linear().domain([0, 1]).range([h - margin_v, margin_v]);
g.selectAll().data(lines).enter().append("svg:path")
.attr("d", function(line){
return d3.svg.area()
.x(function(d) { return x(as_date(d[0])) })
.y0(function(d) { return y(d.y0) })
.y1(function(d) { return y(d.y0 + d.y) })
.defined(compose(not_null, itemgetter(1)))
(line.data)
})
.style("fill", function(line){return line.color})
.attr("stroke", function(line){return line.color})
.attr("class", "plotline");
var total = 0;
var total_area = 0;
for(var i = 0; i < lines.length; ++i) {
var line = lines[i];
var stats = get_area_mean(line.data);
if(stats.mean != null) {
total += stats.mean;
total_area += stats.area;
}
}
for(var i = 0; i < lines.length; ++i) {
var line = lines[i];
var stats = get_area_mean(line.data);
if(stats.mean != null) {
var num = 0;
var denom = 0;
for(var j = 0; j < line.data.length; j++)
if(line.data[j] != null) {
var d = line.data[j];
num += (d.y+1)*((d.y0 + d.y) + (d.y0))/2;
denom += (d.y+1);
}
g.append("svg:line")
.style("stroke", line.color)
.attr("x1", w - margin_h + 3)
.attr("y1", y(num/denom))
.attr("x2", w - margin_h + 10)
.attr("y2", y_abs(i/lines.length));
g.append("svg:text")
.text(line.label + " (mean: " + d3.format(".3s")(stats.mean) + unit + ")")
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h + 10)
.attr("y", y_abs(i/lines.length));
if(total_unit != null)
g.append("svg:text")
.text("Area: " + d3.format(".3s")(stats.area) + total_unit + " (" + d3.format(".2p")(stats.area/total_area) + " total)")
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h + 10)
.attr("y", y_abs(i/lines.length) + 12);
}
}
g.append("svg:line")
.style("stroke", "black")
.attr("x1", w - margin_h + 3)
.attr("y1", y(total))
.attr("x2", w - margin_h + 10)
.attr("y2", y_abs(1));
g.append("svg:text")
.text("Total (mean: " + d3.format(".3s")(total) + unit + ")")
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", "black")
.attr("x", w - margin_h + 10)
.attr("y", y_abs(1));
if(total_unit != null)
g.append("svg:text")
.text("Area: " + d3.format(".3s")(total_area) + total_unit)
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", "black")
.attr("x", w - margin_h + 10)
.attr("y", y_abs(1) + 12);
} else {
var y = d3.scale.linear().domain([
0,
d3.max(lines, function(line) { return d3.max(line.data, itemgetter(1)); } )
]).range([h - margin_v, margin_v]);
g.selectAll().data(lines).enter().append("svg:path")
.attr("d", function(line) {
return d3.svg.line()
.x(compose(x, as_date, itemgetter(0)))
.y(compose(y, itemgetter(1)))
.defined(compose(not_null, itemgetter(1)))
(line.data)
})
.style("stroke", function(line) { return line.color })
.attr("class", "plotline");
for(var i = 0; i < lines.length; ++i) {
var line = lines[i];
var stats = get_area_mean(line.data);
if(stats.mean != null) {
g.append("svg:text")
.text(line.label)
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h + 10)
.attr("y", y(stats.mean) - 12);
g.append("svg:text")
.text("-Mean: " + d3.format(".3s")(stats.mean) + unit)
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h)
.attr("y", y(stats.mean));
if(total_unit != null)
g.append("svg:text")
.text("Area: " + d3.format(".3s")(stats.area) + total_unit)
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h + 10)
.attr("y", y(stats.mean) + 12);
}
}
}
// x axis
g.append("svg:line")
.attr("x1", margin_h)
.attr("y1", h - margin_v)
.attr("x2", w - margin_h)
.attr("y2", h - margin_v);
g.selectAll()
.data(x.ticks(13))
.enter().append("svg:g")
.attr("transform", function(d) { return "translate(" + x(d) + "," + (h-margin_v/2) + ")"; })
.append("svg:text")
.attr("transform", "rotate(45)")
.attr("text-anchor", "middle")
.attr("dominant-baseline", "central")
.text(x.tickFormat(13));
g.selectAll()
.data(x.ticks(13))
.enter().append("svg:line")
.attr("x1", x)
.attr("y1", h - margin_v)
.attr("x2", x)
.attr("y2", h - margin_v + 5);
// y axis
g.append("svg:line")
.attr("x1", margin_h)
.attr("y1", h - margin_v)
.attr("x2", margin_h)
.attr("y2", margin_v);
g.selectAll()
.data(y.ticks(6))
.enter().append("svg:line")
.attr("x1", margin_h - 5)
.attr("y1", y)
.attr("x2", margin_h)
.attr("y2", y);
g.selectAll()
.data(y.ticks(6))
.enter().append("svg:text")
.text(compose(function(x) { return x + unit; }, d3.format(".2s")))
.attr("x", margin_h/2)
.attr("y", y)
.attr("dominant-baseline", "central")
.attr("text-anchor", "middle");
}
function plot_later(g, unit, total_unit, lines,w,h,stack) { // takes lines with url attribute instead of data attribute
var callbacks_left = lines.length;
lines.map(function(line) {
d3.json(line.url, function(line_data) {
line.data = line_data;
callbacks_left--;
if(callbacks_left == 0)
plot(g, unit, total_unit, lines,w,h,stack);
});
});
}
function data_to_lines(data, sort_key) {
var vers = {}; for(var i = 0; i < data.length; ++i) if(data[i][1] != null) for(var v in data[i][1]) if(data[i][1][v] != data[i][3]) vers[v] = null;
var verlist = []; for(var v in vers) verlist.push(v);
verlist.sort();
lines = [];
for(var i = 0; i < verlist.length; i++) {
lines.push({
data: data.map(function(d){ return [d[0], d[1] == null ? null : (verlist[i] in d[1] ? d[1][verlist[i]] : d[3]), d[2]] }),
color: d3.hsl(i/verlist.length*360, 0.5, 0.5),
label: verlist[i]
});
}
if(sort_key == undefined)
var sort_key = function(x) { return d3.max(x.data, function(d){ return d[1] }) }
lines.sort(function(a, b){ return sort_key(a) - sort_key(b) });
return lines;
}
</script>
<script type="text/javascript">
$(document).ready(function() {
LoadData();
UpdateData();
setInterval("AutoRefresh()", 5 * 1000);
$('#myTab a:first').tab('show');
});
</script>
</body>
</html>