Skip to content

Commit c1c9958

Browse files
committed
Update example
1 parent e13e300 commit c1c9958

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ The demo can be used as an example or a seed project. Local execution requires t
1717

1818
### Description
1919

20-
This example shows how to display a generated ECG-signal by using a Line Series in a XY Chart.
20+
This example shows a simulated ECG-signal by using a Line Series in a XY Chart.
21+
22+
The simulated signal pushes 960 points per second to the chart.
2123

2224
### API links
2325

src/index.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const {
99
lightningChart,
1010
DataPatterns,
1111
AxisScrollStrategies,
12+
SolidLine,
13+
SolidFill,
14+
ColorHEX,
15+
AutoCursorModes
1216
} = lcjs
1317

1418
// Import data-generators from 'xydata'-library.
@@ -19,6 +23,29 @@ const {
1923
// Create a XY Chart.
2024
const chart = lightningChart().ChartXY({}).setTitle('ECG')
2125

26+
// Add line series to visualize the data received
27+
const series = chart.addLineSeries({ dataPattern: DataPatterns.horizontalProgressive })
28+
// Style the series
29+
series
30+
.setStrokeStyle( new SolidLine({
31+
thickness: 2,
32+
fillStyle: new SolidFill({ color: ColorHEX( '#5aafc7' ) })
33+
}))
34+
.setMouseInteractions(false)
35+
36+
chart.setAutoCursorMode( AutoCursorModes.disabled )
37+
38+
// Setup view nicely.
39+
chart.getDefaultAxisY()
40+
.setTitle('mV')
41+
.setInterval(-1600, 1000)
42+
.setScrollStrategy(AxisScrollStrategies.expansion)
43+
44+
chart.getDefaultAxisX()
45+
.setTitle('milliseconds')
46+
.setInterval(0, 2500)
47+
.setScrollStrategy(AxisScrollStrategies.progressive)
48+
2249
// Points that are used to generate a continuous stream of data.
2350
const point = [
2451
{ x: 2, y: 81 },
@@ -1609,14 +1636,6 @@ const point = [
16091636
{ x: 1587, y: 82 }
16101637

16111638
]
1612-
// Add line series to visualize the data received
1613-
const series = chart.addLineSeries({ dataPattern: DataPatterns.horizontalProgressive })
1614-
1615-
// Customize how the data will be shown at cursor for the line series.
1616-
series.setResultTableFormatter((tableBuilder, series, x, y) => tableBuilder
1617-
.addRow('milliseconds', x.toFixed(1))
1618-
.addRow('mV', y.toFixed(0))
1619-
)
16201639
// Create a data generator to supply a continuous stream of data.
16211640
createSampledDataGenerator(point, 1, 10)
16221641
.setSamplingFrequency(1)
@@ -1627,16 +1646,6 @@ createSampledDataGenerator(point, 1, 10)
16271646
.setStreamRepeat(true)
16281647
.toStream()
16291648
.forEach(point => {
1649+
// Push the created points to the series.
16301650
series.add({ x: point.timestamp, y: point.data.y })
16311651
})
1632-
1633-
// Setup view nicely.
1634-
chart.getDefaultAxisY()
1635-
.setTitle('mV')
1636-
.setInterval(-1600, 1000)
1637-
.setScrollStrategy(AxisScrollStrategies.expansion)
1638-
1639-
chart.getDefaultAxisX()
1640-
.setTitle('milliseconds')
1641-
.setInterval(0, 2500)
1642-
.setScrollStrategy(AxisScrollStrategies.progressive)

0 commit comments

Comments
 (0)