Module: lib/data

Methods

(static) addCalculatedField(data, fieldName, expr, variablesopt, nullable, optionsopt, nullable) → {Array.<Object>}

Add a calculated field to each row of a data array

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array. Row objects are updated with the calculated field values.

fieldName string

The calculated field name

expr string

The calculated field expression

variables Object <optional>
<nullable>
null

Additional variables for expression evaluation

options Object <optional>
<nullable>
null

The script execution options

Source:
Returns:

The updated data array

Type
Array.<Object>

(static) aggregateData(data, aggregation) → {Array.<Object>}

Aggregate data rows

Parameters:
Name Type Description
data Array.<Object>

The data array

aggregation Object

The aggregation model

Source:
Returns:

The aggregated data array

Type
Array.<Object>

(static) filterData(data, expr, variablesopt, nullable, optionsopt, nullable) → {Array.<Object>}

Filter data rows

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array

expr string

The boolean filter expression

variables Object <optional>
<nullable>
null

Additional variables for expression evaluation

options Object <optional>
<nullable>
null

The script execution options

Source:
Returns:

The filtered data array

Type
Array.<Object>

(static) joinData(leftData, rightData, joinExpr, rightExpropt, nullable, isLeftJoinopt, variablesopt, nullable, optionsopt, nullable) → {Array.<Object>}

Join two data arrays

Parameters:
Name Type Attributes Default Description
leftData Object

The left data array

rightData Object

The left data array

joinExpr string

The join expression

rightExpr string <optional>
<nullable>
null

The right join expression

isLeftJoin boolean <optional>
false

If true, perform a left join (always include left row)

variables Object <optional>
<nullable>
null

Additional variables for expression evaluation

options Object <optional>
<nullable>
null

The script execution options

Source:
Returns:

The joined data array

Type
Array.<Object>

(static) parseCSV(text) → {Array.<Object>}

Parse and validate CSV text to a data array

Parameters:
Name Type Description
text string

The CSV text

Source:
Returns:

The data array

Type
Array.<Object>

(static) sortData(data, sorts) → {Array.<Object>}

Sort data rows

Parameters:
Name Type Description
data Array.<Object>

The data array

sorts Array.<Object>

The sort field-name/descending-sort tuples

Source:
Returns:

The sorted data array

Type
Array.<Object>

(static) topData(data, count, categoryFieldsopt, nullable) → {Array.<Object>}

Top data rows

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array

count number

The number of rows to keep

categoryFields Array.<string> <optional>
<nullable>
null

The category fields

Source:
Returns:

The top data array

Type
Array.<Object>

(static) validateData(data, csvopt) → {Object}

Determine data field types and parse/validate field values

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array. Row objects are updated with parsed/validated values.

csv boolean <optional>
false

If true, parse value strings

Source:
Throws:

Throws an error if data is invalid

Returns:

The map of field name to field type ("boolean", "datetime", "number", "string")

Type
Object