hyper-analytics
Advanced tools
Comparing version 0.11.4 to 0.11.5
@@ -10,2 +10,3 @@ 'use strict'; | ||
DataSourceTreeview: require('./js/DataSourceTreeview'), | ||
DataSourceTreeviewSorter: require('./js/DataSourceTreeviewSorter'), | ||
DataNodeGroupSorter: require('./js/DataNodeGroupSorter'), | ||
@@ -12,0 +13,0 @@ util: { |
@@ -6,49 +6,59 @@ 'use strict'; | ||
Base.prototype.click = function() { | ||
if (this.dataSource) { | ||
return this.dataSource.click.apply(this.dataSource, arguments); | ||
} | ||
}; | ||
Base.prototype = { | ||
constructor: Base.prototype.constructor, | ||
Base.prototype.findRow = function() { | ||
if (this.dataSource) { | ||
return this.dataSource.findRow.apply(this.dataSource, arguments); | ||
} | ||
}; | ||
replaceIndent: '_', | ||
Base.prototype.revealRow = function() { | ||
if (this.dataSource) { | ||
return this.dataSource.revealRow.apply(this.dataSource, arguments); | ||
} | ||
}; | ||
getHeaders: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.getHeaders.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
Base.prototype.replaceIndent = '_'; | ||
click: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.click.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
Base.prototype.fixIndentForTableDisplay = function(string) { | ||
var count = string.search(/\S/); | ||
var end = string.substring(count); | ||
var result = Array(count + 1).join(this.replaceIndent) + end; | ||
return result; | ||
}; | ||
findRow: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.findRow.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
Base.prototype.dump = function(max) { | ||
max = Math.min(this.getRowCount(), max || Math.max(100, this.getRowCount())); | ||
var data = []; | ||
var fields = this.getHeaders(); | ||
var cCount = this.getColumnCount(); | ||
var viewMakesSense = this.viewMakesSense; | ||
for (var r = 0; r < max; r++) { | ||
var row = {}; | ||
for (var c = 0; c < cCount; c++) { | ||
var val = this.getValue(c, r); | ||
if (c === 0 && viewMakesSense) { | ||
val = this.fixIndentForTableDisplay(val); | ||
revealRow: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.revealRow.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
fixIndentForTableDisplay: function(string) { | ||
var count = string.search(/\S/); | ||
var end = string.substring(count); | ||
var result = Array(count + 1).join(this.replaceIndent) + end; | ||
return result; | ||
}, | ||
dump: function(max) { | ||
max = Math.min(this.getRowCount(), max || Math.max(100, this.getRowCount())); | ||
var data = []; | ||
var fields = this.getHeaders(); | ||
var cCount = this.getColumnCount(); | ||
var viewMakesSense = this.viewMakesSense; | ||
for (var r = 0; r < max; r++) { | ||
var row = {}; | ||
for (var c = 0; c < cCount; c++) { | ||
var val = this.getValue(c, r); | ||
if (c === 0 && viewMakesSense) { | ||
val = this.fixIndentForTableDisplay(val); | ||
} | ||
row[fields[c]] = val; | ||
} | ||
row[fields[c]] = val; | ||
data[r] = row; | ||
} | ||
data[r] = row; | ||
console.table(data); | ||
} | ||
console.table(data); | ||
}; | ||
module.exports = Base; |
@@ -39,3 +39,3 @@ 'use strict'; | ||
setSorts: function(sorts) { | ||
set: function(sorts) { | ||
this.sorts = sorts || []; | ||
@@ -42,0 +42,0 @@ }, |
@@ -168,2 +168,13 @@ 'use strict'; | ||
/** | ||
* Used by the sorters (`DataSourceSorter` and `DataSourceTreeviewSorter`). | ||
* @param {object} dataRow | ||
* @param {string} columnName | ||
* @returns {*} | ||
*/ | ||
DataSourceIndexed.valOrFunc = function(dataRow, columnName) { | ||
var vf = dataRow[columnName]; | ||
return (typeof vf)[0] === 'f' ? vf(dataRow, columnName) : vf; | ||
}; | ||
module.exports = DataSourceIndexed; |
@@ -11,16 +11,4 @@ 'use strict'; | ||
var DataSourceSorter = DataSourceIndexed.extend('DataSourceSorter', { | ||
/** | ||
* @memberOf DataSourceSorter.prototype | ||
*/ | ||
initialize: function() { | ||
/** | ||
* @memberOf DataSourceSorter.prototype | ||
* @type {boolean} | ||
*/ | ||
this.descendingSort = false; // TODO: this does not seem to be in use | ||
}, | ||
/** | ||
* @memberOf DataSourceSorter.prototype | ||
* @param {number} columnIndex | ||
@@ -46,3 +34,4 @@ * @param {number} [direction=1] | ||
function getValue(rowIdx) { | ||
return valOrFunc(dataSource.getRow(rowIdx), columnName); | ||
var dataRow = dataSource.getRow(rowIdx); | ||
return DataSourceIndexed.valOrFunc(dataRow, columnName); | ||
} | ||
@@ -52,12 +41,2 @@ } | ||
/** | ||
* @private | ||
* @param {*|function} valOrFunc | ||
* @returns {*} | ||
*/ | ||
function valOrFunc(dataRow, columnName) { | ||
var vf = dataRow[columnName]; | ||
return (typeof vf)[0] === 'f' ? vf(dataRow, columnName) : vf; | ||
} | ||
module.exports = DataSourceSorter; |
@@ -52,3 +52,3 @@ 'use strict'; | ||
setSorts: function(sorts) { | ||
set: function(sorts) { | ||
this.sorts = sorts || []; | ||
@@ -55,0 +55,0 @@ }, |
@@ -11,4 +11,4 @@ 'use strict'; | ||
/** | ||
* For proper sorting, include `DataSourceTreeviewSorter` in your pipeline, _ahead of_ (closer to the data than) this data source. | ||
* @constructor | ||
@@ -36,3 +36,3 @@ * @extends DataSourceIndexed | ||
var idColumnName, parentIdColumnName, treeColumnName, fields, | ||
rowCount, r, parentID, depth, leafRow, row, ID; | ||
r, parentID, depth, leafRow, row, ID; | ||
@@ -62,2 +62,6 @@ this.joined = false; | ||
this.joined = this.treeColumnIndex !== undefined; | ||
// treeviewSorter needs to know following for access by each DataSourceSorter it creates: | ||
this.dataSource.idColumnName = idColumnName; | ||
this.dataSource.parentIdColumnName = parentIdColumnName; | ||
} | ||
@@ -70,4 +74,3 @@ } | ||
// mutate data row with __DEPTH (all rows) and __EXPANDED (all "parent" rows) | ||
rowCount = this.getRowCount(); | ||
r = rowCount; | ||
r = this.getRowCount(); | ||
while (r--) { | ||
@@ -102,3 +105,3 @@ depth = 0; | ||
if (this.viewMakesSense()) { | ||
this.buildIndex(this.treeColumnIndex === undefined ? undefined : collapseRows); | ||
this.buildIndex(this.treeColumnIndex === undefined ? undefined : rowIsRevealed); | ||
} | ||
@@ -151,2 +154,3 @@ }, | ||
} | ||
var changed, row = this.getRow(y); | ||
@@ -192,13 +196,18 @@ if (row && row.__EXPANDED !== undefined) { | ||
function collapseRows(r, row) { | ||
function rowIsRevealed(r, row) { | ||
var parentID; | ||
// are any of the row's ancestors collapsed? | ||
while ((parentID = row[this.parentIdColumnName]) != undefined) { // eslint-disable-line eqeqeq | ||
// walk up through each parent... | ||
row = this.findRow(this.idColumnName, parentID); | ||
if (row.__EXPANDED === false) { | ||
return false; | ||
if (row.__EXPANDED === false) { // an ancestor is collapsed | ||
return false; // exclude row from build | ||
} | ||
} | ||
return true; | ||
// no ancestors were collapsed | ||
return true; // include row in build | ||
} | ||
module.exports = DataSourceTreeview; |
{ | ||
"name": "hyper-analytics", | ||
"version": "0.11.4", | ||
"version": "0.11.5", | ||
"description": "Data transformations on arrays of congruent JavaScript objects.", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66366
24
2091