Last updated

API / geotoolkit / charts / DataSource / DataSource

Class: DataSource

charts.DataSource.DataSource

Define a generic chart data to be used for any chart type.

Example

import {DataTable} from '@int/geotoolkit/data/DataTable';
import {DataSource} from '@int/geotoolkit/charts/DataSource';

const table1 = new DataTable({
'name': 'table-1', // unique name
'cols': […] // table data series
});
const data = new DataSource();
// add new tables:
data.add(table1);
data.add(table2);

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new DataSource(data)

new DataSource(data?)

Creates data source

Parameters

Name Type Description
Optional dataAbstractDataTableoptions

Overrides

EventDispatcher.constructor

Methods

add

add(data, tableName?): DataSource

Adds data table to data source using its name as identifier

Throws

Error if table with this identifier already exists

Parameters

Name Type Description
dataAbstractDataTabledata table to add
Optional tableNamestringtable name to use as identifier

Returns

DataSource


addArray

addArray(data, tableId?, unit?, field?): string

Adds data array to the source, automatically generating identifier for it to be used

Parameters

Name Type Description
datastring | string[] | number[] | Date[] | RecordObj[]data array to save
Optional tableIdstringtable identifier for the data table (if needed)
Optional unitstringunit of the data series
Optional fieldstringfield name for object data case

Returns

string


addSelection

addSelection(selection, name?, tableId?): DataSource

Adds new selection series to the table

Throws

Error if series already exists

Parameters

Name Type Description
selectionSelectionSeriesseries to be added
Optional namestringidentifier for the added series
Optional tableIdstringtable identifier to store added selection series

Returns

DataSource


clear

clear(tableId?): DataSource

Removes data table(s) from the storage

Parameters

Name Type
Optional tableIdstring

Returns

DataSource


dispose

dispose(): void

Dispose.

Returns

void

Inherited from

EventDispatcher.dispose


getClassName

getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


getDataSeries

getDataSeries(id, returnType?): INumericalDataSeries & AbstractDataSeries<any>

Returns data series by series identifier

Parameters

Name Type Description
idstringseries identifier (use ':' separator to add table identifier)
Optional returnTypestringdata type for the returning series

Returns

INumericalDataSeries & AbstractDataSeries<any>

getDataSeries(id): DataSeries<any>

Returns data series by series identifier

Parameters

Name Type Description
idstringseries identifier (use ':' separator to add table identifier)

Returns

DataSeries<any>


getDataSeriesIds

getDataSeriesIds(tableId?): string[]

Returns array of data series identifiers stored in the table.

Parameters

Name Type
Optional tableIdstring

Returns

string[]


getDataTable

getDataTable(tableId?): AbstractDataTable

Returns data table by identifier

Parameters

Name Type Description
Optional tableIdstringtable identifier

Returns

AbstractDataTable


getSelection

getSelection(name?, tableId?): SelectionSeries

Returns selection series for shared selection state(s)

Example

widget.addChart({
'series': {
'table': 'my-table', // table to connect chart (optional)
'selection': 'my-column', // column for selection synchronization, 'default' id used if no specified
'x': ... // other data
}
});
// default column from default table, can be used for simple cases:
let selection = data.getSelection();

// specify column and table ids to avoid ambiguity (recommended):
selection = data.getSelection('my-column', 'my-table');
// reference to column from table using ':', result is the same as the line above:
selection = data.getSelection('my-table:my-column');

// use it to change the selection:
selection.select(...);

Parameters

Name Type Description
Optional namestringselection series identifier
Optional tableIdstringselection series table

Returns

SelectionSeries


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

EventDispatcher.hasEventListener


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

EventDispatcher.isDisposed


isGeneratedName

isGeneratedName(name, tableId?): boolean

Returns true if provided series name was generated automatically by data source, false otherwise

Parameters

Name Type Description
namestringseries name
Optional tableIdstringtable identifier (if exists)

Returns

boolean


isSilent

isSilent(): boolean

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

Returns

boolean

Inherited from

EventDispatcher.isSilent


notify

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

Notify listeners

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEevent types
sourceDataSourceof the event
Optional argsEventMap[E]arguments of the event

Returns

DataSource

this

Overrides

EventDispatcher.notify


off

off<E>(type?, callback?): DataSource

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: DataSource, args: EventMap[E]) => voidfunction to be called

Returns

DataSource

this

Overrides

EventDispatcher.off


on

on<E>(type, callback): DataSource

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: DataSource, args: EventMap[E]) => voidto be called

Returns

DataSource

this

Overrides

EventDispatcher.on


remove

remove(data): DataSource

Removes data table from the source

Parameters

Name Type Description
datastring | AbstractDataTabledata table or table id to remove

Returns

DataSource


removeSelection

removeSelection(name?, tableId?): DataSource

Removes selection series

Parameters

Name Type Description
Optional namestringidentifier for the series
Optional tableIdstringtable identifier

Returns

DataSource


set

set(data, tableName?): DataSource

Sets data table to data source, overwriting existed data table with the same name (if exists)

Parameters

Name Type Description
dataAbstractDataTabledata table to set
Optional tableNamestringtable identifier to use

Returns

DataSource


setSelection

setSelection(selection, name?, tableId?): DataSource

Adds new selection series to the table

Parameters

Name Type Description
selectionSelectionSeriesseries to be added
Optional namestringidentifier for the added series
Optional tableIdstringtable identifier to store added selection series

Returns

DataSource


setSilent

setSilent(bool): DataSource

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

DataSource

this

Inherited from

EventDispatcher.setSilent


getClassName

Static getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName