Component overview
TheAreaChartFillByValue component in src/components/cryptoGrafics.jsx handles both data fetching and rendering. It is used in two contexts:
Standalone charts page
Rendered at
/grafics. The user can freely switch between Bitcoin, Ethereum, Tether, BNB, and Solana using the asset selector buttons.Favorites page
Rendered once per favorited coin with
cryptoId locked to that coin. The asset selector buttons are hidden when cryptoId is provided as a prop.Props
CoinGecko coin identifier to pin the chart to a specific asset (e.g.
"bitcoin"). When omitted, the user can pick the asset from the selector buttons. Defaults to "bitcoin" when not supplied.Selectable assets
WhencryptoId is not provided the following assets are available in the selector:
| ID | Display name |
|---|---|
bitcoin | Bitcoin |
ethereum | Ethereum |
tether | Tether |
binancecoin | BNB |
solana | Solana |
Time windows
Four time-range buttons are always visible regardless of the asset selection:| Button | days value | Label format |
|---|---|---|
| 24H | 1 | Hour (2-digit) |
| 7D | 7 | Month + day (short) |
| 30D | 30 | Month + day (short) |
| 1Y | 365 | Month + day (short) |
Data loading
Chart data is fetched viakeepHistory(cryptoId, days) whenever either activeCrypto or days changes:
cryptoGrafics.jsx
keepHistory calls the CoinGecko market chart endpoint:
(cryptoId, days) combination is cached independently in localStorage under the key history_{cryptoId}_{days} for 5 minutes.
Chart rendering
The chart is built with the Recharts library usingAreaChart with a ResponsiveContainer:
cryptoGrafics.jsx
Gradient component, which renders an SVG <linearGradient id="splitColor">: Tailwind’s #10b981 (green-500) at 80% opacity at the top, fading to 10% opacity at the bottom. The gradient is referenced via fill="url(#splitColor)" on the <Area> element.
The chart container is responsive and adjusts its height based on the viewport: 300 px on mobile, 360 px on small screens, and 420 px on medium and larger screens.