Last updated

API / geotoolkit / data / DataSeries / DataSeries

Class: DataSeries<T>

data.DataSeries.DataSeries

Define a generic series of data to be used for any type.

Type parameters

NameType
Tany

Hierarchy

Table of contents

Constructors
Methods
Css Properties
Name Type Description
idnumber | stringUnique id of the data series
namestringName
typestringType
unitstringUnit of the data series
uristringUnique resource identifier

Contents

Constructors

new DataSeries&lt;T&amp;gt;(options)

new DataSeries<T>(options?)

Type parameters

NameType
Tany

Parameters

Name Type
Optional optionsOptions<T>

Overrides

AbstractDataSeries&lt;T&amp;gt;.constructor

Methods

addChild

addChild(data): DataSeries<T>

Add a child object

Parameters

Name Type Description
dataDataObject | DataObject[]the child data to be added

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.addChild


addProperties

addProperties(properties): DataSeries<T>

Add additional properties

Parameters

Name Type Description
propertiesRecord<string, any>additional properties of the dataobject

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.addProperties


addValue

addValue(value): DataSeries<T>

Adds a value to the data series.

Parameters

Name Type Description
valueTa new value

Returns

DataSeries<T>

this


addValues

addValues(array): DataSeries<T>

Adds an array of values to the data series.

Parameters

Name Type Description
arrayT[]an array of values

Returns

DataSeries<T>

this


calculate

calculate(name): any

Run function. See available formulas list by DataSeries.getFormulas

Parameters

Name Type Description
namestringname

Returns

any


clearChildren

clearChildren(): DataSeries<T>

Remove all child data

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.clearChildren


clearValues

clearValues(): DataSeries<T>

Clears all values of the data series.

Returns

DataSeries<T>

this


clone

clone(copyData?): DataObject

All subclasses should override copyConstructor or provide custom implementation for this method

Parameters

Name Type Description
Optional copyDatabooleanflag to copy data

Returns

DataObject

clone

Inherited from

AbstractDataSeries.clone


convertValues

Protected convertValues<U>(values, fromUnit?, toUnit?): U

Converts values from one unit to another specified unit.

Type parameters

Name
U

Parameters

Name Type Description
valuesUarray of values or a single value
Optional fromUnitstring | AbstractUnitthe original unit of the value(s)
Optional toUnitstring | AbstractUnitthe unit to convert the value(s) to

Returns

U

Overrides

AbstractDataSeries.convertValues


copyConstructor

Protected copyConstructor(src, copyData?): DataSeries<T>

Copy constructor function.
Function used as part of the cloning mechanism.
Implementations should copy the given instance state to this instance.

Parameters

Name Type Description
srcDataSeries<T>Source to copy from
Optional copyDatabooleancopy data

Returns

DataSeries<T>

Overrides

AbstractDataSeries.copyConstructor


dispose

dispose(): void

Dispose data object and all children. Clear all listeners

Returns

void

Inherited from

AbstractDataSeries.dispose


getChild

getChild(i): DataObject

Return data by index

Parameters

Name Type Description
inumberindex of the data

Returns

DataObject

child

Inherited from

AbstractDataSeries.getChild


getChildren

getChildren(filter?): Iterator<DataObject>

Return iterator by child data objects

Parameters

Name Type Description
Optional filter(data: DataObject) => booleana filter function. Returns all child data objects if the value is null.

Returns

Iterator<DataObject>

Inherited from

AbstractDataSeries.getChildren


getChildrenCount

getChildrenCount(): number

Return number of child data

Returns

number

Inherited from

AbstractDataSeries.getChildrenCount


getClassName

getClassName(): string

Returns

string

Inherited from

AbstractDataSeries.getClassName


getDataOrder

getDataOrder(): Order

Returns data ordering of the data series.

Returns

Order

Inherited from

AbstractDataSeries.getDataOrder


getId

getId(): string | number

Returns the identifier of the data series.

Returns

string | number

Inherited from

AbstractDataSeries.getId


getLength

getLength(): number

Returns the number of values in the data series.

Returns

number

Overrides

AbstractDataSeries.getLength


getName

getName(): string

Returns data object name

Returns

string

Inherited from

AbstractDataSeries.getName


getParent

getParent(): DataObject

Gets parent data item

Returns

DataObject

Inherited from

AbstractDataSeries.getParent


getProperties

getProperties(): OptionsOut

Gets all the properties pertaining to this object

Returns

OptionsOut

JSON options object

Overrides

AbstractDataSeries.getProperties


getProperty

getProperty(name): any

Gets property by name

Parameters

Name Type Description
namestringproperty name

Returns

any

Inherited from

AbstractDataSeries.getProperty


getTimeStamp

Protected getTimeStamp(): number

Returns the timestamp of the data series.

