API / geotoolkit / charts / DataSource / 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);↳
DataSource
Constructors
Methods
Constructors
• new DataSource(data?)
Creates data source
| Name | Type | Description |
|---|---|---|
Optional data | AbstractDataTable | options |
EventDispatcher.constructor
Methods
▸ add(data, tableName?): DataSource
Adds data table to data source using its name as identifier
Throws
Error if table with this identifier already exists
| Name | Type | Description |
|---|---|---|
data | AbstractDataTable | data table to add |
Optional tableName | string | table name to use as identifier |
▸ addArray(data, tableId?, unit?, field?): string
Adds data array to the source, automatically generating identifier for it to be used
| Name | Type | Description |
|---|---|---|
data | string | string[] | number[] | Date[] | RecordObj[] | data array to save |
Optional tableId | string | table identifier for the data table (if needed) |
Optional unit | string | unit of the data series |
Optional field | string | field name for object data case |
string
▸ addSelection(selection, name?, tableId?): DataSource
Adds new selection series to the table
Throws
Error if series already exists
| Name | Type | Description |
|---|---|---|
selection | SelectionSeries | series to be added |
Optional name | string | identifier for the added series |
Optional tableId | string | table identifier to store added selection series |
▸ clear(tableId?): DataSource
Removes data table(s) from the storage
| Name | Type |
|---|---|
Optional tableId | string |
▸ dispose(): void
Dispose.
void
▸ getClassName(): string
string
▸ getDataSeries(id, returnType?): INumericalDataSeries & AbstractDataSeries<any>
Returns data series by series identifier
| Name | Type | Description |
|---|---|---|
id | string | series identifier (use ':' separator to add table identifier) |
Optional returnType | string | data type for the returning series |
INumericalDataSeries & AbstractDataSeries<any>
▸ getDataSeries(id): DataSeries<any>
Returns data series by series identifier
| Name | Type | Description |
|---|---|---|
id | string | series identifier (use ':' separator to add table identifier) |
DataSeries<any>
▸ getDataSeriesIds(tableId?): string[]
Returns array of data series identifiers stored in the table.
| Name | Type |
|---|---|
Optional tableId | string |
string[]
▸ getDataTable(tableId?): AbstractDataTable
Returns data table by identifier
| Name | Type | Description |
|---|---|---|
Optional tableId | string | table identifier |
▸ 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(...);| Name | Type | Description |
|---|---|---|
Optional name | string | selection series identifier |
Optional tableId | string | selection series table |
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
EventDispatcher.hasEventListener
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isGeneratedName(name, tableId?): boolean
Returns true if provided series name was generated automatically by data source, false otherwise
| Name | Type | Description |
|---|---|---|
name | string | series name |
Optional tableId | string | table identifier (if exists) |
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): DataSource
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | DataSource | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: DataSource, args: EventMap[E]) => void | function to be called |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: DataSource, args: EventMap[E]) => void | to be called |
this
▸ remove(data): DataSource
Removes data table from the source
| Name | Type | Description |
|---|---|---|
data | string | AbstractDataTable | data table or table id to remove |
▸ removeSelection(name?, tableId?): DataSource
Removes selection series
| Name | Type | Description |
|---|---|---|
Optional name | string | identifier for the series |
Optional tableId | string | table identifier |
▸ set(data, tableName?): DataSource
Sets data table to data source, overwriting existed data table with the same name (if exists)
| Name | Type | Description |
|---|---|---|
data | AbstractDataTable | data table to set |
Optional tableName | string | table identifier to use |
▸ setSelection(selection, name?, tableId?): DataSource
Adds new selection series to the table
| Name | Type | Description |
|---|---|---|
selection | SelectionSeries | series to be added |
Optional name | string | identifier for the added series |
Optional tableId | string | table identifier to store added selection series |
▸ setSilent(bool): DataSource
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ Static getClassName(): string
string