Skip to content

Commit 2ccb6d2

Browse files
committed
updated to remove unneeded code regarding offsets and to fix trace plot time stamp calculation in parser since move to absolute time.
1 parent ef41a80 commit 2ccb6d2

File tree

3 files changed

+144
-163
lines changed

3 files changed

+144
-163
lines changed

parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ define([], function() {
1313
data : [],
1414
};
1515
}
16-
var enq = parseFloat(result[2]) * 1000000.0;
17-
var comp = parseFloat(result[4]) * 1000000.0;
16+
var enq = parseFloat(result[2]) * 1000.0;
17+
var comp = parseFloat(result[4]) * 1000.0;
1818
var exec_time = parseFloat(result[5]);
1919
log_data[alias].data.push([enq, 0]);
2020
log_data[alias].data.push([enq, exec_time]);

plotter.js

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
define(['plotly-js/plotly.min', 'd3'], function(Plotly,d3) {
22
'use strict';
33
return {
4-
plotData: function(plotId, data, offset) {
5-
// extent returns array: [min, max]
6-
var maxXs = Object.keys(data).map(function(key) {
7-
return d3.extent(data[key].data, function(xy) { return xy[0] - offset; })[1];
8-
});
9-
var maxYs = Object.keys(data).map(function(key) {
10-
return d3.extent(data[key].data, function(xy) { return xy[1]; })[1];
11-
});
12-
var xdomain = d3.max(maxXs);
13-
var ydomain = d3.max(maxYs);
4+
plotData: function(plotId, data) {
5+
// extent returns array: [min, max]
6+
var maxXs = Object.keys(data).map(function(key) {
7+
return d3.extent(data[key].data, function(xy) { return xy[0]; })[1];
8+
});
9+
var maxYs = Object.keys(data).map(function(key) {
10+
return d3.extent(data[key].data, function(xy) { return xy[1]; })[1];
11+
});
12+
var xdomain = d3.max(maxXs);
13+
var ydomain = d3.max(maxYs);
1414

15-
var pdata = [];
15+
var pdata = [];
1616

17-
Object.keys(data).map(function(key) {
18-
pdata.push({
19-
x : data[key].data.map(function(xy) { return new Date(xy[0]); }),
20-
y : data[key].data.map(function(xy) { return xy[1]; }),
21-
mode: 'lines',
17+
Object.keys(data).map(function(key) {
18+
pdata.push({
19+
x : data[key].data.map(function(xy) { return new Date(xy[0]); }),
20+
y : data[key].data.map(function(xy) { return xy[1]; }),
21+
mode: 'lines',
2222
type: 'scatter',
23-
name: key,
23+
name: key,
2424
marker: {
2525
maxdisplayed: 1000 // ,
2626
/*
27-
color: "rgb(164, 194, 244)",
28-
size: 12,
29-
line: {
30-
color: "white",
31-
width: 0.5
32-
}
33-
*/
27+
color: "rgb(164, 194, 244)",
28+
size: 12,
29+
line: {
30+
color: "white",
31+
width: 0.5
32+
}
33+
*/
3434
}
35-
});
36-
});
35+
});
36+
});
3737

38-
var layout = {
39-
xaxis: {
40-
title: 'Time (s)'
41-
},
38+
var layout = {
39+
xaxis: {
40+
title: 'Time (s)'
41+
},
4242
legend: {
4343
xanchor: 'right'
4444
},
@@ -52,66 +52,66 @@ define(['plotly-js/plotly.min', 'd3'], function(Plotly,d3) {
5252
hovermode: 'closest',
5353
autosize: true,
5454
showlegend: true
55-
};
55+
};
5656

57-
Plotly.plot(plotId, pdata, layout, {
58-
modeBarButtons: [[{
59-
'name': 'toImage',
60-
'title': 'Download plot as png',
61-
'icon': Plotly.Icons.camera,
62-
'click': function(gd) {
63-
var format = 'png';
64-
var id = '#'+plotId;
57+
Plotly.plot(plotId, pdata, layout, {
58+
modeBarButtons: [[{
59+
'name': 'toImage',
60+
'title': 'Download plot as png',
61+
'icon': Plotly.Icons.camera,
62+
'click': function(gd) {
63+
var format = 'png';
64+
var id = '#'+plotId;
6565

66-
/*
67-
Plotly.Lib.notifier('Taking snapshot - this may take a few seconds', 'long');
66+
/*
67+
Plotly.Lib.notifier('Taking snapshot - this may take a few seconds', 'long');
6868
69-
if(Plotly.Lib.isIE()) {
70-
Plotly.Lib.notifier('IE only supports svg. Changing format to svg.', 'long');
71-
format = 'svg';
72-
}
73-
*/
74-
75-
Plotly.downloadImage(gd, {
76-
'format': format,
77-
'width': $(id).width(),
78-
'width': $(id).width(),
79-
})
80-
.then(function(filename) {
81-
//Plotly.Lib.notifier('Snapshot succeeded - ' + filename, 'long');
82-
})
83-
.catch(function() {
84-
//Plotly.Lib.notifier('Sorry there was a problem downloading your snapshot!', 'long');
85-
});
86-
}
87-
}],[
88-
'zoom2d',
89-
'pan2d',
90-
'select2d',
91-
'lasso2d',
92-
'zoomIn2d',
93-
'zoomOut2d',
94-
'autoScale2d',
95-
'resetScale2d',
96-
'hoverClosestCartesian',
97-
'hoverCompareCartesian'
98-
]],
99-
/*
100-
modeBarButtonsToRemove: ['toImage', 'sendDataToCloud'],
101-
modeBarButtonsToAdd: [{
102-
name: 'toImage2',
103-
icon: Plotly.Icons.camera,
104-
click: function(gd) {
105-
console.log($('#'+plotId).height());
106-
console.log($('#'+plotId).width());
107-
Plotly.downloadImage(gd, {
108-
height: $('#'+plotId).height(),
109-
width: $('#'+plotId).width(),
110-
});
111-
}
112-
}],
113-
*/
114-
});
115-
}
69+
if(Plotly.Lib.isIE()) {
70+
Plotly.Lib.notifier('IE only supports svg. Changing format to svg.', 'long');
71+
format = 'svg';
72+
}
73+
*/
74+
75+
Plotly.downloadImage(gd, {
76+
'format': format,
77+
'width': $(id).width(),
78+
'height': $(id).height(),
79+
})
80+
.then(function(filename) {
81+
//Plotly.Lib.notifier('Snapshot succeeded - ' + filename, 'long');
82+
})
83+
.catch(function() {
84+
//Plotly.Lib.notifier('Sorry there was a problem downloading your snapshot!', 'long');
85+
});
86+
}
87+
}],[
88+
'zoom2d',
89+
'pan2d',
90+
'select2d',
91+
'lasso2d',
92+
'zoomIn2d',
93+
'zoomOut2d',
94+
'autoScale2d',
95+
'resetScale2d',
96+
'hoverClosestCartesian',
97+
'hoverCompareCartesian'
98+
]],
99+
/*
100+
modeBarButtonsToRemove: ['toImage', 'sendDataToCloud'],
101+
modeBarButtonsToAdd: [{
102+
name: 'toImage2',
103+
icon: Plotly.Icons.camera,
104+
click: function(gd) {
105+
console.log($('#'+plotId).height());
106+
console.log($('#'+plotId).width());
107+
Plotly.downloadImage(gd, {
108+
height: $('#'+plotId).height(),
109+
width: $('#'+plotId).width(),
110+
});
111+
}
112+
}],
113+
*/
114+
});
115+
}
116116
};
117117
});

renderer.js

Lines changed: 54 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -51,90 +51,71 @@ function removeExtension(filename){
5151
const menu = new Menu();
5252
menu.append(new MenuItem({label: 'Open Log', click() {
5353
dialog.showOpenDialog(function (fileNames) {
54-
if(fileNames === undefined)
55-
console.log("No file selected");
56-
else {
54+
if(fileNames === undefined)
55+
console.log("No file selected");
56+
else {
5757
console.log("Opened " + fileNames);
5858
fs.readFile(fileNames[0], 'utf-8', function(err, data) {
59-
if (err) {
59+
if (err) {
6060
alert("Couldn't open the file: " + err.message);
6161
return;
62-
}
63-
fileNames[0] = removeExtension(path.basename(fileNames[0])).replace(/\./g, '_');
64-
// init vars
65-
var a = fileNames[0],
66-
datas = {},
67-
first_time = undefined,
68-
last_time = undefined;
69-
70-
// Prepare hide plot func
71-
var hidePlotFunc = function(a) {
72-
var active = datas[a].active ? false : true;
73-
var opacity = active ? 0 : 1;
74-
var visibility = active ? 'hidden' : 'visible';
75-
var display = active ? 'none' : 'block';
76-
d3.select('#plot_'+a)
77-
.style('display', display);
78-
datas[a].active = active;
79-
};
80-
81-
// parse the log
82-
var parsed = parser.getDataFromAttribute(data);
83-
if (_.isEmpty(parsed))
62+
}
63+
fileNames[0] = removeExtension(path.basename(fileNames[0])).replace(/\./g, '_');
64+
// init vars
65+
var a = fileNames[0],
66+
datas = {};
67+
68+
// Prepare hide plot func
69+
var hidePlotFunc = function(a) {
70+
var active = datas[a].active ? false : true;
71+
var opacity = active ? 0 : 1;
72+
var visibility = active ? 'hidden' : 'visible';
73+
var display = active ? 'none' : 'block';
74+
d3.select('#plot_'+a)
75+
.style('display', display);
76+
datas[a].active = active;
77+
};
78+
79+
// parse the log
80+
var parsed = parser.getDataFromAttribute(data);
81+
if (_.isEmpty(parsed))
8482
parsed = userparser.getDataFromAttribute(data);
85-
datas[a] = parsed;
86-
var aliases = Object.keys(datas[a]);
87-
aliases.map((key) => {
88-
var d = datas[a][key].data;
89-
var first_entry = d[0];
90-
var last_entry = d[d.length-1];
91-
if ( first_time === undefined || first_time > first_entry[0] ) {
92-
first_time = first_entry[0];
93-
}
94-
if ( last_time === undefined || last_time < last_entry[0] ) {
95-
last_time = last_entry[0];
96-
}
97-
});
98-
// plot the logs
99-
for (var a in datas) {
100-
// setup the html
101-
$(plotHtml).appendTo('#main');
102-
var container = $('#log');
103-
$(container).attr('id', 'log_'+a);
104-
105-
var title = $(container).find('#title');
106-
$(title).attr('id','title_'+a)
107-
.on('click', function(_a) {
108-
return function() {
109-
hidePlotFunc(_a);
110-
};
111-
}(a));
112-
113-
title.append('<b>'+a+'</b>');
114-
115-
var p = $(container).find('#plot');
116-
$(p).attr('id',"plot_" + a);
117-
118-
var data = datas[a];
119-
var offset = first_time;
120-
if (!_.isEmpty(data)) {
121-
var aliases = Object.keys(data);
122-
aliases.map((key) => {
123-
data[key].data.push([last_time, 0]);
124-
});
125-
plotter.plotData('plot_'+a, data, offset);
126-
plotIDs.push('#plot_'+a); }
127-
else
128-
$(container).detach();
129-
}
83+
datas[a] = parsed;
84+
// plot the logs
85+
for (var a in datas) {
86+
// setup the html
87+
$(plotHtml).appendTo('#main');
88+
var container = $('#log');
89+
$(container).attr('id', 'log_'+a);
90+
91+
var title = $(container).find('#title');
92+
$(title).attr('id','title_'+a)
93+
.on('click', function(_a) {
94+
return function() {
95+
hidePlotFunc(_a);
96+
};
97+
}(a));
98+
99+
title.append('<b>'+a+'</b>');
100+
101+
var p = $(container).find('#plot');
102+
$(p).attr('id',"plot_" + a);
103+
104+
var data = datas[a];
105+
if (!_.isEmpty(data)) {
106+
plotter.plotData('plot_'+a, data);
107+
plotIDs.push('#plot_'+a); }
108+
else
109+
$(container).detach();
110+
}
130111
});
131-
}
112+
}
132113
});
133114
}}));
134115

135116
$( window ).resize(function() {
136117
plotIDs.map(function(plotID) {
137-
plotly.Plots.resize(d3.select(plotID).node());
118+
plotly.Plots.resize(d3.select(plotID).node());
138119
});
139120
});
140121

0 commit comments

Comments
 (0)