Returns

number

Inherited from

AbstractDataSeries.getTimeStamp


getType

getType(): string

Returns data type

Returns

string

Inherited from

AbstractDataSeries.getType


getUnit

getUnit(): AbstractUnit

Returns unit of the data series.

Returns

AbstractUnit

unit

Overrides

AbstractDataSeries.getUnit


getUri

getUri(): string

Returns unique resource identifier

Returns

string

Inherited from

AbstractDataSeries.getUri


getValue

getValue(index): T

Returns the value at given index.

Parameters

Name Type Description
indexnumberthe index should be a number greater than or equal to zero, and less than the number of values as returned by getLength() method.

Returns

T

Overrides

AbstractDataSeries.getValue


hasEventListener

hasEventListener(type, callback?): boolean

Check if a list of event listeners for this type contains this listener

Parameters

Name Type Description
typestringtype of event or property
Optional callbackFunctionto be called, if null, check if any callback is registered

Returns

boolean

Inherited from

AbstractDataSeries.hasEventListener


hasProperty

hasProperty(name): boolean

Returns whether data object contains specific property

Parameters

Name Type Description
namestringproperty name

Returns

boolean

Inherited from

AbstractDataSeries.hasProperty


indexOfChild

indexOfChild(data): number

Return index of child data ( index of the specified child or -1 if data is not found)

Parameters

Name Type Description
dataDataObjectdata object to check index

Returns

number

Inherited from

AbstractDataSeries.indexOfChild


insertChild

insertChild(index, item, silent?): DataSeries<T>

Insert item by index

Parameters

Name Type Description
indexnumberspecified index
itemDataObjectnode
Optional silentbooleanwill not fire any events if true

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.insertChild


insertValue

insertValue(index, value): DataSeries<T>

Inserts a value at the specified index.

Parameters

Name Type Description
indexnumberthe index number where to insert the value.
valueTthe value to insert

Returns

DataSeries<T>

this


insertValues

insertValues(index, array): DataSeries<T>

Inserts an array of values at the specified index.

Parameters

Name Type Description
indexnumberthe index number where to insert the values. Values will be added starting at the index number.
arrayT[]the array of values to insert

Returns

DataSeries<T>

this


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

AbstractDataSeries.isDisposed


isReadOnly

isReadOnly(): boolean

Returns false

Returns

boolean

false

Overrides

AbstractDataSeries.isReadOnly


isSilent

isSilent(): boolean

Return true if the event dispatcher doesn't notify any events

Returns

boolean

Inherited from

AbstractDataSeries.isSilent


notify

notify<E>(type, source, args?): DataSeries<T>

Notify listeners

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEevent types
sourceAbstractDataSeries<any>of the event
Optional argsEventMap[E]arguments of the event

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.notify


off

off<E>(type?, callback?): DataSeries<T>

Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
Optional typeEtype of the event
Optional callback(eventType: E, sender: DataSeries<T>, args: EventMap[E]) => voidfunction to be called

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.off


on

on<E>(type, callback): DataSeries<T>

Attach listener on event that will be called whenever the specified event is delivered to the target

If the callback function is already in the list of event listeners for this target, the function is not added a second time.

If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEtype of event or property
callback(eventType: E, sender: DataSeries<T>, args: EventMap[E]) => voidto be called

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.on


onPropertyChanged

onPropertyChanged(prop): DataSeries<T>

This method is called if property bag is changed using setProperty method

Parameters

Name Type Description
propObjectproperty
prop.namestring
prop.valueany

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.onPropertyChanged


query

query(): QueryBuilder<any>

Query data item and child items by different conditions

Example

// Select by function
import {DataObject} from '@int/geotoolkit/data/DataObject';

const dataobject = new DataObject({'name': 'test', 'uri': 'testuri', 'type': 'testtype'});
const item1 = new DataObject({'name': 'item1', 'uri': 'item1', 'type': 'test'});
const item2 = new DataObject({'name': 'item2', 'uri': 'item2', 'type': 'test'});
dataobject.addChild([item1, item2]);
const item5 = new DataObject({'name': 'item5', 'uri': 'item5', 'type': 'test'});
item2.addChild(item5);
let founditem = null;
dataobject.query()
.where( (item: DataObject) => item.getParent() === dataobject)
.where( (item: DataObject) => item.getUri() === 'item2')
.select((item: DataObject) => {
founditem = item;
});

Example

// Select by expression
dataobject.query()
.where( 'item => uri(item) == "item5"')
.select((item: DataObject) => {
founditem = item;
});

Returns

QueryBuilder<any>

query object which has methods 'where' tp specify conditions, 'select' to run query, 'selectToArray' select results to array Expressions syntax: "item => expression", where expression:

  • logical and arithmetic operators
  • embedded functions: name(item) - gets name of the data object url(item) - gets url of the data object type(item) - gets type of the data object

