1
- const lcjs = require ( '@arction /lcjs' )
1
+ const lcjs = require ( '@lightningchart /lcjs' )
2
2
const { AxisTickStrategies, emptyTick, FormattingFunctions, SolidLine, emptyFill, SolidFill, lightningChart, Themes } = lcjs
3
3
4
4
const highlightIntensity = 0.2 // [0, 1]
@@ -70,6 +70,7 @@ const setDrillDown = (() => {
70
70
theme : Themes [ new URLSearchParams ( window . location . search ) . get ( 'theme' ) || 'darkGold' ] || undefined ,
71
71
} )
72
72
. setTitle ( name )
73
+ . setCursor ( ( cursor ) => cursor . setTickMarkerXVisible ( false ) )
73
74
chart
74
75
. getDefaultAxisX ( )
75
76
. setTickStrategy ( AxisTickStrategies . DateTime )
@@ -78,68 +79,47 @@ const setDrillDown = (() => {
78
79
endMax : state . dataMax ,
79
80
} ) )
80
81
chart . getDefaultAxisY ( ) . dispose ( )
81
- const axisRate = chart . addAxisY ( { iStack : 3 } ) . setTitle ( `Rate $` ) . setMargins ( 10 , 0 )
82
+ const axisRate = chart . addAxisY ( { iStack : 3 } ) . setTitle ( `Rate` ) . setUnits ( '$' ) . setMargins ( 10 , 0 )
82
83
const seriesRate = chart
83
84
. addPointLineAreaSeries ( { dataPattern : 'ProgressiveX' , yAxis : axisRate } )
84
85
. setAreaFillStyle ( emptyFill )
85
- . setName ( `${ name } Rate $` )
86
- . appendJSON ( coinData . map ( ( p ) => ( { x : p . date , y : p . rate } ) ) )
87
- . setCursorResultTableFormatter ( ( builder , series , dataPoint ) =>
88
- builder
89
- . addRow ( series . getName ( ) )
90
- . addRow ( timeAxis . formatValue ( dataPoint . x ) )
91
- . addRow ( `$${ series . axisY . formatValue ( dataPoint . y ) } ` ) ,
92
- )
86
+ . setName ( `${ name } Rate` )
87
+ . appendJSON ( coinData , { x : 'date' , y : 'rate' } )
93
88
94
89
const axisVolume = chart
95
90
. addAxisY ( { iStack : 2 } )
96
- . setTitle ( `Volume $` )
91
+ . setTitle ( `Volume` )
92
+ . setUnits ( '$' )
97
93
. setMargins ( 10 , 10 )
98
94
. setTickStrategy ( AxisTickStrategies . Numeric , ( ticks ) => ticks . setFormattingFunction ( FormattingFunctions . NumericUnits ) )
99
95
const seriesVolume = chart
100
- . addAreaSeries ( { yAxis : axisVolume } )
101
- . setName ( `${ name } Volume $` )
102
- . add ( coinData . map ( ( p ) => ( { x : p . date , y : p . volume } ) ) )
103
- . setCursorResultTableFormatter ( ( builder , series , x , high , low ) =>
104
- builder
105
- . addRow ( series . getName ( ) )
106
- . addRow ( timeAxis . formatValue ( x ) )
107
- . addRow ( `$${ ( high / 10 ** 9 ) . toFixed ( 3 ) } B` ) ,
108
- )
96
+ . addPointLineAreaSeries ( { dataPattern : 'ProgressiveX' , yAxis : axisVolume } )
97
+ . setName ( `${ name } Volume` )
98
+ . appendJSON ( coinData , { x : 'date' , y : 'volume' } )
109
99
110
100
const axisLiquidity = chart
111
101
. addAxisY ( { iStack : 1 } )
112
- . setTitle ( `Liquidity $` )
102
+ . setTitle ( `Liquidity` )
103
+ . setUnits ( '$' )
113
104
. setMargins ( 10 , 10 )
114
105
. setTickStrategy ( AxisTickStrategies . Numeric , ( ticks ) => ticks . setFormattingFunction ( FormattingFunctions . NumericUnits ) )
115
106
const seriesLiquidity = chart
116
107
. addPointLineAreaSeries ( { dataPattern : 'ProgressiveX' , yAxis : axisLiquidity } )
117
108
. setAreaFillStyle ( emptyFill )
118
- . setName ( `${ name } Liquidity $` )
119
- . add ( coinData . map ( ( p ) => ( { x : p . date , y : p . liquidity } ) ) )
120
- . setCursorResultTableFormatter ( ( builder , series , dataPoint ) =>
121
- builder
122
- . addRow ( series . getName ( ) )
123
- . addRow ( timeAxis . formatValue ( dataPoint . x ) )
124
- . addRow ( `$${ series . axisY . formatValue ( dataPoint . y ) } ` ) ,
125
- )
109
+ . setName ( `${ name } Liquidity` )
110
+ . appendJSON ( coinData , { x : 'date' , y : 'liquidity' } )
126
111
127
112
const axisCap = chart
128
113
. addAxisY ( { iStack : 0 } )
129
- . setTitle ( `Market Cap $` )
114
+ . setTitle ( `Market Cap` )
115
+ . setUnits ( '$' )
130
116
. setMargins ( 0 , 10 )
131
117
. setTickStrategy ( AxisTickStrategies . Numeric , ( ticks ) => ticks . setFormattingFunction ( FormattingFunctions . NumericUnits ) )
132
118
const seriesCap = chart
133
119
. addPointLineAreaSeries ( { dataPattern : 'ProgressiveX' , yAxis : axisCap } )
134
120
. setAreaFillStyle ( emptyFill )
135
- . setName ( `${ name } Market Cap $` )
136
- . add ( coinData . map ( ( p ) => ( { x : p . date , y : p . cap } ) ) )
137
- . setCursorResultTableFormatter ( ( builder , series , dataPoint ) =>
138
- builder
139
- . addRow ( series . getName ( ) )
140
- . addRow ( timeAxis . formatValue ( dataPoint . x ) )
141
- . addRow ( `$${ series . axisY . formatValue ( dataPoint . y ) } ` ) ,
142
- )
121
+ . setName ( `${ name } Market Cap` )
122
+ . appendJSON ( coinData , { x : 'date' , y : 'cap' } )
143
123
144
124
chart . forEachAxis ( ( axis ) => axis . setAnimationScroll ( false ) )
145
125
const timeAxis = chart . getDefaultAxisX ( )
0 commit comments