Options
All
  • Public
  • Public/Protected
  • All
Menu
summary

XyDataSeries is a DataSeries for holding X, Y data in SciChart's 2D JavaScript Charts

description

The XyDataSeries is primarily used with our JavaScript Line Chart, but can also be used by the JavaScript Scatter Chart or JavaScript Mountain/Area Chart and JavaScript Column Chart.

To instantiate an XyDataSeries, use the following code:

const xyDataSeries = new XyDataSeries(wasmContext);
xyDataSeries.append(1, 2); // Append a single x,y point
xyDataSeries.appendRange([3, 4], [3, 4]); // Append multiple x,y points (faster)
xyDataSeries.insert(0, 9, 10); // Insert a point at index 0
xyDataSeries.update(0, 11, 12); // Update a point at index 0
xyDataSeries.removeAt(0); // Remove a point at index 0
xyDataSeries.clear(); // Clear the dataseries
xyDataSeries.delete(); // Delete the dataseries and native (WebAssembly) memory
remarks

A DataSeries stores the data to render. This is independent from the RenderableSeries which defines how that data should be rendered.

See derived types of BaseDataSeries to find out what data-series are available. See derived types of IRenderableSeries to find out what 2D JavaScript Chart types are available.


📚 Docs: https://www.scichart.com/documentation/js/v4/2d-charts/chart-types/data-series-api/data-series-api-overview/

Type parameters

  • T

Hierarchy

Implements

Index

Constructors

constructor

Properties

Readonly arrayCount

arrayCount: number = 1

The number of y values arrays in this DataSeries

Readonly dataChanged

dataChanged: EventHandler<IDataChangeArgs> = new EventHandler<IDataChangeArgs>()

An EventHandler which is raised when the data changes.

remarks

To subscribe to dataChanged, use the following code:

const dataSeries = new XyDataSeries(wasmContext);
const callback = () => {
   // Data has changed
};
dataSeries.dataChanged.subscribe(callback);

To unsubscribe from dataChanged, use the following code:

const dataSeries = new XyDataSeries(wasmContext);
dataSeries.dataChanged.unsubscribe(callback);

Readonly dataDistributionCalculator

dataDistributionCalculator: IDataDistributionCalculator = new DataDistributionCalculator()

Gets the IDataDistributionCalculator instance for this DataSeries. Used when resampling data to determine the correct algorithm

dataIds

dataIds: Record<number | string, number[]>

If set, these will be included in the serialised definition, so that it can be used with sharedData

Protected doubleVectorProvider

doubleVectorProvider: IDoubleVectorProvider = new DoubleVectorProvider()

Readonly id

id: string

A unique Id for the IDataSeries

Protected includeInYRange

includeInYRange: boolean[]

Protected indexes

indexes: SCRTDoubleVector

Protected isDeleted

isDeleted: boolean

minXSpacing

minXSpacing: number = 0

Readonly type

type: Xy = EDataSeriesType.Xy

Gets the EDataSeriesType type of the DataSeries

Readonly valueNames

valueNames: string[]

Readonly webAssemblyContext

webAssemblyContext: TSciChart

The SciChart WebAssembly Context containing native methods and access to our WebGL2 Engine

xFinalAnimationValues

xFinalAnimationValues: SCRTDoubleVector

X vector with final animation values

xInitialAnimationValues

xInitialAnimationValues: SCRTDoubleVector

X vector with initial animation values

Protected xValues

xValues: SCRTDoubleVector

yFinalAnimationValuesArray

yFinalAnimationValuesArray: SCRTDoubleVector[] = []

Y vector with final animation values

yInitialAnimationValuesArray

yInitialAnimationValuesArray: SCRTDoubleVector[] = []

Y vector with initial animation values

Protected Readonly yValuesArray

yValuesArray: SCRTDoubleVector[] = []

Accessors

capacity

  • get capacity(): number
  • set capacity(value: number): void
  • Gets or sets the capacity of data-points in the DataSeries

    Returns number

  • Gets or sets the capacity of data-points in the DataSeries

    Parameters

    • value: number

    Returns void

changeCount

  • get changeCount(): number
  • Gets the change count for this data series. Allows to indentify when data series was changed

    inheritdoc

    Returns number

containsNaN

  • get containsNaN(): boolean
  • set containsNaN(containsNaN: boolean): void
  • Gets or sets whether the Y data contains NaN values. Set containsNaN = false for the performance optimization when the series has no NaNs

    inheritdoc

    Returns boolean

  • Gets or sets whether the Y data contains NaN values. Set containsNaN = false for the performance optimization when the series has no NaNs

    inheritdoc

    Parameters

    • containsNaN: boolean

    Returns void

