-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
65 lines (59 loc) · 1.4 KB
/
main.js
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
var clicks = [];
var bind = false;
function plotclick(event, pos, item)
{
if (!item)
return;
clicks.push(item);
if (clicks.length == 2) {
if (clicks[0].datapoint[0] > clicks[1].datapoint[0]) {
// swap
var tmp = clicks[0];
clicks[0] = clicks[1];
clicks[1] = tmp;
}
$.getJSON("/get_json?x0=" + clicks[0].datapoint[0] + "&x1=" + clicks[1].datapoint[0],
plot_data);
return;
}
$("#start").css({left: pos.pageX});
$("#start").show();
}
function zoom_out()
{
$.getJSON("/get_json", plot_data);
clicks = [];
}
function plothover(event, pos, item)
{
var x = Math.ceil(pos);
if (item) {
$("#stacktrace").html(glob_data.mem[item.dataIndex][2]);
}
}
function format_y_axis(val, axis)
{
if (val > 1024) {
return (val / 1024).toFixed() + " MiB";
}
return val + " KiB";
}
function plot_data(data)
{
glob_data = data;
$.plot("#chart", [data['mem']], {
grid: {hoverable: true, clickable: true},
yaxis: {tickFormatter: format_y_axis}
});
if (!bind) {
$("#chart").bind("plothover", plothover);
$("#chart").bind("plotclick", plotclick);
bind = true;
}
clicks = [];
$("#start").hide();
}
$(function() {
$.getJSON("/get_json", plot_data);
$("#start").hide();
})