This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return ( | |
| <div className="App"> | |
| <header className="App-header"> | |
| <NewsTicker /> | |
| <h1>Crypto Dashboard</h1> | |
| {loading ? ( | |
| <p>Loading...</p> | |
| ) : ( | |
| <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', width: '100%', height: '100vh' }}> | |
| <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', width: '100%', height: '100%' }}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| font-family: Arial, sans-serif; | |
| } | |
| .App { | |
| text-align: center; | |
| } | |
| .App-header { | |
| background-color: #ffffff; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect, useState } from 'react'; | |
| import axios from 'axios'; | |
| import Marquee from 'react-marquee-slider'; | |
| function NewsTicker() { | |
| const [news, setNews] = useState([]); | |
| const [isLoading, setIsLoading] = useState(true); | |
| const [error, setError] = useState(null); | |
| useEffect(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const handleCoinSelect = (id) => { | |
| setLoading(true); | |
| const selected = coins.find(coin => coin.id === id); | |
| setSelectedCoin(selected); | |
| // Fetch historical data for the selected date range | |
| const promises = []; | |
| const date = new Date(startDate); | |
| while (date <= endDate) { | |
| const formattedDate = `${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042']; // add more colors if you have more coins | |
| useEffect(() => { | |
| axios.get(`https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=${holdings.map(holding => holding.id).join(',')}`, { | |
| headers: { | |
| 'X-CoinAPI-Key': api_key | |
| } | |
| }) | |
| .then(response => { | |
| const updatedHoldings = holdings.map(holding => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function App() { | |
| const [coins, setCoins] = useState([]); | |
| const [selectedCoin, setSelectedCoin] = useState(null); | |
| const [history, setHistory] = useState([]); | |
| const [loading, setLoading] = useState(true); | |
| const [startDate, setStartDate] = useState(new Date()); | |
| const [endDate, setEndDate] = useState(new Date()); | |
| const api_key = 'YOUR_API_KEY'; // replace this with your own API key | |
| const holdings = useMemo(() => holdingsData, []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function CoinDetails({ coin, history }) { | |
| // Prepare the data for the line chart | |
| const chartData = history.map(dataPoint => ({ date: new Date(dataPoint[0]).toDateString(), price: dataPoint[1] })); | |
| const priceChangeColor = coin.price_change_24h < 0 ? 'red' : 'green'; | |
| return ( | |
| <div className="coin-details"> | |
| <h2>{coin.name} ({coin.symbol.toUpperCase()})</h2> | |
| <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', width: '100%' }}> | |
| <span style={{ color: priceChangeColor, fontSize: '0.8em' }}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useEffect, useMemo } from 'react'; | |
| import axios from 'axios'; | |
| import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, PieChart, Pie, Cell, ResponsiveContainer } from 'recharts'; | |
| import DatePicker from 'react-datepicker'; | |
| import NewsTicker from './components/News'; // Import the News components | |
| import 'react-datepicker/dist/react-datepicker.css'; | |
| import './App.css'; // Import the CSS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| font-family: Arial, sans-serif; | |
| } | |
| .App { | |
| text-align: center; | |
| } | |
| .App-header { | |
| background-color: #ffffff; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useEffect, useMemo } from 'react'; | |
| import axios from 'axios'; | |
| import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, PieChart, Pie, Cell, ResponsiveContainer } from 'recharts'; | |
| import DatePicker from 'react-datepicker'; | |
| import 'react-datepicker/dist/react-datepicker.css'; | |
| import './App.css'; // Import the CSS | |
| import NewsTicker from './components/News'; // Import the News components | |
| function CoinDetails({ coin, history }) { | |
| // Prepare the data for the line chart |