|
| 1 | +import React, { useEffect, useRef, memo } from 'react'; |
| 2 | + |
| 3 | +function MarketOverview() { |
| 4 | + const container = useRef(); |
| 5 | + |
| 6 | + useEffect(() => { |
| 7 | + if (container.current) { |
| 8 | + container.current.innerHTML = ''; // Clear any previous content |
| 9 | + |
| 10 | + const script = document.createElement('script'); |
| 11 | + script.src = 'https://s3.tradingview.com/external-embedding/embed-widget-market-overview.js'; |
| 12 | + script.type = 'text/javascript'; |
| 13 | + script.async = true; |
| 14 | + script.innerHTML = ` |
| 15 | + { |
| 16 | + "colorTheme": "dark", |
| 17 | + "dateRange": "12M", |
| 18 | + "showChart": true, |
| 19 | + "locale": "en", |
| 20 | + "largeChartUrl": "", |
| 21 | + "isTransparent": false, |
| 22 | + "showSymbolLogo": true, |
| 23 | + "showFloatingTooltip": false, |
| 24 | + "width": "400", |
| 25 | + "height": "520", |
| 26 | + "plotLineColorGrowing": "rgba(41, 98, 255, 1)", |
| 27 | + "plotLineColorFalling": "rgba(41, 98, 255, 1)", |
| 28 | + "gridLineColor": "rgba(42, 46, 57, 0)", |
| 29 | + "scaleFontColor": "rgba(219, 219, 219, 1)", |
| 30 | + "belowLineFillColorGrowing": "rgba(41, 98, 255, 0.12)", |
| 31 | + "belowLineFillColorFalling": "rgba(41, 98, 255, 0.12)", |
| 32 | + "belowLineFillColorGrowingBottom": "rgba(41, 98, 255, 0)", |
| 33 | + "belowLineFillColorFallingBottom": "rgba(41, 98, 255, 0)", |
| 34 | + "symbolActiveColor": "rgba(41, 98, 255, 0.12)", |
| 35 | + "tabs": [ |
| 36 | + { |
| 37 | + "title": "Indices", |
| 38 | + "symbols": [ |
| 39 | + { "s": "FOREXCOM:SPXUSD", "d": "S&P 500 Index" }, |
| 40 | + { "s": "FOREXCOM:NSXUSD", "d": "US 100 Cash CFD" }, |
| 41 | + { "s": "FOREXCOM:DJI", "d": "Dow Jones Industrial Average Index" }, |
| 42 | + { "s": "INDEX:NKY", "d": "Japan 225" }, |
| 43 | + { "s": "INDEX:DEU40", "d": "DAX Index" }, |
| 44 | + { "s": "FOREXCOM:UKXGBP", "d": "FTSE 100 Index" }, |
| 45 | + { "s": "INDEX:BTCUSD", "d": "BTC Index" }, |
| 46 | + { "s": "CRYPTOCAP:TOTAL2", "d": "CryptoCap" }, |
| 47 | + { "s": "SKILLING:US100", "d": "CFD 100" } |
| 48 | + ], |
| 49 | + "originalTitle": "Indices" |
| 50 | + }, |
| 51 | + { |
| 52 | + "title": "Forex", |
| 53 | + "symbols": [ |
| 54 | + { "s": "FX:EURUSD", "d": "EUR to USD" }, |
| 55 | + { "s": "FX:GBPUSD", "d": "GBP to USD" }, |
| 56 | + { "s": "FX:USDJPY", "d": "USD to JPY" }, |
| 57 | + { "s": "FX:USDCHF", "d": "USD to CHF" }, |
| 58 | + { "s": "FX:AUDUSD", "d": "AUD to USD" }, |
| 59 | + { "s": "FX:USDCAD", "d": "USD to CAD" }, |
| 60 | + { "s": "FX_IDC:USDINR", "d": "USDINR" }, |
| 61 | + { "s": "OANDA:NZDUSD", "d": "NZDUSD" }, |
| 62 | + { "s": "OANDA:EURAUD", "d": "EURAUD" } |
| 63 | + ], |
| 64 | + "originalTitle": "Forex" |
| 65 | + }, |
| 66 | + { |
| 67 | + "title": "Futures", |
| 68 | + "symbols": [ |
| 69 | + { "s": "BMFBOVESPA:ISP1!", "d": "S&P 500 Index Futures" }, |
| 70 | + { "s": "BMFBOVESPA:EUR1!", "d": "Euro Futures" }, |
| 71 | + { "s": "PYTH:WTI3!", "d": "WTI CRUDE OIL" }, |
| 72 | + { "s": "BMFBOVESPA:ETH1!", "d": "Hydrous ethanol" }, |
| 73 | + { "s": "BMFBOVESPA:CCM1!", "d": "Corn" } |
| 74 | + ], |
| 75 | + "originalTitle": "Futures" |
| 76 | + }, |
| 77 | + { |
| 78 | + "title": "Bonds", |
| 79 | + "symbols": [ |
| 80 | + { "s": "EUREX:FGBL1!", "d": "Euro Bund" }, |
| 81 | + { "s": "EUREX:FBTP1!", "d": "Euro BTP" }, |
| 82 | + { "s": "EUREX:FGBM1!", "d": "Euro BOBL" } |
| 83 | + ], |
| 84 | + "originalTitle": "Bonds" |
| 85 | + } |
| 86 | + ] |
| 87 | + }`; |
| 88 | + |
| 89 | + container.current.appendChild(script); |
| 90 | + } |
| 91 | + }, []); |
| 92 | + |
| 93 | + return ( |
| 94 | + <div |
| 95 | + className="tradingview-widget-container" |
| 96 | + ref={container} |
| 97 | + style={{ width: '400px', height: '550px' }} |
| 98 | + > |
| 99 | + <div className="tradingview-widget-container__widget"></div> |
| 100 | + </div> |
| 101 | + ); |
| 102 | +} |
| 103 | + |
| 104 | +export default memo(MarketOverview); |
0 commit comments