tmmdev2 commited on
Commit
14be6f3
·
verified ·
1 Parent(s): e6cbe42

Delete src/components/Chart.tsx

Browse files
Files changed (1) hide show
  1. src/components/Chart.tsx +0 -55
src/components/Chart.tsx DELETED
@@ -1,55 +0,0 @@
1
- "use client"
2
- import { useEffect, useRef } from 'react'
3
- import * as LightweightCharts from 'lightweight-charts'
4
-
5
- interface ChartProps {
6
- onRoboClick: () => void
7
- }
8
-
9
- export const Chart: React.FC<ChartProps> = ({ onRoboClick }) => {
10
- const chartContainerRef = useRef<HTMLDivElement>(null)
11
- const chartRef = useRef<any>(null)
12
-
13
- useEffect(() => {
14
- if (!chartContainerRef.current) return
15
-
16
- chartRef.current = LightweightCharts.createChart(chartContainerRef.current, {
17
- width: chartContainerRef.current.clientWidth,
18
- height: 500,
19
- layout: {
20
- background: { color: '#1A1A1A' },
21
- textColor: '#d1d4dc',
22
- }
23
- })
24
-
25
- const series = chartRef.current.addCandlestickSeries()
26
-
27
- const fetchData = async () => {
28
- const response = await fetch('http://localhost:5000/fetch_candles')
29
- const data = await response.json()
30
- series.setData(data)
31
- }
32
-
33
- fetchData()
34
-
35
- const roboIcon = document.createElement('div')
36
- roboIcon.innerHTML = '🤖'
37
- roboIcon.style.position = 'absolute'
38
- roboIcon.style.top = '10px'
39
- roboIcon.style.left = '10px'
40
- roboIcon.style.fontSize = '24px'
41
- roboIcon.style.cursor = 'pointer'
42
- roboIcon.onclick = onRoboClick
43
- chartContainerRef.current.appendChild(roboIcon)
44
-
45
- return () => {
46
- if (chartRef.current) {
47
- chartRef.current.remove()
48
- }
49
- }
50
- }, [onRoboClick])
51
-
52
- return (
53
- <div ref={chartContainerRef} className="w-full h-[500px] relative" />
54
- )
55
- }