Home Reference Source
public class | source

ColOps

Extends:

Feature → ColOps

Column calculations extension

Constructor Summary

Public Constructor
public

Creates an instance of ColOps

Member Summary

Public Members
public

List of columns' indexes for calculations

public

List of decimal precision for calculation results

public

List of row indexes excluded from calculations

public

List of format objects used for formatting the result - refer to https://github.com/componitable/format-number to check configuration options

public
public

List of DOM element IDs containing column's calculation result

public

Callback fired after columns operations are completed

public

Callback fired before columns operations start

public

List of operations - possible values: 'sum', 'mean', 'min', 'max', 'median', 'q1', 'q3'

public

Configuration options

public

List of write methods used to write the result - possible values: 'innerHTML', 'setValue', 'createTextNode'

public

List of row indexes displaying the results

Method Summary

Public Methods
public

Calculates columns' values Configuration options are stored in 'opts' property

  • 'id' contains ids of elements showing result (array)
  • 'col' contains the columns' indexes (array)
  • 'operation' contains operation type (array, values: 'sum', 'mean', 'min', 'max', 'median', 'q1', 'q3')
  • 'write_method' array defines which method to use for displaying the result (innerHTML, setValue, createTextNode) - default: 'innerHTML'
  • 'tot_row_index' defines in which row results are displayed (integers array)
public

calcMax(values: Array): Number

Calculate the max value of passed values.

public

calcMean(values: Array): Number

Calculate the mean of passed values.

public

calcMedian(values: Array): Number

Calculate the median of passed values.

public

calcMin(values: Array): Number

Calculate the min value of passed values.

public

calcQ1(values: Array): Number

Calculate the lower quartile of passed values.

public

calcQ3(values: Array): Number

Calculate the upper quartile of passed values.

public

calcSum(values: Array): Number

Calculate the sum of passed values.

public

columnCalc(colIndex: Number, operation: String, precision: Number): Number

Make desired calculation on specified column.

public

Remove extension

public

init()

Initializes ColOps instance

public

sortColumnValues(values: Array, sorter: Function): Array

Sort passed values with supplied sorter function.

Inherited Summary

From class Feature
public

TableFilter configuration

public

TableFilter emitter instance

public

TableFilter feature setting

public

Feature name

public

Field indicating whether Feature is initialized

public

TableFilter instance

public

Destroy the feature

public

Disable the feature

public

enable()

Enable the feature

public

init()

Initialize the feature

public

Indicate whether the feature is enabled or not

public

reset()

Reset the feature after being disabled

Public Constructors

public constructor(tf: TableFilter, opts: Object) source

Creates an instance of ColOps

Override:

Feature#constructor

Params:

NameTypeAttributeDescription
tf TableFilter

TableFilter instance

opts Object

Configuration object

Public Members

public colIndexes: Array source

List of columns' indexes for calculations

public decimalPrecisions: Array source

List of decimal precision for calculation results

public excludeRows: Array source

List of row indexes excluded from calculations

public formatResults: Array source

List of format objects used for formatting the result - refer to https://github.com/componitable/format-number to check configuration options

public initialized: boolean source

Field indicating whether Feature is initialized

Override:

Feature#initialized

public labelIds: Array source

List of DOM element IDs containing column's calculation result

public onAfterOperation: Function source

Callback fired after columns operations are completed

public onBeforeOperation: Function source

Callback fired before columns operations start

public operations: Array source

List of operations - possible values: 'sum', 'mean', 'min', 'max', 'median', 'q1', 'q3'

public opts: Object source

Configuration options

public outputTypes: Array source

List of write methods used to write the result - possible values: 'innerHTML', 'setValue', 'createTextNode'

public totRowIndexes: Array source

List of row indexes displaying the results

Public Methods

public calcAll() source

Calculates columns' values Configuration options are stored in 'opts' property

  • 'id' contains ids of elements showing result (array)
  • 'col' contains the columns' indexes (array)
  • 'operation' contains operation type (array, values: 'sum', 'mean', 'min', 'max', 'median', 'q1', 'q3')
  • 'write_method' array defines which method to use for displaying the result (innerHTML, setValue, createTextNode) - default: 'innerHTML'
  • 'tot_row_index' defines in which row results are displayed (integers array)

  • changes made by Nuovella: (1) optimized the routine (now it will only process each column once), (2) added calculations for the median, lower and upper quartile.

public calcMax(values: Array): Number source

Calculate the max value of passed values.

Params:

NameTypeAttributeDescription
values Array
  • optional
  • default: []

List of values

Return:

Number

public calcMean(values: Array): Number source

Calculate the mean of passed values.

Params:

NameTypeAttributeDescription
values Array
  • optional
  • default: []

List of values

Return:

Number

public calcMedian(values: Array): Number source

Calculate the median of passed values.

Params:

NameTypeAttributeDescription
values Array
  • optional
  • default: []

List of values

Return:

Number

public calcMin(values: Array): Number source

Calculate the min value of passed values.

Params:

NameTypeAttributeDescription
values Array
  • optional
  • default: []

List of values

Return:

Number

public calcQ1(values: Array): Number source

Calculate the lower quartile of passed values.

Params:

NameTypeAttributeDescription
values Array
  • optional
  • default: []

List of values

Return:

Number

public calcQ3(values: Array): Number source

Calculate the upper quartile of passed values.

Params:

NameTypeAttributeDescription
values Array
  • optional
  • default: []

List of values

Return:

Number

public calcSum(values: Array): Number source

Calculate the sum of passed values.

Params:

NameTypeAttributeDescription
values Array
  • optional
  • default: []

List of values

Return:

Number

public columnCalc(colIndex: Number, operation: String, precision: Number): Number source

Make desired calculation on specified column.

Params:

NameTypeAttributeDescription
colIndex Number

Column index

operation String
  • optional
  • default: SUM

Operation type

precision Number

Decimal precision

Return:

Number

public destroy() source

Remove extension

Override:

Feature#destroy

public init() source

Initializes ColOps instance

Override:

Feature#init

public sortColumnValues(values: Array, sorter: Function): Array source

Sort passed values with supplied sorter function.

Params:

NameTypeAttributeDescription
values Array
  • optional
  • default: []

List of values to be sorted

sorter Function

Sorter function

Return:

Array