Inherited from

AbstractDataSeries.query


removeChild

removeChild(data, silent?): DataSeries<T>

Remove child data object

Parameters

Name Type Description
dataDataObjectdata object to be removed
Optional silentbooleanwill not fire any events if true

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.removeChild


removeValues

removeValues(index, count?): DataSeries<T>

Removes a specified amount of values at the specified index.

Parameters

Name Type Description
indexnumberthe index number where to start removing the values
Optional countnumberthe amount of values to remove

Returns

DataSeries<T>

this


reverseValues

reverseValues(): DataSeries<T>

Reverse values

Returns

DataSeries<T>


set

set(index, item): DataObject

Sets item by index

Parameters

Name Type Description
indexnumberindex of the item
itemDataObjectnode

Returns

DataObject

Inherited from

AbstractDataSeries.set


setId

setId(id): DataSeries<T>

Sets the identifier of the data series.

Parameters

Name Type Description
idstring | numbera new identifier

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.setId


setName

setName(name): DataSeries<T>

Sets data object name

Parameters

Name Type Description
namestringdata object name

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.setName


setParent

setParent(parent): DataSeries<T>

Sets parent data item

Parameters

Name Type Description
parentDataObjectparent data item

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.setParent


setProperties

setProperties(properties?): DataSeries<T>

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesOptions<any>JSON options object

Returns

DataSeries<T>

this

Overrides

AbstractDataSeries.setProperties


setProperty

setProperty(name, value): DataSeries<T>

Sets property by name

Parameters

Name Type Description
namestringproperty name
valueanyproperty value

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.setProperty


setSilent

setSilent(bool): DataSeries<T>

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.setSilent


setType

setType(type): DataSeries<T>

Sets data object type

Parameters

Name Type Description
typestringdata type

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.setType


setUnit

setUnit(unit?): DataSeries<T>

Sets unit of the data series.

Parameters

Name Type Description
Optional unitstring | AbstractUnitunit to be set

Returns

DataSeries<T>

this


setUri

setUri(uri): DataSeries<T>

Sets unique resource identifier

Parameters

Name Type Description
uristringunique identifier

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.setUri


setValue

setValue(index, value): DataSeries<T>

Sets the value at given index.

Parameters

Name Type Description
indexnumberthe index should be a number greater than or equal to zero, and less than the number of values as returned by getLength() method.
valueTvalue to set

Returns

DataSeries<T>

this


setValues

setValues(array, copy?): DataSeries<T>

Sets an array of values to the data series.

Parameters

Name Type Description
arrayT[]an array of values to set
Optional copybooleanmake a deep copy of the values

Returns

DataSeries<T>

this


toArray

toArray(copy?, unit?): T[]

Returns an array of objects in the data series.

Parameters

Name Type Description
Optional copybooleanwhether creating a copy of data
Optional unitstring | AbstractUnitunit optional output unit to convert the data to. if not specified, data will not be converted

Returns

T[]

Overrides

AbstractDataSeries.toArray


update

update(args?): DataSeries<T>

Notifies the data series has been updated. The timestamp will be updated and Events.Updated event will be fired.

Fires

Events.Updated

Parameters

Name Type Description
Optional argsObjectevent args
args.countnumber
args.indexnumber
args.typeStateChanges

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.update


updateTimeStamp

Protected updateTimeStamp(): DataSeries<T>

Updates timestamp of the data series.

Returns

DataSeries<T>

Inherited from

AbstractDataSeries.updateTimeStamp


updating

updating(args?): DataSeries<T>

Notifies the data series has been started updating. The Events.Updating event will be fired.

Fires

Events.Updating

Parameters

Name Type Description
Optional argsObjectevent args
args.countnumber
args.indexnumber
args.typeStateChanges

Returns

DataSeries<T>

this

Inherited from

AbstractDataSeries.updating


getClassName

Static getClassName(): string

Returns

string

Inherited from

AbstractDataSeries.getClassName


getFormulaDescription

Static getFormulaDescription(name?): string

Get formula's description

Parameters

Name Type Description
Optional namestringname of function

Returns

string


getFormulas

Static getFormulas(): string[]

List formulas

Returns

string[]


setFormula

Static setFormula(name, func?, desc?): void

Set function which can be used to calculate some value (e.g. sum, avg etc.)

Example

DataSeries.setFormula('concat', (series) => {
return series.toArray().join(' ');
});
const series = new DataSeries({
'type': 'string',
'data': ['just', 'some', 'text']
});
console.log(series.calculate('concat')); // 'just some text'

Parameters

Name Type Description
namestring | FormulaDescriptionname of function or parameters object
Optional funcFormulahandler, use null to unset
Optional descstringdescription

Returns

void