@@ -12,10 +12,10 @@ const {
1212 emptyFill,
1313 emptyLine,
1414 AxisScrollStrategies,
15- LegendBoxBuilders,
1615 synchronizeAxisIntervals,
1716 regularColorSteps,
1817 Themes,
18+ LegendPosition,
1919} = lcjs
2020
2121const { createSpectrumDataGenerator } = require ( '@lightningchart/xydata' )
@@ -43,6 +43,9 @@ const chartSpectrogram = dashboard
4343 . createChartXY ( {
4444 columnIndex : 0 ,
4545 rowIndex : 0 ,
46+ legend : {
47+ position : LegendPosition . TopCenter
48+ } ,
4649 } )
4750 . setTitle ( '2D Spectrogram with X & Y projection on mouse hover' )
4851
@@ -64,23 +67,15 @@ const seriesSpectrogram = chartSpectrogram
6467 } ) ,
6568 )
6669
67- const legend = chartSpectrogram
68- . addLegendBox ( LegendBoxBuilders . HorizontalLegendBox )
69- // Dispose example UI elements automatically if they take too much space. This is to avoid bad UI on mobile / etc. devices.
70- . setAutoDispose ( {
71- type : 'max-width' ,
72- maxWidth : 0.8 ,
73- } )
74- . add ( chartSpectrogram )
75-
7670const chartProjectionY = dashboard
7771 . createChartXY ( {
7872 columnIndex : 1 ,
7973 rowIndex : 0 ,
74+ legend : { visible : false } ,
8075 } )
8176 . setTitleFillStyle ( emptyFill )
8277 // NOTE: Hardcoded alignment with Spectrogram chart.
83- . setPadding ( { top : 44 } )
78+ . setPadding ( { top : 110 } )
8479 . setUserInteractions ( undefined )
8580
8681chartProjectionY . getDefaultAxisY ( ) . setScrollStrategy ( undefined )
@@ -90,17 +85,13 @@ synchronizeAxisIntervals(chartSpectrogram.getDefaultAxisY(), chartProjectionY.ge
9085
9186chartProjectionY . getDefaultAxisX ( ) . setScrollStrategy ( AxisScrollStrategies . expansion ) . setInterval ( { start : 0 , end : 1 , stopAxisAfter : false } )
9287
93- const seriesProjectionY = chartProjectionY
94- . addPointLineAreaSeries ( {
95- dataPattern : 'ProgressiveY' ,
96- } )
97- . setName ( 'Projection (Y)' )
98- . setAreaFillStyle ( emptyFill )
88+ const seriesProjectionY = chartProjectionY . addLineSeries ( { } ) . setName ( 'Projection (Y)' )
9989
10090const chartProjectionX = dashboard
10191 . createChartXY ( {
10292 columnIndex : 0 ,
10393 rowIndex : 1 ,
94+ legend : { visible : false } ,
10495 } )
10596 . setTitleFillStyle ( emptyFill )
10697 . setUserInteractions ( undefined )
@@ -110,12 +101,7 @@ chartProjectionX.getDefaultAxisX().setScrollStrategy(undefined)
110101synchronizeAxisIntervals ( chartSpectrogram . getDefaultAxisX ( ) , chartProjectionX . getDefaultAxisX ( ) )
111102
112103chartProjectionX . getDefaultAxisY ( ) . setScrollStrategy ( AxisScrollStrategies . expansion ) . setInterval ( { start : 0 , end : 1 , stopAxisAfter : false } )
113- const seriesProjectionX = chartProjectionX
114- . addPointLineAreaSeries ( {
115- dataPattern : 'ProgressiveX' ,
116- } )
117- . setName ( 'Projection (X)' )
118- . setAreaFillStyle ( emptyFill )
104+ const seriesProjectionX = chartProjectionX . addLineSeries ( { } ) . setName ( 'Projection (X)' )
119105
120106// Align charts nicely.
121107chartSpectrogram . getDefaultAxisY ( ) . setThickness ( 50 )
@@ -157,12 +143,12 @@ createSpectrumDataGenerator()
157143 // Update projection series data.
158144 seriesProjectionY . clear ( )
159145 if ( projectionY ) {
160- seriesProjectionY . add ( projectionY )
146+ seriesProjectionY . appendJSON ( projectionY )
161147 }
162148
163149 seriesProjectionX . clear ( )
164150 if ( projectionX ) {
165- seriesProjectionX . add ( projectionX )
151+ seriesProjectionX . appendJSON ( projectionX )
166152 }
167153 }
168154
0 commit comments