dataSeriesName

  • get dataSeriesName(): string
  • set dataSeriesName(dataSeriesName: string): void
  • Gets the DataSeries name. This is used in legend controls and tooltips to identify the series

    inheritdoc

    Returns string

  • Gets the DataSeries name. This is used in legend controls and tooltips to identify the series

    inheritdoc

    Parameters

    • dataSeriesName: string

    Returns void

fifoCapacity

  • get fifoCapacity(): number
  • Gets the maximum size of the dataSeries in FIFO (First In First Out) mode. This can only be set in the constructor options. If set, the dataSeries supports only append, appendRange, update and clear. Any data that is appended once the dataSeries has reached fifoCapacity will cause the oldest data to be discarded. This is a much more efficient than appending and removing for achieving scrolling data. Spline series and Stacked series currently do not support fifo mode. To get the scrolling effect, you need to consider the behaviour of your X Axis. You can either Use a CategoryAxis Use a NumericAxis with increasing x values, and update the visibleRange (or use zoomExtents)

    inheritdoc

    Returns number

fifoStartIndex

  • get fifoStartIndex(): number
  • Internal only - Get the starting offset when in fifo mode

    inheritdoc

    Returns number

fifoSweeping

  • get fifoSweeping(): boolean
  • set fifoSweeping(enabled: boolean): void
  • If true, data in fifo mode will not be "unwrapped" before drawing, giving ecg style sweeping mode. To get the sweeping effect, you need to consider the behaviour of your X Axis. You can either Use a CategoryAxis Use a NumericAxis and make your x values an offset from the first value, eg by doing x % fifoCapcity

    inheritdoc

    Returns boolean

  • If true, data in fifo mode will not be "unwrapped" before drawing, giving ecg style sweeping mode. To get the sweeping effect, you need to consider the behaviour of your X Axis. You can either Use a CategoryAxis Use a NumericAxis and make your x values an offset from the first value, eg by doing x % fifoCapcity

    inheritdoc

    Parameters

    • enabled: boolean

    Returns void

fifoSweepingGap

  • get fifoSweepingGap(): number
  • set fifoSweepingGap(fifoSweepingGap: number): void
  • In fifo sweeping mode, the number of earliest points to skip to create a gap between the latest and earliest data

    inheritdoc

    Returns number

  • In fifo sweeping mode, the number of earliest points to skip to create a gap between the latest and earliest data

    inheritdoc

    Parameters

    • fifoSweepingGap: number

    Returns void

hasMetadata

  • get hasMetadata(): boolean
  • Check if the series has an existing metadata

    Returns boolean

hasValues

  • get hasValues(): boolean
  • When true, the DataSeries has values, else it is empty

    inheritdoc

    Returns boolean

isEvenlySpaced

  • get isEvenlySpaced(): boolean
  • set isEvenlySpaced(isSorted: boolean): void

isSorted

  • get isSorted(): boolean
  • set isSorted(isSorted: boolean): void
  • Gets or sets whether the X-values are sorted ascending or not. See remarks at IDataSeries.isSorted for further information

    inheritdoc

    Returns boolean

  • Gets or sets whether the X-values are sorted ascending or not. See remarks at IDataSeries.isSorted for further information

    inheritdoc

    Parameters

    • isSorted: boolean

    Returns void

xRange

  • Gets the range in the X-direction for this DataSeries

    inheritdoc

    Returns NumberRange

yFinalAnimationValues

  • get yFinalAnimationValues(): SCRTDoubleVector

yInitialAnimationValues

  • get yInitialAnimationValues(): SCRTDoubleVector

yValues

  • get yValues(): SCRTDoubleVector
  • Returns SCRTDoubleVector

Methods

append

  • Appends a single X, Y point to the DataSeries

    remarks

    For best performance on drawing large datasets, use the appendRange method

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • x: number

      The X-value

    • y: number

      The Y-value

    • Optional metadata: IPointMetadata

      The point metadata

    Returns void

appendBufferRangeN

  • appendBufferRangeN(xValues: ArrayBuffer, yValuesArray: ArrayBuffer[], metadata?: T[], onAppend?: () => void): void
  • Appends a range of X, yValuesArray points to the DataSeries

    remarks

    This method is an optimized version of the appendRangeN. It skips some data validation steps. So, make sure to set the proper optimization flags manually (isSorted, containsNaN, etc.) when using this method.

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • xValues: ArrayBuffer

      The X-values defined as 64bit float numbers contained within an ArrayBuffer

    • yValuesArray: ArrayBuffer[]

      An array of Y-value arrays defined as 64bit float numbers contained within an ArrayBuffer

    • Optional metadata: T[]

      The array of point metadata

    • Optional onAppend: () => void
        • (): void
        • Returns void

    Returns void

