StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
'use strict';
|
|
|
|
var utils = require('../utils/');
|
|
|
|
/**
|
|
* The paginator keep trakcs of a pointer index in a list and return
|
|
* a subset of the choices if the list is too long.
|
|
*/
|
|
|
|
var Paginator = module.exports = function() {
|
|
this.pointer = 0;
|
|
this.lastIndex = 0;
|
|
};
|
|
|
|
Paginator.prototype.paginate = function(output, active, pageSize) {
|
|
var pageSize = pageSize || 7;
|
|
var lines = output.split('\n');
|
|
|
|
// Make sure there's enough lines to paginate
|
|
if (lines.length <= pageSize + 2) {
|
|
return output;
|
|
}
|
|
|
|
// Move the pointer only when the user go down and limit it to 3
|
|
if (this.pointer < 3 && this.lastIndex < active && active - this.lastIndex < 9) {
|
|
this.pointer = Math.min(3, this.pointer + active - this.lastIndex);
|
|
}
|
|
this.lastIndex = active;
|
|
|
|
// Duplicate the lines so it give an infinite list look
|
|
var infinite = utils.flatten([lines, lines, lines]);
|
|
var topIndex = Math.max(0, active + lines.length - this.pointer);
|
|
|
|
var section = infinite.splice(topIndex, pageSize).join('\n');
|
|
return section + '\n' + utils.chalk.dim('(Move up and down to reveal more choices)');
|
|
};
|
|
|