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.
2024const 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.
2350const 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.
16211640createSampledDataGenerator ( 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