Delete components/Chart.tsx
Browse files- components/Chart.tsx +0 -57
components/Chart.tsx
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
"use client"
|
| 2 |
-
import { useEffect, useRef, useState } from 'react'
|
| 3 |
-
import Plot from 'react-plotly.js'
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
interface ChartProps {
|
| 7 |
-
onRoboClick: () => void
|
| 8 |
-
}
|
| 9 |
-
|
| 10 |
-
export const Chart: React.FC<ChartProps> = ({ onRoboClick }) => {
|
| 11 |
-
const [data, setData] = useState<any[]>([])
|
| 12 |
-
|
| 13 |
-
useEffect(() => {
|
| 14 |
-
const fetchData = async () => {
|
| 15 |
-
const response = await fetch('http://localhost:5000/fetch_candles')
|
| 16 |
-
const candles = await response.json()
|
| 17 |
-
|
| 18 |
-
setData([{
|
| 19 |
-
type: 'candlestick',
|
| 20 |
-
x: candles.map((c: any) => new Date(c.time)),
|
| 21 |
-
open: candles.map((c: any) => c.open),
|
| 22 |
-
high: candles.map((c: any) => c.high),
|
| 23 |
-
low: candles.map((c: any) => c.low),
|
| 24 |
-
close: candles.map((c: any) => c.close),
|
| 25 |
-
increasing: {line: {color: '#4CAF50'}},
|
| 26 |
-
decreasing: {line: {color: '#FF5252'}}
|
| 27 |
-
}])
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
fetchData()
|
| 31 |
-
}, [])
|
| 32 |
-
|
| 33 |
-
return (
|
| 34 |
-
<div className="relative">
|
| 35 |
-
<button
|
| 36 |
-
onClick={onRoboClick}
|
| 37 |
-
className="absolute top-2 left-2 text-2xl cursor-pointer z-10"
|
| 38 |
-
>
|
| 39 |
-
🤖
|
| 40 |
-
</button>
|
| 41 |
-
<Plot
|
| 42 |
-
data={data}
|
| 43 |
-
layout={{
|
| 44 |
-
width: 1000,
|
| 45 |
-
height: 500,
|
| 46 |
-
paper_bgcolor: '#1A1A1A',
|
| 47 |
-
plot_bgcolor: '#1A1A1A',
|
| 48 |
-
font: { color: '#d1d4dc' },
|
| 49 |
-
xaxis: { gridcolor: '#2a2e39' },
|
| 50 |
-
yaxis: { gridcolor: '#2a2e39' },
|
| 51 |
-
margin: { l: 50, r: 50, t: 30, b: 30 }
|
| 52 |
-
}}
|
| 53 |
-
config={{ responsive: true }}
|
| 54 |
-
/>
|
| 55 |
-
</div>
|
| 56 |
-
)
|
| 57 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|