Carga
This commit is contained in:
2025-04-17 00:35:33 -06:00
parent 4977462629
commit 67fc72aed5
1333 changed files with 1077639 additions and 0 deletions

View File

@@ -0,0 +1,301 @@
/* *
*
* (c) 2020-2022 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Sophie Bremer
*
* */
'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import DataModifier from './DataModifier.js';
import U from '../../Core/Utilities.js';
var merge = U.merge;
/* *
*
* Class
*
* */
/**
* Modifies a table with the help of modifiers in an ordered chain.
*
* @private
*/
var ChainModifier = /** @class */ (function (_super) {
__extends(ChainModifier, _super);
/* *
*
* Constructors
*
* */
/**
* Constructs an instance of the modifier chain.
*
* @param {DeepPartial<ChainModifier.Options>} [options]
* Options to configure the modifier chain.
*
* @param {...DataModifier} [modifiers]
* Modifiers in order for the modifier chain.
*/
function ChainModifier(options) {
var modifiers = [];
for (var _i = 1; _i < arguments.length; _i++) {
modifiers[_i - 1] = arguments[_i];
}
var _this = _super.call(this) || this;
_this.modifiers = modifiers;
_this.options = merge(ChainModifier.defaultOptions, options);
return _this;
}
/* *
*
* Functions
*
* */
/**
* Adds a configured modifier to the end of the modifier chain. Please note,
* that the modifier can be added multiple times.
*
* @param {DataModifier} modifier
* Configured modifier to add.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*/
ChainModifier.prototype.add = function (modifier, eventDetail) {
this.emit({
type: 'addModifier',
detail: eventDetail,
modifier: modifier
});
this.modifiers.push(modifier);
this.emit({
type: 'addModifier',
detail: eventDetail,
modifier: modifier
});
};
/**
* Clears all modifiers from the chain.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*/
ChainModifier.prototype.clear = function (eventDetail) {
this.emit({
type: 'clearChain',
detail: eventDetail
});
this.modifiers.length = 0;
this.emit({
type: 'afterClearChain',
detail: eventDetail
});
};
/**
* Applies partial modifications of a cell change to the property `modified`
* of the given modified table.
*
* *Note:* The `modified` property of the table gets replaced.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {string} columnName
* Column name of changed cell.
*
* @param {number|undefined} rowIndex
* Row index of changed cell.
*
* @param {Highcharts.DataTableCellType} cellValue
* Changed cell value.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
ChainModifier.prototype.modifyCell = function (table, columnName, rowIndex, cellValue, eventDetail) {
var modifiers = (this.options.reverse ?
this.modifiers.reverse() :
this.modifiers);
if (modifiers.length) {
var clone = table.clone();
for (var i = 0, iEnd = modifiers.length; i < iEnd; ++i) {
modifiers[i].modifyCell(clone, columnName, rowIndex, cellValue, eventDetail);
clone = clone.modified;
}
table.modified = clone;
}
return table;
};
/**
* Applies partial modifications of column changes to the property
* `modified` of the given table.
*
* *Note:* The `modified` property of the table gets replaced.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {Highcharts.DataTableColumnCollection} columns
* Changed columns as a collection, where the keys are the column names.
*
* @param {number} [rowIndex=0]
* Index of the first changed row.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
ChainModifier.prototype.modifyColumns = function (table, columns, rowIndex, eventDetail) {
var modifiers = (this.options.reverse ?
this.modifiers.reverse() :
this.modifiers.slice());
if (modifiers.length) {
var clone = table.clone();
for (var i = 0, iEnd = modifiers.length; i < iEnd; ++i) {
modifiers[i].modifyColumns(clone, columns, rowIndex, eventDetail);
clone = clone.modified;
}
table.modified = clone;
}
return table;
};
/**
* Applies partial modifications of row changes to the property `modified`
* of the given table.
*
* *Note:* The `modified` property of the table gets replaced.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {Array<(Highcharts.DataTableRow|Highcharts.DataTableRowObject)>} rows
* Changed rows.
*
* @param {number} [rowIndex]
* Index of the first changed row.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
ChainModifier.prototype.modifyRows = function (table, rows, rowIndex, eventDetail) {
var modifiers = (this.options.reverse ?
this.modifiers.reverse() :
this.modifiers.slice());
if (modifiers.length) {
var clone = table.clone();
for (var i = 0, iEnd = modifiers.length; i < iEnd; ++i) {
modifiers[i].modifyRows(clone, rows, rowIndex, eventDetail);
clone = clone.modified;
}
table.modified = clone;
}
return table;
};
/**
* Applies several modifications to the table.
*
* *Note:* The `modified` property of the table gets replaced.
*
* @param {DataTable} table
* Table to modify.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {DataTable}
* Table as a reference.
*
* @emits ChainDataModifier#execute
* @emits ChainDataModifier#afterExecute
*/
ChainModifier.prototype.modifyTable = function (table, eventDetail) {
var chain = this;
chain.emit({ type: 'modify', detail: eventDetail, table: table });
var modifiers = (chain.options.reverse ?
chain.modifiers.reverse() :
chain.modifiers.slice());
var modified = table.modified;
for (var i = 0, iEnd = modifiers.length, modifier = void 0; i < iEnd; ++i) {
modifier = modifiers[i];
modified = modifier.modifyTable(modified).modified;
}
table.modified = modified;
chain.emit({ type: 'afterModify', detail: eventDetail, table: table });
return table;
};
/**
* Removes a configured modifier from all positions of the modifier chain.
*
* @param {DataModifier} modifier
* Configured modifier to remove.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*/
ChainModifier.prototype.remove = function (modifier, eventDetail) {
var modifiers = this.modifiers;
this.emit({
type: 'removeModifier',
detail: eventDetail,
modifier: modifier
});
modifiers.splice(modifiers.indexOf(modifier), 1);
this.emit({
type: 'afterRemoveModifier',
detail: eventDetail,
modifier: modifier
});
};
/* *
*
* Static Properties
*
* */
/**
* Default option for the ordered modifier chain.
*/
ChainModifier.defaultOptions = {
modifier: 'Chain',
reverse: false
};
return ChainModifier;
}(DataModifier));
/* *
*
* Register
*
* */
DataModifier.addModifier(ChainModifier);
/* *
*
* Export
*
* */
export default ChainModifier;

