Skip to main content
Version: 5.2.1

Custom sample properties

The new XY series supports storage of only specific sample properties. These are:

  • X
  • Y
  • Lookup value (for dynamic coloring according to lookup table)
  • Color (for individual coloring per sample)
  • ID (for data edit and connecting to custom sample properties, read more below)

In some use cases, your samples can have many more properties than these. Often extra information that may be displayed in a data cursor, or utilized when drilling down to a data point.

This use case is described as "custom sample properties".


As mentioned before, you can't store any other properties than the five mentioned above within the charts. However, you can assign numeric ID properties to samples, and use them to backwards connect samples to the original full data in your application - something like this:

const data = new Array(10).fill(0).map((_, i) => ({
x: i,
y: Math.random(),
id: i,
propertyA: Math.random(),
propertyB: Math.random(),
}))

const chart = lightningChart().ChartXY()
const series = chart.addPointLineAreaSeries({ ids: true })
series.getDataSet().appendJSON(data, { x: 'x', y: 'y', id: 'id' })

series.setCursorResultTableFormatter((builder, series, sample) => {
const origSample = data[sample.id as number]
builder.addRow('Property A', '', origSample.propertyA.toFixed(3))
builder.addRow('Property B', '', origSample.propertyB.toFixed(3))
return builder
})

In this example, the original data has properties propertyA and propertyB, which should be displayed in the cursor. They are not used as X or Y coordinates.

This is accomplished by using the data point index as id and finding the original data point in the result table formatter.