Skip to content

Commit

Permalink
Do not hard-code default column for plots in HTML tables.
Browse files Browse the repository at this point in the history
Previously always the second column was used when a user clicked on
"Quantile Plot" or "Scatter Plot".
Now we use the first numeric column, if there is one.

This fixes #260.
  • Loading branch information
PhilippWendler committed Oct 25, 2017
1 parent 5f04bc9 commit b619b67
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions benchexec/tablegenerator/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -1394,14 +1394,21 @@
.text(graphData.showCorrectOnly ? 'Switch to All Results' : 'Switch to Correct Results Only');
}

function isValidStatisticsColumn(columnIndex) {
function isValidStatisticsColumn(columnIndex, allowStatus) {
var firstRow = $('#dataTable').find('> tbody > tr:visible')[0];
var firstColumnEntry = firstRow.cells[dataColumnsOffset + columnIndex];
var columnClasses = firstColumnEntry.classList;

return $(columnTitleCells[columnIndex]).is(':visible')
&& (columnClasses.contains('status') || columnClasses.contains('main_status')
|| columnClasses.contains('measure') || columnClasses.contains('count'));
if (!$(columnTitleCells[columnIndex]).is(':visible')) {
return false;
}
if (columnClasses.contains('measure') || columnClasses.contains('count')) {
return true;
}
if (allowStatus && (columnClasses.contains('status') || columnClasses.contains('main_status'))) {
return true;
}
return false;
}

function getSelectorForScatter(identifier) {
Expand All @@ -1412,7 +1419,7 @@
var group = $('<optgroup>', {label:getNameOfTestDirect(runSet)})
.appendTo(select);
for (var j = 0; j < runSet.columns.length; j++, columnIndex++) {
if (isValidStatisticsColumn(columnIndex)) {
if (isValidStatisticsColumn(columnIndex, true)) {
var column = runSet.columns[j];
var option = $('<option>', {
value:columnIndex,
Expand Down Expand Up @@ -1552,7 +1559,7 @@
var run_set = run_sets[i];
for (var j = 0; j < run_set.columns.length; j++, columnIndex++) {
var column = run_set.columns[j];
if (columns[column] == null && isValidStatisticsColumn(columnIndex)) {
if (columns[column] == null && isValidStatisticsColumn(columnIndex, true)) {
$('<option>', { value:'column' + columnIndex, selected:(!graphData.isRunSet && graphData.target.textContent == column) })
.text(column).appendTo(group);
columns[column] = column;
Expand Down Expand Up @@ -1647,9 +1654,18 @@
});
};

function findFirstStatisticsColumn() {
for (var i = 0; i < columnTitleCells.length; i++) {
if (isValidStatisticsColumn(i, false)) {
return i;
}
}
return 0;
}

function createQuantilePlotView(event) {
if (event == undefined) {
graphData.target = columnTitleCells[1]; // second column is default
graphData.target = columnTitleCells[findFirstStatisticsColumn()];
} else {
graphData.target = event.target;
}
Expand All @@ -1658,7 +1674,8 @@
};

function createScatterPlotView() {
graphData.target = [1,1]; // default indices of the columns in the plot
var i = findFirstStatisticsColumn(); // default indices of the columns in the plot
graphData.target = [i, i];
graphData.isRunSet = false;
showScatterPlot();
};
Expand Down

0 comments on commit b619b67

Please sign in to comment.