Derived Data Properties - Editor

This is an example of a chart that tracks daily system capacity by comparing expected request volumes against the actual number of requests processed.

LightningChart DataSet class supports defining custom derivation rules, meaning data values can be derived from other properties' values. In this example, the dataset contains the base 'actual' and 'predictions' values. The median, prediction interval and SMA values are derived from those properties.

With Simple Moving Average (SMA), you can use built-in derivation implementation. You only need to feed in data values for x and y -> sma is automatically calculated. You can also specify any custom callback to do this kind of calculations.

const dataSet = new DataSet({
    schema: {
        x: { pattern: 'progressive' },
        y: { pattern: null },
        sma: { pattern: null, derived: builtInDataDerivations.SMA({ source: 'y', window: 100 }) },
        example: {
            pattern: null,
            derived: (info) => {
                // other properties' values can be referenced through `info`
                return new Array(info.newCount).fill(0).map(Math.random)
            },
        },
    },
})