@@ -109,7 +109,7 @@ const StockChart: React.FC<StockChartProps> = ({ symbol, interval, range }) => {
109
109
} ,
110
110
timeScale : {
111
111
timeVisible : true ,
112
- rightOffset : 5 ,
112
+ rightOffset : 10 ,
113
113
minBarSpacing : 3 ,
114
114
} ,
115
115
width : chartContainerRef . current . clientWidth ,
@@ -124,13 +124,14 @@ const StockChart: React.FC<StockChartProps> = ({ symbol, interval, range }) => {
124
124
125
125
chartRef . current = createChart ( chartContainerRef . current , chartOptions )
126
126
127
- // Candlestick
127
+ // Candlestick series on main pane
128
128
candlestickSeriesRef . current = chartRef . current . addBarSeries ( {
129
129
upColor : '#089981' ,
130
130
downColor : '#f23645' ,
131
131
} )
132
132
candlestickSeriesRef . current . setData ( data )
133
- // 10-period Moving Average
133
+
134
+ // 20-period Moving Average on main pane
134
135
const maData = calculateMovingAverage ( data , maLength )
135
136
maSeriesRef . current = chartRef . current . addLineSeries ( {
136
137
color : '#eab308' , // yellow
@@ -139,6 +140,30 @@ const StockChart: React.FC<StockChartProps> = ({ symbol, interval, range }) => {
139
140
} )
140
141
maSeriesRef . current . setData ( maData )
141
142
143
+ // Volume series on separate pane at bottom
144
+ volumeSeriesRef . current = chartRef . current . addHistogramSeries ( {
145
+ color : theme === 'dark' ? '#4B5563' : '#9CA3AF' ,
146
+ priceFormat : {
147
+ type : 'volume' ,
148
+ } ,
149
+ priceScaleId : 'volume' ,
150
+ scaleMargins : {
151
+ top : 0.8 ,
152
+ bottom : 0 ,
153
+ } ,
154
+ } )
155
+
156
+ // Prepare volume data with color based on price movement
157
+ const volumeData = data . map ( ( item , index ) => {
158
+ const isUp = index > 0 ? item . close >= data [ index - 1 ] . close : true
159
+ return {
160
+ time : item . time ,
161
+ value : item . volume ,
162
+ color : isUp ? '#089981' : '#f23645'
163
+ }
164
+ } )
165
+ volumeSeriesRef . current . setData ( volumeData )
166
+
142
167
chartRef . current . timeScale ( ) . fitContent ( )
143
168
144
169
if ( data . length > 0 ) {
@@ -287,7 +312,7 @@ const StockCarousel: React.FC<StockCarouselProps> = ({
287
312
{ /* Single row layout for all controls */ }
288
313
< div className = "bg-background border-muted-foreground/20" >
289
314
< div className = "flex items-center justify-between gap-4" >
290
- { /* Left side - Theme toggle and fullscreen */ }
315
+ { /* Left side - Theme toggle and fullscreen (hide fullscreen on small screens) */ }
291
316
< div className = "flex items-center gap-2" >
292
317
< Button
293
318
variant = "outline"
@@ -301,9 +326,9 @@ const StockCarousel: React.FC<StockCarouselProps> = ({
301
326
</ div >
302
327
303
328
{ /* Center - Category selector and interval buttons */ }
304
- < div className = "flex items-center gap-2 " >
329
+ < div className = "flex items-center gap-4 " >
305
330
< select
306
- className = "border border-muted-foreground/20 rounded px-1 py-1 text-xs bg-background"
331
+ className = "border border-muted-foreground/20 rounded px-2 py-1 text-xs bg-background"
307
332
value = { currentCategoryIndex }
308
333
onChange = { ( e ) => handleCategoryChange ( Number ( e . target . value ) ) }
309
334
>
0 commit comments