<h2>Miners</h2>
<div id="miners"></div>
- <h2>Desired versions</h2>
- <svg id="desired_versions"></svg>
+ <h2>Desired version rates</h2>
+ <svg id="desired_version_rates"></svg>
+
+ <h2>Traffic rate</h2>
+ <svg id="traffic_rate"></svg>
<script type="text/javascript">
function compose() {
function plot(g, unit, total_unit, lines, 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";
+
+ var showhide = document.createElement("p");
+ g.node().parentNode.insertBefore(showhide, g.node().nextSibling);
+ d3.select(showhide).append("a")
+ .text('Show/hide table')
+ .on('click', function() { table_div.style.display = table_div.style.display == "block" ? "none" : "block" })
+ .attr("style", "color:blue;text-decoration:underline;cursor:pointer");
+
+ 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])});
+ }
+ d3.select(table_div).append('div').attr('style', 'clear:both');
+
+ d3.select(table_div).append('p').append("a")
+ .text('Show/hide table')
+ .on('click', function() { table_div.style.display = table_div.style.display == "block" ? "none" : "block" })
+ .attr("style", "color:blue;text-decoration:underline;cursor:pointer");
+
+
var w = 700;
var h = 300;
var margin_v = 40;
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()
})
.style("fill", function(line){return line.color})
.attr("stroke", function(line){return line.color})
- .attr("class", "plotline")
- .on("mouseover", function(line, i) {
- for(var j = 0; j < text_boxes.length; j++)
- text_boxes[j][1].attr("opacity", text_boxes[j][0] == i ? 1 : 0.3);
- });
+ .attr("class", "plotline");
- var text_boxes = [];
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);
num += (d.y+1)*((d.y0 + d.y) + (d.y0))/2;
denom += (d.y+1);
}
- text_boxes.push([i, g.append("svg:text")
+ 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(num/denom))]);
- total += stats.mean;
+ .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);
}
}
- text_boxes.push([i, g.append("svg:text")
- .text("- Total (mean: " + d3.format(".3s")(total) + unit + ")")
+ 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)
- .attr("y", y(total))]);
+ .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,
(line.data)
})
.style("stroke", function(line) { return line.color })
- .attr("class", "plotline")
- .on("mouseover", function(line, i) {
- for(var j = 0; j < text_boxes.length; j++)
- text_boxes[j][1].attr("opacity", text_boxes[j][0] == i ? 1 : 0.3);
- });
+ .attr("class", "plotline");
- var text_boxes = [];
for(var i = 0; i < lines.length; ++i) {
var line = lines[i];
var stats = get_area_mean(line.data);
if(stats.mean != null) {
- text_boxes.push([i, g.append("svg:text")
+ 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)]);
- text_boxes.push([i, g.append("svg:text")
+ .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))]);
+ .attr("y", y(stats.mean));
if(total_unit != null)
- text_boxes.push([i, g.append("svg:text")
+ 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)]);
+ .attr("y", y(stats.mean) + 12);
}
}
}
{"url": "/web/graph_data/current_payout/last_" + lowerperiod, "color": "#0000FF"}
]);
d3.json("/web/graph_data/pool_rates/last_" + lowerperiod, function(data) {
- plot(d3.select('#pool'), 'H/s', null, data_to_lines(data), true);
+ plot(d3.select('#pool'), 'H/s', 'H', data_to_lines(data), true);
});
plot_later(d3.select("#peers"), "", null, [
{"url": "/web/graph_data/outgoing_peers/last_" + lowerperiod, "color": "#FF0000", "label": "Outgoing"},
});
});
- d3.json("/web/graph_data/desired_versions/last_" + lowerperiod, function(data) {
- plot(d3.select('#desired_versions'), '', null, data_to_lines(data, function(line){ return parseInt(line.label) }), true);
+ d3.json("/web/graph_data/desired_version_rates/last_" + lowerperiod, function(data) {
+ plot(d3.select('#desired_version_rates'), 'H/s', 'H', data_to_lines(data, function(line){ return parseInt(line.label) }), true);
+ });
+
+ d3.json("/web/graph_data/traffic_rate/last_" + lowerperiod, function(data) {
+ plot(d3.select('#traffic_rate'), 'B/s', 'B', data_to_lines(data, function(line){ return parseInt(line.label) }), true);
});
}
- d3.json('/web/currency_info', function(currency_info) {
- periods = ["Hour", "Day", "Week", "Month", "Year"];
- d3.select("#period_chooser").selectAll().data(periods).enter().append("span")
- .text(function(period) { return period })
- .on("click", function(period){ change_period(period, currency_info) })
- .attr("style", function(d, i) { return (i == 0 ? "" : "margin-left:.4em;") + "color:blue;text-decoration:underline;cursor:pointer" });
- change_period(periods[1], currency_info);
- });
+ periods = ["Hour", "Day", "Week", "Month", "Year"];
+ d3.select("#period_chooser").selectAll().data(periods).enter().append("a")
+ .text(function(period) { return period })
+ .attr('href', function(period){ return "?" + period })
+ .attr("style", function(d, i) { return (i == 0 ? "" : "margin-left:.4em;") + "color:blue;text-decoration:underline;cursor:pointer" });
+ period = window.location.search.substr(1);
+ if(period.length < 3) {
+ window.location.search = "Day";
+ } else {
+ d3.json('/web/currency_info', function(currency_info) {
+ change_period(period, currency_info);
+ });
+ }
</script>
</body>
</html>