Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
137 lines (118 loc) · 4.94 KB

File metadata and controls

137 lines (118 loc) · 4.94 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
html, body, svg {
margin: 0px;
min-height: 100%;
height: 100%;
width: 100%;
}
.chart rect {
fill: steelblue;
}
.axis text {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
div.tooltip {
position: absolute;
# text-align: center;
# width: 60px;
# height: 28px;
padding: 2px;
font: 12px sans-serif;
background: lightsteelblue;
border: 0px;
}
</style>
</head>
<body>
<svg class="chart"></svg>
<script src="https://d3js.org/d3.v4.js"></script>
<script>
var barHeight = 2;
var chart = d3.select(".chart");
var margin = {top: 20, right: 30, bottom: 30, left: 40},
width = chart.style("width").replace("px", "") - margin.left - margin.right,
height = chart.style("height").replace("px", "") - margin.top - margin.bottom;
var x = d3.scaleLinear().range([0, width]);
var y = d3.scaleLinear().range([0, height]);
var chart = chart.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var xAxis = d3.axisBottom().scale(x);
var yAxis = d3.axisLeft().scale(y);
var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
d3.json("/allocation_history.json", function(error, data) {
console.log(data[0]);
x.domain([0, d3.max(data, function(d) { return d.end_time; })]);
y.domain([0, d3.max(data, function(d) { return d.start_block + d.size; })]);
chart.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
chart.append("g")
.attr("class", "y axis")
.call(yAxis);
var bar = chart.selectAll("g")
.data(data)
.enter().append("g")
.attr("transform", function(d, i) { return "translate(" + x(d.start_time) + "," + y(d.start_block) + ")"; });
bar.append("rect")
.attr("width", function(d) { return x(d.end_time - d.start_time); })
.attr("height", function(d) { return y(d.size) - 1; })
.on("mouseover", function(d) {
var trace = "";
for (var i = 0, len = d.start_trace.length; i < len; i++) {
var frame = d.start_trace[i];
trace += frame[2] + " " + frame[1] + "<br/>";
}
trace += "<br/>End Trace:<br/>";
for (var i = 0, len = d.end_trace.length; i < len; i++) {
var frame = d.end_trace[i];
trace += frame[2] + " " + frame[1] + "<br/>";
}
var side = "left";
var other_side = "right";
var pos_x = x(d.start_time) + margin.left;
if (width - pos_x < 300) {
side = "right";
other_side = "left";
pos_x = width - x(d.start_time) + margin.right;
}
var pos_y = (height - y(d.start_block) + margin.bottom)
var edge = "bottom";
var other_edge = "top";
if ((height - pos_y) < 300) {
edge = "top";
other_edge = "bottom";
pos_y = y(d.start_block) + margin.top + y(d.size);
}
div.style("opacity", 1)
.html("Start block: " + d.start_block + " Size: " + d.size + " blocks<br/><br/>" + trace)
.style(side, pos_x + "px")
.style(other_side, null)
.style(edge, pos_y + "px")
.style(other_edge, null);
});
// bar.append("text")
// .attr("x", function(d) { return x(d.value) - 3; })
// .attr("y", barHeight / 2)
// .attr("dy", ".35em")
// .text(function(d) { return d.value; });
});
function type(d) {
d.value = +d.value; // coerce to number
return d;
}
</script>
</body>
</html>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.