Spaces:
Sleeping
Sleeping
File size: 7,042 Bytes
eecb251 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | import { useState, useEffect } from 'react';
import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, PieChart, Pie, Cell } from 'recharts';
const COLORS = ['#00f3ff', '#bc13fe']; // Cyan pour Gains, Magenta pour Pertes
export default function App() {
const [seuil, setSeuil] = useState(2.0);
const [data, setData] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
setLoading(true);
// Appel de l'API sur le même domaine (port 7860)
fetch(`/api/stats?seuil=${seuil}`)
.then(res => res.json())
.then(result => {
setData(result);
setLoading(false);
})
.catch(err => {
console.error("Erreur API:", err);
setLoading(false);
});
}, [seuil]);
if (loading || !data) {
return (
<div className="flex items-center justify-center h-screen text-slate-500 text-xl">
Chargement des données...
</div>
);
}
if (data.error) {
return <div className="flex items-center justify-center h-screen text-red-500">{data.error}</div>;
}
// Formatage des données pour Recharts
const chartData = data.historique.map((r, i) => ({ name: i, cote: r.cote }));
const pieData = [
{ name: `Gains (> ${seuil}x)`, value: data.distribution.gains },
{ name: `Pertes (<= ${seuil}x)`, value: data.distribution.pertes }
];
return (
<div className="min-h-screen p-6 bg-slate-100">
<div className="max-w-7xl mx-auto">
{/* Header */}
<div className="mb-8 text-center">
<h1 className="text-4xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-neon-cyan to-neon-magenta drop-shadow-neon-cyan">
AVIATOR ANALYTICS V3
</h1>
<p className="text-slate-500 mt-2">Analyse dynamique en temps réel</p>
</div>
{/* LE SUPER SLIDER DE SEUIL */}
<div className="glass-card p-6 mb-8 flex flex-col md:flex-row items-center justify-between gap-4">
<div className="w-full md:w-1/3">
<span className="text-sm font-bold text-slate-600 uppercase tracking-wider">Seuil d'analyse</span>
</div>
<div className="w-full md:w-2/3 flex items-center gap-4">
<span className="text-slate-400 text-sm">1.0x</span>
<input
type="range"
min="1.1"
max="10"
step="0.1"
value={seuil}
onChange={(e) => setSeuil(parseFloat(e.target.value))}
className="neon-slider w-full"
/>
<span className="text-slate-400 text-sm">10.0x</span>
</div>
<div className="text-3xl font-bold text-neon-cyan drop-shadow-[0_0_10px_rgba(0,243,255,0.7)]">
{seuil.toFixed(1)}x
</div>
</div>
{/* KPI Cards */}
<div className="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
<KpiCard title="Total Rounds" value={data.totalRounds} color="text-slate-800" />
<KpiCard title="Cote Moyenne" value={`${data.coteMoyenne}x`} color="text-neon-cyan" shadow="neon-cyan" />
<KpiCard title="Avantage Maison" value={`${data.avantageMaison}%`} color="text-neon-magenta" shadow="neon-magenta" isNegative={data.avantageMaison > 0} />
<KpiCard title="Max Streak (Gains)" value={`${data.streaks.maxGains} coups`} color="text-green-500" />
</div>
{/* Graphiques */}
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
{/* Courbe des cotes */}
<div className="glass-card p-6 lg:col-span-2">
<h3 className="text-lg font-bold text-slate-700 mb-4">Historique des Cotes (100 derniers)</h3>
<div className="h-64">
<ResponsiveContainer width="100%" height="100%">
<LineChart data={chartData}>
<XAxis dataKey="name" hide />
<YAxis domain={[0, 'auto']} />
<Tooltip
contentStyle={{ background: 'rgba(255,255,255,0.8)', backdropFilter: 'blur(5px)', border: 'none', borderRadius: '10px' }}
formatter={(value) => [`${value}x`, "Cote"]}
/>
<Line type="monotone" dataKey="cote" stroke="#00f3ff" strokeWidth={2} dot={false} activeDot={{r: 6, fill: '#bc13fe'}} />
</LineChart>
</ResponsiveContainer>
</div>
</div>
{/* Pie Chart Distribution */}
<div className="glass-card p-6 flex flex-col items-center justify-center">
<h3 className="text-lg font-bold text-slate-700 mb-4">Distribution</h3>
<div className="h-48 w-full">
<ResponsiveContainer width="100%" height="100%">
<PieChart>
<Pie data={pieData} cx="50%" cy="50%" innerRadius={40} outerRadius={70} paddingAngle={5} dataKey="value">
{pieData.map((entry, index) => (
<Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
))}
</Pie>
<Tooltip
contentStyle={{ background: 'rgba(255,255,255,0.8)', border: 'none', borderRadius: '10px' }}
formatter={(value, name) => [`${value} (${((value/data.totalRounds)*100).toFixed(1)}%)`, name]}
/>
</PieChart>
</ResponsiveContainer>
</div>
<div className="flex gap-6 mt-4 text-sm font-semibold">
<div className="flex items-center gap-2"><span className="w-3 h-3 rounded-full bg-neon-cyan"></span> Gains ({data.distribution.pourcentageGains}%)</div>
<div className="flex items-center gap-2"><span className="w-3 h-3 rounded-full bg-neon-magenta"></span> Pertes ({data.distribution.pourcentagePertes}%)</div>
</div>
</div>
</div>
</div>
{/* Styles CSS Injectés pour le Glassmorphism (pour éviter un fichier tailwind trop complexe pour l'instant) */}
<style jsx global>{`
.glass-card {
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.4);
border-radius: 1rem;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
transition: all 0.3s ease;
}
.glass-card:hover {
border-color: rgba(0, 243, 255, 0.3);
box-shadow: 0 8px 32px 0 rgba(0, 243, 255, 0.1);
}
`}</style>
</div>
);
}
// Composant Card réutilisable
const KpiCard = ({ title, value, color, shadow, isNegative }) => (
<div className={`glass-card p-6 text-center ${shadow ? `shadow-${shadow}` : ''}`}>
<p className="text-sm font-medium text-slate-500 mb-1">{title}</p>
<p className={`text-3xl font-bold ${color} ${isNegative ? 'drop-shadow-[0_0_8px_rgba(188,19,254,0.6)]' : ''}`}>
{value}
</p>
</div>
); |