View File

@@ -0,0 +1,303 @@
/* *
*
* (c) 2020-2022 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Sophie Bremer
* - Gøran Slettemark
*
* */
'use strict';
import DataPromise from '../DataPromise.js';
import U from '../../Core/Utilities.js';
var addEvent = U.addEvent, fireEvent = U.fireEvent, merge = U.merge;
/** eslint-disable valid-jsdoc */
/* *
*
* Class
*
* */
/**
* Abstract class to provide an interface for modifying a table.
*
* @private
*/
var DataModifier = /** @class */ (function () {
function DataModifier() {
}
/* *
*
* Static Functions
*
* */
/**
* Adds a modifier class to the registry. The modifier has to provide the
* `DataModifier.options` property and the `DataModifier.execute` method to
* modify the table.
*
* @param {DataModifier} modifier
* Modifier class (aka class constructor) to register.
*
* @return {boolean}
* Returns true, if the registration was successful. False is returned, if
* their is already a modifier registered with this name.
*/
DataModifier.addModifier = function (modifier) {
var name = DataModifier.getName(modifier), registry = DataModifier.registry;
if (typeof name === 'undefined' ||
registry[name]) {
return false;
}
registry[name] = modifier;
return true;
};
/**
* Returns all registered modifier names.
*
* @return {Array<string>}
* All registered modifier names.
*/
DataModifier.getAllModifierNames = function () {
return Object.keys(DataModifier.registry);
};
/**
* Returns a copy of the modifier registry as record object with
* modifier names and their modifier class.
*
* @return {Record<string,DataModifierRegistryType>}
* Copy of the modifier registry.
*/
DataModifier.getAllModifiers = function () {
return merge(DataModifier.registry);
};
/**
* Returns a modifier class (aka class constructor) of the given modifier
* name.
*
* @param {string} name
* Registered class name of the class type.
*
* @return {DataModifier|undefined}
* Class type, if the class name was found, otherwise `undefined`.
*/
DataModifier.getModifier = function (name) {
return DataModifier.registry[name];
};
/**
* Extracts the name from a given modifier class.
*
* @param {DataModifier} modifier
* Modifier class to extract the name from.
*
* @return {string}
* Modifier name, if the extraction was successful, otherwise an empty
* string.
*/
DataModifier.getName = function (modifier) {
return (modifier.toString().match(DataModifier.nameRegExp) ||
['', ''])[1];
};
/* *
*
* Functions
*
* */
/**
* Runs a timed execution of the modifier on the given datatable.
* Can be configured to run multiple times.
*
* @param {DataTable} dataTable
* The datatable to execute
*
* @param {DataModifier.BenchmarkOptions} options
* Options. Currently supports `iterations` for number of iterations.
*
* @return {Array<number>}
* An array of times in milliseconds
*
*/
DataModifier.prototype.benchmark = function (dataTable, options) {
var results = [];
var modifier = this;
var execute = function () {
modifier.modifyTable(dataTable);
modifier.emit({ type: 'afterBenchmarkIteration' });
};
var defaultOptions = {
iterations: 1
};
var iterations = merge(defaultOptions, options).iterations;
modifier.on('afterBenchmarkIteration', function () {
if (results.length === iterations) {
modifier.emit({ type: 'afterBenchmark', results: results });
return;
}
// Run again
execute();
});
var times = {
startTime: 0,
endTime: 0
};
// Add timers
modifier.on('modify', function () {
times.startTime = window.performance.now();
});
modifier.on('afterModify', function () {
times.endTime = window.performance.now();
results.push(times.endTime - times.startTime);
});
// Initial run
execute();
return results;
};
/**
* Emits an event on the modifier to all registered callbacks of this event.
*
* @param {DataEventEmitter.Event} [e]
* Event object containing additonal event information.
*/
DataModifier.prototype.emit = function (e) {
fireEvent(this, e.type, e);
};
/**
* Returns a modified copy of the given table.
*
* @param {Highcharts.DataTable} table
* Table to modify.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Promise<Highcharts.DataTable>}
* Table with `modified` property as a reference.
*/
DataModifier.prototype.modify = function (table, eventDetail) {
var modifier = this;
return new DataPromise(function (resolve, reject) {
if (table.modified === table) {
table.modified = table.clone(false, eventDetail);
}
try {
resolve(modifier.modifyTable(table, eventDetail));
}
catch (e) {
modifier.emit({
type: 'error',
detail: eventDetail,
table: table
});
reject(e);
}
});
};
/**
* Applies partial modifications of a cell change to the property `modified`
* of the given modified table.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {string} columnName
* Column name of changed cell.
*
* @param {number|undefined} rowIndex
* Row index of changed cell.
*
* @param {Highcharts.DataTableCellType} cellValue
* Changed cell value.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
DataModifier.prototype.modifyCell = function (table, columnName, rowIndex, cellValue, eventDetail) {
return this.modifyTable(table);
};
/**
* Applies partial modifications of column changes to the property
* `modified` of the given table.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {Highcharts.DataTableColumnCollection} columns
* Changed columns as a collection, where the keys are the column names.
*
* @param {number} [rowIndex=0]
* Index of the first changed row.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
DataModifier.prototype.modifyColumns = function (table, columns, rowIndex, eventDetail) {
return this.modifyTable(table);
};
/**
* Applies partial modifications of row changes to the property `modified`
* of the given table.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {Array<(Highcharts.DataTableRow|Highcharts.DataTableRowObject)>} rows
* Changed rows.
*
* @param {number} [rowIndex]
* Index of the first changed row.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
DataModifier.prototype.modifyRows = function (table, rows, rowIndex, eventDetail) {
return this.modifyTable(table);
};
/**
* Registers a callback for a specific modifier event.
*
* @param {string} type
* Event type as a string.
*
* @param {DataEventEmitter.EventCallback} callback
* Function to register for an modifier callback.
*
* @return {Function}
* Function to unregister callback from the modifier event.
*/
DataModifier.prototype.on = function (type, callback) {
return addEvent(this, type, callback);
};
/* *
*
* Static Properties
*
* */
/**
* Regular expression to extract the modifier name (group 1) from the
* stringified class type.
*/
DataModifier.nameRegExp = (/^function\s+(\w*?)(?:Data)?(?:Modifier)?\s*\(/);
/**
* Registry as a record object with modifier names and their class.
*/
DataModifier.registry = {};
return DataModifier;
}());
/* *
*
* Export
*
* */
export default DataModifier;

View File

@@ -0,0 +1,146 @@
/* *
*
* (c) 2020-2022 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Sophie Bremer
*
* */
'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import DataModifier from './DataModifier.js';
import DataTable from '../DataTable.js';
import U from '../../Core/Utilities.js';
var merge = U.merge;
/* *
*
* Class
*
* */
/**
* Groups table rows into subtables depending on column values.
*
* @private
*/
var GroupModifier = /** @class */ (function (_super) {
__extends(GroupModifier, _super);
/* *
*
* Constructors
*
* */
/**
* Constructs an instance of the group modifier.
*
* @param {GroupModifier.Options} [options]
* Options to configure the group modifier.
*/
function GroupModifier(options) {
var _this = _super.call(this) || this;
_this.options = merge(GroupModifier.defaultOptions, options);
return _this;
}
/* *
*
* Functions
*
* */
/**
* Applies modifications to the table rows and returns a new table with
* subtable, containing the grouped rows. The rows of the new table contain
* three columns:
* - `groupBy`: Column name used to group rows by.
* - `table`: Subtable containing the grouped rows.
* - `value`: containing the common value of the group
*
* @param {DataTable} table
* Table to modify.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {DataTable}
* Table with `modified` property as a reference.
*/
GroupModifier.prototype.modifyTable = function (table, eventDetail) {
var modifier = this;
modifier.emit({ type: 'modify', detail: eventDetail, table: table });
var byGroups = [], tableGroups = [], valueGroups = [], groupColumn = (modifier.options.groupColumn ||
table.getColumnNames()[0]), valueColumn = (table.getColumn(groupColumn) ||
[]), _a = modifier.options, invalidValues = _a.invalidValues, validValues = _a.validValues, modified = table.modified = table.clone(true, eventDetail);
var value, valueIndex;
for (var i = 0, iEnd = valueColumn.length; i < iEnd; ++i) {
value = valueColumn[i];
if (typeof value !== 'undefined') {
if (value instanceof DataTable ||
(invalidValues &&
invalidValues.indexOf(value) >= 0) || (validValues &&
validValues.indexOf(value) === -1)) {
continue;
}
valueIndex = valueGroups.indexOf(value);
if (valueIndex === -1) {
var newTable = new DataTable();
newTable.setRows([table.getRowObject(i) || {}]);
byGroups.push(groupColumn);
tableGroups.push(newTable);
valueGroups.push(value);
}
else {
tableGroups[valueIndex].setRows([table.getRow(i) || []]);
}
}
}
modified.deleteColumns();
modified.setColumns({
groupBy: byGroups,
table: tableGroups,
value: valueGroups
});
modifier.emit({ type: 'afterModify', detail: eventDetail, table: table });
return table;
};
/* *
*
* Static Properties
*
* */
/**
* Default options to group table rows.
*/
GroupModifier.defaultOptions = {
modifier: 'Group',
groupColumn: ''
};
return GroupModifier;
}(DataModifier));
/* *
*
* Register
*
* */
DataModifier.addModifier(GroupModifier);
/* *
*
* Export
*
* */
export default GroupModifier;

View File

@@ -0,0 +1,256 @@
/* *
*
* (c) 2020-2022 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Wojciech Chmiel
* - Sophie Bremer
*
* */
'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import DataModifier from './DataModifier.js';
import U from '../../Core/Utilities.js';
var merge = U.merge;
/* *
*
* Class
*
* */
/**
* Inverts columns and rows in a table.
*
* @private
*/
var InvertModifier = /** @class */ (function (_super) {
__extends(InvertModifier, _super);
/* *
*
* Constructor
*
* */
/**
* Constructs an instance of the invert modifier.
*
* @param {InvertModifier.Options} [options]
* Options to configure the invert modifier.
*/
function InvertModifier(options) {
var _this = _super.call(this) || this;
_this.options = merge(InvertModifier.defaultOptions, options);
return _this;
}
/* *
*
* Functions
*
* */
/**
* Applies partial modifications of a cell change to the property `modified`
* of the given modified table.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {string} columnName
* Column name of changed cell.
*
* @param {number|undefined} rowIndex
* Row index of changed cell.
*
* @param {Highcharts.DataTableCellType} cellValue
* Changed cell value.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
InvertModifier.prototype.modifyCell = function (table, columnName, rowIndex, cellValue, eventDetail) {
var modified = table.modified, modifiedRowIndex = modified.getRowIndexBy('columnNames', columnName);
if (typeof modifiedRowIndex === 'undefined') {
modified.setColumns(this.modifyTable(table.clone()).getColumns(), void 0, eventDetail);
}
else {
modified.setCell("".concat(rowIndex), modifiedRowIndex, cellValue, eventDetail);
}
return table;
};
/**
* Applies partial modifications of column changes to the property
* `modified` of the given table.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {Highcharts.DataTableColumnCollection} columns
* Changed columns as a collection, where the keys are the column names.
*
* @param {number} [rowIndex=0]
* Index of the first changed row.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
InvertModifier.prototype.modifyColumns = function (table, columns, rowIndex, eventDetail) {
var modified = table.modified, modifiedColumnNames = (modified.getColumn('columnNames') || []);
var columnNames = table.getColumnNames(), reset = (table.getRowCount() !== modifiedColumnNames.length);
if (!reset) {
for (var i = 0, iEnd = columnNames.length; i < iEnd; ++i) {
if (columnNames[i] !== modifiedColumnNames[i]) {
reset = true;
break;
}
}
}
if (reset) {
return this.modifyTable(table, eventDetail);
}
columnNames = Object.keys(columns);
for (var i = 0, iEnd = columnNames.length, column = void 0, columnName = void 0, modifiedRowIndex = void 0; i < iEnd; ++i) {
columnName = columnNames[i];
column = columns[columnName];
modifiedRowIndex = (modified.getRowIndexBy('columnNames', columnName) ||
modified.getRowCount());
for (var j = 0, j2 = rowIndex, jEnd = column.length; j < jEnd; ++j, ++j2) {
modified.setCell("".concat(j2), modifiedRowIndex, column[j], eventDetail);
}
}
return table;
};
/**
* Applies partial modifications of row changes to the property `modified`
* of the given table.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {Array<(Highcharts.DataTableRow|Highcharts.DataTableRowObject)>} rows
* Changed rows.
*
* @param {number} [rowIndex]
* Index of the first changed row.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
InvertModifier.prototype.modifyRows = function (table, rows, rowIndex, eventDetail) {
var columnNames = table.getColumnNames(), modified = table.modified, modifiedColumnNames = (modified.getColumn('columnNames') || []);
var reset = (table.getRowCount() !== modifiedColumnNames.length);
if (!reset) {
for (var i = 0, iEnd = columnNames.length; i < iEnd; ++i) {
if (columnNames[i] !== modifiedColumnNames[i]) {
reset = true;
break;
}
}
}
if (reset) {
return this.modifyTable(table, eventDetail);
}
for (var i = 0, i2 = rowIndex, iEnd = rows.length, row = void 0; i < iEnd; ++i, ++i2) {
row = rows[i];
if (row instanceof Array) {
modified.setColumn("".concat(i2), row);
}
else {
for (var j = 0, jEnd = columnNames.length; j < jEnd; ++j) {
modified.setCell("".concat(i2), j, row[columnNames[j]], eventDetail);
}
}
}
return table;
};
/**
* Inverts rows and columns in the table.
*
* @param {DataTable} table
* Table to invert.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {DataTable}
* Table with inverted `modified` property as a reference.
*/
InvertModifier.prototype.modifyTable = function (table, eventDetail) {
var modifier = this;
modifier.emit({ type: 'modify', detail: eventDetail, table: table });
var modified = table.modified;
if (table.hasColumns(['columnNames'])) { // inverted table
var columnNames = ((table.deleteColumns(['columnNames']) || {})
.columnNames || []).map(function (column) { return "".concat(column); }), columns = {};
for (var i = 0, iEnd = table.getRowCount(), row = void 0; i < iEnd; ++i) {
row = table.getRow(i);
if (row) {
columns[columnNames[i]] = row;
}
}
modified.deleteColumns();
modified.setColumns(columns);
}
else { // regular table
var columns = {};
for (var i = 0, iEnd = table.getRowCount(), row = void 0; i < iEnd; ++i) {
row = table.getRow(i);
if (row) {
columns["".concat(i)] = row;
}
}
columns.columnNames = table.getColumnNames();
modified.deleteColumns();
modified.setColumns(columns);
}
modifier.emit({ type: 'afterModify', detail: eventDetail, table: table });
return table;
};
/* *
*
* Static Properties
*
* */
/**
* Default options for the invert modifier.
*/
InvertModifier.defaultOptions = {
modifier: 'InvertModifier'
};
return InvertModifier;
}(DataModifier));
/* *
*
* Register
*
* */
DataModifier.addModifier(InvertModifier);
/* *
*
* Export
*
* */
export default InvertModifier;

View File

@@ -0,0 +1,145 @@
/* *
*
* (c) 2020-2022 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Sophie Bremer
*
* */
'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import DataModifier from './DataModifier.js';
import U from '../../Core/Utilities.js';
var merge = U.merge;
/* *
*
* Class
*
* */
/**
* Filters out table rows with a specific value range.
*
* @private
*/
var RangeModifier = /** @class */ (function (_super) {
__extends(RangeModifier, _super);
/* *
*
* Constructor
*
* */
/**
* Constructs an instance of the range modifier.
*
* @param {RangeModifier.Options} [options]
* Options to configure the range modifier.
*/
function RangeModifier(options) {
var _this = _super.call(this) || this;
_this.options = merge(RangeModifier.defaultOptions, options);
return _this;
}
/* *
*
* Functions
*
* */
/**
* Replaces table rows with filtered rows.
*
* @param {DataTable} table
* Table to modify.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {DataTable}
* Table with `modified` property as a reference.
*/
RangeModifier.prototype.modifyTable = function (table, eventDetail) {
var modifier = this;
modifier.emit({ type: 'modify', detail: eventDetail, table: table });
var _a = modifier.options, ranges = _a.ranges, strict = _a.strict;
if (ranges.length) {
var columns = table.getColumns(), rows = [], modified = table.modified;
for (var i = 0, iEnd = ranges.length, range = void 0, rangeColumn = void 0; i < iEnd; ++i) {
range = ranges[i];
if (strict &&
typeof range.minValue !== typeof range.maxValue) {
continue;
}
rangeColumn = (columns[range.column] || []);
for (var j = 0, jEnd = rangeColumn.length, cell = void 0, row = void 0; j < jEnd; ++j) {
cell = rangeColumn[j];
switch (typeof cell) {
default:
continue;
case 'boolean':
case 'number':
case 'string':
break;
}
if (strict &&
typeof cell !== typeof range.minValue) {
continue;
}
if (cell >= range.minValue &&
cell <= range.maxValue) {
row = table.getRow(j);
if (row) {
rows.push(row);
}
}
}
}
modified.deleteRows();
modified.setRows(rows);
}
modifier.emit({ type: 'afterModify', detail: eventDetail, table: table });
return table;
};
/* *
*
* Static Properties
*
* */
/**
* Default options for the range modifier.
*/
RangeModifier.defaultOptions = {
modifier: 'Range',
strict: false,
ranges: []
};
return RangeModifier;
}(DataModifier));
/* *
*
* Register
*
* */
DataModifier.addModifier(RangeModifier);
/* *
*
* Export
*
* */
export default RangeModifier;

View File

@@ -0,0 +1,112 @@
/* *
*
* (c) 2020-2022 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Wojciech Chmiel
* - Sophie Bremer
*
* */
'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import DataModifier from './DataModifier.js';
import U from '../../Core/Utilities.js';
var merge = U.merge;
/* *
*
* Class
*
* */
/**
* @private
*/
var SeriesPointsModifier = /** @class */ (function (_super) {
__extends(SeriesPointsModifier, _super);
/* *
*
* Constructor
*
* */
/**
* Constructs an instance of the series points modifier.
*
* @param {SeriesPointsModifier.Options} [options]
* Options to configure the series points modifier.
*/
function SeriesPointsModifier(options) {
var _this = _super.call(this) || this;
_this.options = merge(SeriesPointsModifier.defaultOptions, options);
return _this;
}
/* *
*
* Functions
*
* */
/**
* Renames columns to alternative column names (alias) depending on mapping
* option.
*
* @param {DataTable} table
* Table to modify.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {DataTable}
* Table with `modified` property as a reference.
*/
SeriesPointsModifier.prototype.modifyTable = function (table, eventDetail) {
var modifier = this;
modifier.emit({ type: 'modify', detail: eventDetail, table: table });
var aliasMap = modifier.options.aliasMap || {}, aliases = Object.keys(aliasMap), modified = table.modified = table.clone(false, eventDetail);
for (var i = 0, iEnd = aliases.length, alias = void 0; i < iEnd; ++i) {
alias = aliases[i];
modified.renameColumn(aliasMap[alias], alias);
}
modifier.emit({ type: 'afterModify', detail: eventDetail, table: table });
return table;
};
/* *
*
* Static Properties
*
* */
/**
* Default options for the series points modifier.
*/
SeriesPointsModifier.defaultOptions = {
modifier: 'SeriesPoints'
};
return SeriesPointsModifier;
}(DataModifier));
/* *
*
* Register
*
* */
DataModifier.addModifier(SeriesPointsModifier);
/* *
*
* Export
*
* */
export default SeriesPointsModifier;

View File

@@ -0,0 +1,251 @@
/* *
*
* (c) 2020-2022 Highsoft AS
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* Authors:
* - Sophie Bremer
*
* */
'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import DataModifier from './DataModifier.js';
import DataTable from '../DataTable.js';
import U from '../../Core/Utilities.js';
var merge = U.merge;
/* *
*
* Class
*
* */
/**
* Sort table rows according to values of a column.
*
* @private
*/
var SortModifier = /** @class */ (function (_super) {
__extends(SortModifier, _super);
/* *
*
* Constructor
*
* */
/**
* Constructs an instance of the range modifier.
*
* @param {RangeDataModifier.Options} [options]
* Options to configure the range modifier.
*/
function SortModifier(options) {
var _this = _super.call(this) || this;
_this.options = merge(SortModifier.defaultOptions, options);
return _this;
}
/* *
*
* Static Functions
*
* */
SortModifier.ascending = function (a, b) {
return ((a || 0) < (b || 0) ? -1 :
(a || 0) > (b || 0) ? 1 :
0);
};
SortModifier.descending = function (a, b) {
return ((b || 0) < (a || 0) ? -1 :
(b || 0) > (a || 0) ? 1 :
0);
};
/* *
*
* Functions
*
* */
/**
* Applies partial modifications of a cell change to the property `modified`
* of the given modified table.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {string} columnName
* Column name of changed cell.
*
* @param {number|undefined} rowIndex
* Row index of changed cell.
*
* @param {Highcharts.DataTableCellType} cellValue
* Changed cell value.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
SortModifier.prototype.modifyCell = function (table, columnName, rowIndex, cellValue, eventDetail) {
var modifier = this, _a = modifier.options, orderByColumn = _a.orderByColumn, orderInColumn = _a.orderInColumn;
if (columnName === orderByColumn) {
if (orderInColumn) {
table.modified.setCell(columnName, rowIndex, cellValue);
table.modified.setColumn(orderInColumn, modifier
.modifyTable(new DataTable(table.getColumns([orderByColumn, orderInColumn])))
.modified
.getColumn(orderInColumn));
}
else {
modifier.modifyTable(table, eventDetail);
}
}
return table;
};
/**
* Applies partial modifications of column changes to the property
* `modified` of the given table.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {Highcharts.DataTableColumnCollection} columns
* Changed columns as a collection, where the keys are the column names.
*
* @param {number} [rowIndex=0]
* Index of the first changed row.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
SortModifier.prototype.modifyColumns = function (table, columns, rowIndex, eventDetail) {
var modifier = this, _a = modifier.options, orderByColumn = _a.orderByColumn, orderInColumn = _a.orderInColumn, columnNames = Object.keys(columns);
if (columnNames.indexOf(orderByColumn) > -1) {
if (orderInColumn &&
columns[columnNames[0]].length) {
table.modified.setColumns(columns, rowIndex);
table.modified.setColumn(orderInColumn, modifier
.modifyTable(new DataTable(table.getColumns([orderByColumn, orderInColumn])))
.modified
.getColumn(orderInColumn));
}
else {
modifier.modifyTable(table, eventDetail);
}
}
return table;
};
/**
* Applies partial modifications of row changes to the property `modified`
* of the given table.
*
* @param {Highcharts.DataTable} table
* Modified table.
*
* @param {Array<(Highcharts.DataTableRow|Highcharts.DataTableRowObject)>} rows
* Changed rows.
*
* @param {number} [rowIndex]
* Index of the first changed row.
*
* @param {Highcharts.DataTableEventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {Highcharts.DataTable}
* Table with `modified` property as a reference.
*/
SortModifier.prototype.modifyRows = function (table, rows, rowIndex, eventDetail) {
var modifier = this, _a = modifier.options, orderByColumn = _a.orderByColumn, orderInColumn = _a.orderInColumn;
if (orderInColumn &&
rows.length) {
table.modified.setRows(rows, rowIndex);
table.modified.setColumn(orderInColumn, modifier
.modifyTable(new DataTable(table.getColumns([orderByColumn, orderInColumn])))
.modified
.getColumn(orderInColumn));
}
else {
modifier.modifyTable(table, eventDetail);
}
return table;
};
/**
* Sorts rows in the table.
*
* @param {DataTable} table
* Table to sort in.
*
* @param {DataEventEmitter.EventDetail} [eventDetail]
* Custom information for pending events.
*
* @return {DataTable}
* Table with `modified` property as a reference.
*/
SortModifier.prototype.modifyTable = function (table, eventDetail) {
var _a;
var modifier = this;
modifier.emit({ type: 'modify', detail: eventDetail, table: table });
var columnNames = table.getColumnNames(), rowCount = table.getRowCount(), rowReferences = table.getRows().map(function (row, index) { return ({
index: index,
row: row
}); }), _b = modifier.options, direction = _b.direction, orderByColumn = _b.orderByColumn, orderInColumn = _b.orderInColumn, compare = (direction === 'asc' ?
SortModifier.ascending :
SortModifier.descending), orderByColumnIndex = columnNames.indexOf(orderByColumn), modified = table.modified;
if (orderByColumnIndex !== -1) {
rowReferences.sort(function (a, b) { return compare(a.row[orderByColumnIndex], b.row[orderByColumnIndex]); });
}
if (orderInColumn) {
var column = [];
for (var i = 0; i < rowCount; ++i) {
column[rowReferences[i].index] = i;
}
modified.setColumns((_a = {}, _a[orderInColumn] = column, _a));
}
else {
var rows = [];
for (var i = 0; i < rowCount; ++i) {
rows.push(rowReferences[i].row);
}
modified.setRows(rows, 0);
}
modifier.emit({ type: 'afterModify', detail: eventDetail, table: table });
return table;
};
/* *
*
* Static Properties
*
* */
/**
* Default options to group table rows.
*/
SortModifier.defaultOptions = {
modifier: 'Order',
direction: 'desc',
orderByColumn: 'y'
};
return SortModifier;
}(DataModifier));
/* *
*
* Default Export
*
* */
export default SortModifier;