Protected appendMetadata

  • appendMetadata(metadata: T): void

Protected appendMetadataRange

  • appendMetadataRange(metadata: T[], length: number): void

appendN

  • appendN(x: number, yArray: number[], metadata?: T, onAppend?: () => void): void
  • Appends a single X, ...YArray, point to the DataSeries

    remarks

    For best performance on drawing large datasets, use the appendRange method

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • x: number

      The X-value

    • yArray: number[]

      An array of the y values

    • Optional metadata: T

      The point metadata

    • Optional onAppend: () => void
        • (): void
        • Returns void

    Returns void

appendRange

  • Appends a range of X, Y points to the DataSeries

    remarks

    This method is considerably higher performance than append which appends a single point

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    Returns void

appendRangeN

  • appendRangeN(xValues: NumberArray, yValuesArray: NumberArray[], metadata?: T[], onAppend?: () => void): void
  • Appends a range of X, yValuesArray points to the DataSeries

    remarks

    This method is considerably higher performance than append which appends a single point

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • xValues: NumberArray

      The X-values

    • yValuesArray: NumberArray[]

      An array of Y-value arrays

    • Optional metadata: T[]

      The array of point metadata

    • Optional onAppend: () => void
        • (): void
        • Returns void

    Returns void

Protected calculateInitialCapacity

clear

  • clear(): void

count

  • count(): number

createAnimationVectors

  • createAnimationVectors(): void

delete

  • delete(): void
  • Deletes native (WebAssembly) memory used by this type, after which it cannot be used.

    remarks

    Call .delete() before finishing with the object to ensure that WebAssmembly memory leaks do not occur.

    All elements within SciChart's High Performance Realtime JavaScript Charts which implement IDeletable must be deleted manually to free native (WebAssembly) memory

    Returns void

findIndex

  • findIndex(xValue: number, searchMode?: ESearchMode): number
  • Finds the nearest index of the xValue passed in by performing binary or linear search on the X-Values array. Returns -1 for index not found. Other negative numbers indicate an error condition

    Parameters

    • xValue: number

      the X-value to find

    • Default value searchMode: ESearchMode = ESearchMode.Nearest

    Returns number

    The index, or -1 if not found

getIndicesRange

  • Gets the integer indices of the XValues array that are currently in the VisibleRange passed in, and an undefined range otherwise.

    Parameters

    • xRange: NumberRange

      The VisibleRange to get the indices range

    • Default value isCategoryData: boolean = false

      If True the renderable series uses CategoryAxis

    • Default value downSearchMode: ESearchMode = ESearchMode.RoundDown

      Specifies the search mode used to look for the index of visibleRange.Min

    • Default value upSearchMode: ESearchMode = ESearchMode.RoundUp

      Specifies the search mode used to look for the index of visibleRange.Max

    Returns NumberRange

    numberRange The indices to the X-Data that are currently in range.

getIsDeleted

  • getIsDeleted(): boolean

getMetadataAt

  • getMetadataAt(index: number, ignoreFifo?: boolean): T
  • Gets the metadata by index

    Parameters

    • index: number

      The X index

    • Default value ignoreFifo: boolean = false

    Returns T

getMetadataLength

  • getMetadataLength(): number

getNativeIndexes

  • getNativeIndexes(): SCRTDoubleVector

getNativeValue

  • getNativeValue(values: SCRTDoubleVector, index: number): number

getNativeXValues

  • getNativeXValues(): SCRTDoubleVector

getNativeYValues

  • getNativeYValues(i?: number): SCRTDoubleVector

Protected getOptions

getWindowedYRange

getXRange

getXRangeByName

getXValues

getYValues

getYValuesArray

getYValuesByName

hasMetadataGenerator

  • hasMetadataGenerator(): boolean

insert

  • insert(startIndex: number, x: number, y: number, metadata?: IPointMetadata): void
  • summary

    Inserts a single X,Y value at the start index

    remarks

    For best performance on drawing large datasets, use the insertRange method

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • startIndex: number

      the index to insert at

    • x: number

      the X value

    • y: number

      the Y value

    • Optional metadata: IPointMetadata

      The point metadata

    Returns void

Protected insertMetadata

  • insertMetadata(startIndex: number, metadata: T): void

Protected insertMetadataRange

  • insertMetadataRange(startIndex: number, metadata: T[]): void

insertN

  • insertN(startIndex: number, x: number, yArray: number[], metadata?: T, onInsert?: () => void): void
  • summary

    Inserts a single X and set of Y-values at the start index

    remarks

    For best performance on drawing large datasets, use the insertRange method

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • startIndex: number

      the index to insert at

    • x: number

      the X value

    • yArray: number[]

      the Y values

    • Optional metadata: T

      The point metadata

    • Optional onInsert: () => void
        • (): void
        • Returns void

    Returns void

insertRange

  • summary

    Inserts a range of X,Y values at the startIndex

    remarks

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    Returns void

insertRangeN

  • insertRangeN(startIndex: number, xValues: NumberArray, yValuesArray: NumberArray[], metadata?: T[], onInsert?: () => void): void
  • summary

    Inserts a range of X,Y values at the startIndex

    remarks

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • startIndex: number

      the index to insert at

    • xValues: NumberArray

      the XValues

    • yValuesArray: NumberArray[]
    • Optional metadata: T[]

      The array of point metadata

    • Optional onInsert: () => void
        • (): void
        • Returns void

    Returns void

isUsedForYRange

  • isUsedForYRange(name: string): boolean
  • Get if a named yValues array should be included when calculating yRange

    Parameters

    • name: string

    Returns boolean

notifyDataChanged

  • notifyDataChanged(changeType: EDataChangeType, index: number, count: number, name?: string): void

removeAt

  • removeAt(index: number): void
  • Removes an X, and all associated y values at the specified index

    remarks

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • index: number

      the index to remove at

    Returns void

Protected removeMetadataAt

  • removeMetadataAt(index: number): void

Protected removeMetadataRange

  • removeMetadataRange(startIndex: number, count: number): void

removeRange

  • removeRange(startIndex: number, count: number): void
  • summary

    Removes a range of X, and all associated y values starting at the specified index

    remarks

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • startIndex: number

      the start index to remove at

    • count: number

      the number of points to remove

    Returns void

Protected reserve

  • reserve(size: number): void
  • Parameters

    • size: number

    Returns void

revertAnimationVectors

setFinalAnimationVectors

setInitialAnimationVectors

Protected setMetadata

  • setMetadata(value: T[]): void

Protected setMetadataAt

  • setMetadataAt(index: number, metadata: T): void

setMetadataGenerator

  • Sets a function that will be used to generate metadata for values when they are appended/inserted, if no explicit metadata is supplied.

    Parameters

    Returns void

setUsedForYRange

  • setUsedForYRange(name: string, isUsed: boolean): void
  • Set if a named yValues array should be included when calculating yRange

    Parameters

    • name: string

      Usually an EValueName

    • isUsed: boolean

    Returns void

Protected throwIfFifo

  • throwIfFifo(operation: string): void

toJSON

  • Convert the object to a definition that can be serialized to JSON, or used directly with the builder api

    Parameters

    • Default value excludeData: boolean = false

      if set true, data values will not be included in the json.

    Returns TDataSeriesDefinition

toPointSeries

update

  • Updates a single Y-value by X-index

    remarks

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • index: number

      the index to update

    • y: number

      The new Y value

    • Optional metadata: IPointMetadata

      The point metadata

    Returns void

updateAnimationProperties

  • updateAnimationProperties(progress: number, animation: SeriesAnimation): void

updateN

  • updateN(index: number, yArray: number[], metadata?: T, onUpdate?: () => void): void
  • Updates a single set of y values by X-index

    remarks

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • index: number

      the index to update

    • yArray: number[]

      The new Y values

    • Optional metadata: T

      The point metadata

    • Optional onUpdate: () => void
        • (): void
        • Returns void

    Returns void

updateXy

  • updateXy(index: number, x: number, y: number, metadata?: IPointMetadata): void
  • Updates a single X, Y-value by X-index. Might also need to set isSorted = false

    remarks

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • index: number

      The index to update

    • x: number

      The new X value

    • y: number

      The new Y value

    • Optional metadata: IPointMetadata

      The point metadata

    Returns void

updateXyN

  • updateXyN(index: number, x: number, yArray: number[], metadata?: T, onUpdate?: () => void): void
  • Updates a single X, and set of Y-values by X-index. Might also need to set isSorted = false

    remarks

    Any changes of the DataSeries will trigger a redraw on the parent SciChartSurface

    Parameters

    • index: number

      The index to update

    • x: number

      The new X value

    • yArray: number[]

      The new Y values

    • Optional metadata: T

      The point metadata

    • Optional onUpdate: () => void
        • (): void
        • Returns void

    Returns void

validateAnimationVectors

  • validateAnimationVectors(): void

Protected validateIndex

  • validateIndex(index: number, message?: string): void
  • Parameters

    • index: number
    • Optional message: string

    Returns void

Generated using TypeDoc