API / geotoolkit / data / DataSeriesView / DataSeriesView
data.DataSeriesView.DataSeriesView
Define a generic read-only view of an underlying DataSeries or DataSeriesView. A DataSeriesView allows unit conversion, pre- and post-processing and filtering.
Throws
if data is not an instance of DataSeries or DataSeriesView
| Name | Type |
|---|---|
T | any |
↳
DataSeriesView
Constructors
Methods
Css Properties
| Name | Type | Description |
|---|---|---|
data | AbstractDataSeries | The original data series or data series view |
data-id | number | string | Unique id of the data series |
data-name | string | Name |
data-type | string | Type |
data-uri | string | Unique resource identifier |
id | number | string | Unique id of the data series |
name | string | Name |
type | string | Type |
unit | string | Unit of the view |
uri | string | Unique resource identifier |
Constructors
• new DataSeriesView<T>(options?)
Create DataSeriesView
| Name | Type |
|---|---|
T | any |
| Name | Type | Description |
|---|---|---|
Optional options | DataSeriesView<T> | AbstractDataSeries<T> | Options<T> | the original data series or data series view or properties object |
AbstractDataSeries<T&gt;.constructor
Methods
▸ addChild(data): DataSeriesView<T>
Add a child object
| Name | Type | Description |
|---|---|---|
data | DataObject | DataObject[] | the child data to be added |
this
▸ addFilter(filter, filterType?): DataSeriesView<T>
Adds a value filter to the end of existing filters.
| Name | Type | Description |
|---|---|---|
filter | DataSeriesView<T> | T | FilterCallback<T> | filter function or DataSeriesView or series item. If DataSeriesView specified, changes from DataSeriesView might not be applied. |
Optional filterType | FilterType | filter type. Value type filter only filters by value and index passed in will be null. Value type filter will be optimized. |
this
▸ addProperties(properties): DataSeriesView<T>
Add additional properties
| Name | Type | Description |
|---|---|---|
properties | Record<string, any> | additional properties of the dataobject |
this
AbstractDataSeries.addProperties
▸ clearChildren(): DataSeriesView<T>
Remove all child data
this
AbstractDataSeries.clearChildren
▸ clearFilters(): DataSeriesView<T>
Clears all filters.
this
▸ clone(): DataSeriesView<T>
Returns a clone of the data series view.
clone
▸ Protected convertValues<U>(values, fromUnit?, toUnit?): U
Converts values from one unit to another specified unit.
| Name |
|---|
U |
| Name | Type | Description |
|---|---|---|
values | U | array of values or a single value |
Optional fromUnit | string | AbstractUnit | the original unit of the value(s) |
Optional toUnit | string | AbstractUnit | the unit to convert the value(s) to |
U
AbstractDataSeries.convertValues
▸ Protected copyConstructor(src): DataSeriesView<T>
Copy constructor function.
Function used as part of the cloning mechanism.
Implementations should copy the given instance state to this instance.
| Name | Type | Description |
|---|---|---|
src | DataObject | Source to copy from |
this
AbstractDataSeries.copyConstructor
▸ dispose(): void
Dispose data object and all children. Clear all listeners
void
▸ getChild(i): DataObject
Return data by index
| Name | Type | Description |
|---|---|---|
i | number | index of the data |
child
▸ getChildren(filter?): Iterator<DataObject>
Return iterator by child data objects
| Name | Type | Description |
|---|---|---|
Optional filter | (data: DataObject) => boolean | a filter function. Returns all child data objects if the value is null. |
AbstractDataSeries.getChildren
▸ getChildrenCount(): number
Return number of child data
number
AbstractDataSeries.getChildrenCount
▸ getClassName(): string
string
AbstractDataSeries.getClassName
▸ getDataOrder(): Order
Returns data ordering of the data series.
AbstractDataSeries.getDataOrder
▸ getFilters(): (DataSeriesView<T> | T | FilterCallback<T>)[]
Return the array of value filters as functions or DataSeriesView or series item.
(DataSeriesView<T> | T | FilterCallback<T>)[]
▸ getId(): string | number
Returns the identifier of the data series.
string | number
▸ getLength(): number
Returns the number of values in the data series.
number
▸ getName(): string
Returns data object name
string
▸ getParent(): DataObject
Gets parent data item
▸ getPostProcessor(): ProcessorCallback<T>
Returns post-processor function.
▸ getPreProcessor(): ProcessorCallback<T>
Returns pre-processor function.
▸ getProperties(): OptionsOut
Gets all the properties pertaining to this object
JSON options object
AbstractDataSeries.getProperties
▸ getProperty(name): any
Gets property by name
| Name | Type | Description |
|---|---|---|
name | string | property name |
any
AbstractDataSeries.getProperty
▸ Protected getTimeStamp(): number
Returns the timestamp of the data series.
number
AbstractDataSeries.getTimeStamp
▸ getType(): string
Returns data type
string
▸ getUnit(): AbstractUnit
Returns unit of the data series.
unit
▸ getUri(): string
Returns unique resource identifier
string
▸ getValue(index): T
Returns the value at the given index. The type of the returned value depends on the data series type.
| Name | Type |
|---|---|
index | number |
T
▸ getViewUnit(): AbstractUnit
Returns view unit of the data series view. This method returns unit set through setUnit() method, which can be different from getUnit() if view unit is not convertible to data unit.
▸ 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
AbstractDataSeries.hasEventListener
▸ hasProperty(name): boolean
Returns whether data object contains specific property
| Name | Type | Description |
|---|---|---|
name | string | property name |
boolean
AbstractDataSeries.hasProperty
▸ indexOfChild(data): number
Return index of child data ( index of the specified child or -1 if data is not found)
| Name | Type | Description |
|---|---|---|
data | DataObject | data object to check index |
number
AbstractDataSeries.indexOfChild
▸ insertChild(index, item, silent?): DataSeriesView<T>
Insert item by index
| Name | Type | Description |
|---|---|---|
index | number | specified index |
item | DataObject | node |
Optional silent | boolean | will not fire any events if true |
this
AbstractDataSeries.insertChild
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isReadOnly(): boolean
Returns true
boolean
true
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): DataSeriesView<T>
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | DataSeriesView<any> | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ off<E>(type?, callback?): DataSeriesView<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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: DataSeriesView<T>, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): DataSeriesView<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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: DataSeriesView<T>, args: EventMap[E]) => void | to be called |
this
▸ onPropertyChanged(prop): DataSeriesView<T>
This method is called if property bag is changed using setProperty method
| Name | Type | Description |
|---|---|---|
prop | Object | property |
prop.name | string | |
prop.value | any |
this
AbstractDataSeries.onPropertyChanged
▸ 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;
});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
▸ removeChild(data, silent?): DataSeriesView<T>
Remove child data object
| Name | Type | Description |
|---|---|---|
data | DataObject | data object to be removed |
Optional silent | boolean | will not fire any events if true |
this
AbstractDataSeries.removeChild
▸ removeFilter(filter): DataSeriesView<T>
Removes a value filter from the data series view.
| Name | Type | Description |
|---|---|---|
filter | DataSeriesView<T> | T | FilterCallback<T> | filter to remove |
this
▸ replaceFilter(oldFilter, newFilter, filterType?): DataSeriesView<T>
Replaces an existing filter with a new filter.
| Name | Type | Description |
|---|---|---|
oldFilter | DataSeriesView<T> | T | FilterCallback<T> | old filter |
newFilter | DataSeriesView<T> | T | FilterCallback<T> | new filter |
Optional filterType | FilterType | filter type |
this
▸ set(index, item): DataObject
Sets item by index
| Name | Type | Description |
|---|---|---|
index | number | index of the item |
item | DataObject | node |
▸ setId(id): DataSeriesView<T>
Sets the identifier of the data series.
| Name | Type | Description |
|---|---|---|
id | string | number | a new identifier |
this
▸ setName(name): DataSeriesView<T>
DataSeriesView does not support setName() method.
| Name | Type | Description |
|---|---|---|
name | string | data object name |
this
▸ setParent(parent): DataSeriesView<T>
Sets parent data item
| Name | Type | Description |
|---|---|---|
parent | DataObject | parent data item |
this
▸ setPostProcessor(postProcessor?): DataSeriesView<T>
Sets post-processor function. This processor will be called after filters.
| Name | Type | Description |
|---|---|---|
Optional postProcessor | ProcessorCallback<T> | post-processor function. The function must accept single value and array of values as parameter. |
▸ setPreProcessor(preProcessor?): DataSeriesView<T>
Sets pre-processor function. This processor will be called before filters.
| Name | Type | Description |
|---|---|---|
Optional preProcessor | ProcessorCallback<T> | pre-processor function. The function must accept single value and array of values as parameter. |
▸ setProperties(properties?): DataSeriesView<T>
Sets all the properties pertaining to this object
| Name | Type | Description |
|---|---|---|
Optional properties | Options<T> | An object containing the properties to set |
AbstractDataSeries.setProperties
▸ setProperty(name, value): DataSeriesView<T>
Sets property by name
| Name | Type | Description |
|---|---|---|
name | string | property name |
value | any | property value |
this
AbstractDataSeries.setProperty
▸ setSilent(bool): DataSeriesView<T>
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ setType(type): DataSeriesView<T>
Sets data object type
| Name | Type | Description |
|---|---|---|
type | string | data type |
this
▸ setUnit(unit?): DataSeriesView<T>
Sets view unit of the data series view.
| Name | Type | Description |
|---|---|---|
Optional unit | string | AbstractUnit | unit to set |
▸ setUri(uri): DataSeriesView<T>
Sets unique resource identifier
| Name | Type | Description |
|---|---|---|
uri | string | unique identifier |
this
▸ Protected synchronize(): void
Synchronizes internal mapping for filters.
void
▸ toArray(copy?, unit?): T[]
Returns an array of objects in the data series.
| Name | Type | Description |
|---|---|---|
Optional copy | boolean | whether creating a copy of data |
Optional unit | string | AbstractUnit | unit optional output unit to convert the data to. if not specified, data will not be converted |
T[]
▸ update(args?): DataSeriesView<T>
Notifies the data series has been updated. The timestamp will be updated and Events.Updated event will be fired.
Fires
| Name | Type | Description |
|---|---|---|
Optional args | Object | event args |
args.count | number | |
args.index | number | |
args.type | StateChanges |
this
▸ Protected updateTimeStamp(): DataSeriesView<T>
Updates timestamp of the data series.
AbstractDataSeries.updateTimeStamp
▸ updating(args?): DataSeriesView<T>
Notifies the data series has been started updating. The Events.Updating event will be fired.
Fires
| Name | Type | Description |
|---|---|---|
Optional args | Object | event args |
args.count | number | |
args.index | number | |
args.type | StateChanges |
this
▸ Static getClassName(): string
string