This is a standalone web application that visualizes cryptocurrency market cap data using Chart.js. The application makes direct API calls to the CryptoCompare API and uses localStorage for caching.
- Visualizes market cap data for multiple cryptocurrencies (ADA, ETH, BNB, TON, SOL)
- Animates changes in market cap over time
- Caches API responses in localStorage to reduce API calls
- Works completely in the browser without requiring a backend server
- Simply open the
index.htmlfile in your web browser. - The application will load and start fetching data from the CryptoCompare API.
- Once data is loaded, the pie chart will be displayed and the animation will start.
For better performance and to avoid potential CORS issues, you can use any local web server of your choice to serve the HTML file.
- Direct API Calls: The application makes direct calls to the CryptoCompare API to fetch historical price data.
- Data Processing: The raw API data is processed to calculate market caps based on coin supply.
- localStorage Caching: API responses are cached in localStorage to reduce API calls and improve performance.
- Visualization: Chart.js is used to create an animated pie chart showing the relative market caps of different cryptocurrencies.
- Data is cached in localStorage for 1 hour.
- A "Clear Cache" button is provided to manually clear the cache if needed.
- If localStorage quota is exceeded, the oldest cache entries will be automatically removed.
The application uses the following CryptoCompare API endpoint:
https://min-api.cryptocompare.com/data/v2/histoday
fsym: From Symbol (the cryptocurrency you want data for)tsym: To Symbol (the currency to display values in)limit: Number of data points to returnaggregate: Data aggregation in days (1 = daily data)
The application uses a unified configuration object for cryptocurrencies that includes both supply data and brand colors:
const coins = {
'ADA': {
color: '#0033ad', // Cardano blue
supply: 45000000000
},
'ETH': {
color: '#3c3c3d', // Ethereum dark gray
supply: 120000000
},
'BNB': {
color: '#f3ba2f', // Binance yellow
supply: 166801148
},
'TON': {
color: '#0088CC', // TonCoin blue
supply: 5000000000
},
'SOL': {
color: '#14f195', // Solana green
supply: 555000000
},
'USDT': {
color: '#26a17b', // Tether green
supply: 83000000000
},
'BTC': {
color: '#f7931a', // Bitcoin orange
supply: 21000000
}
};Market cap is calculated by multiplying the price by the total supply of each cryptocurrency.
This application was refactored from a previous implementation that used a Python/Flask backend. The current version:
- Works completely in the browser without any backend dependencies
- Makes direct API calls to CryptoCompare
- Uses localStorage for efficient client-side caching
- Includes a "Clear Cache" button for user convenience
This application should work in all modern browsers that support:
- ES6+ JavaScript
- localStorage API
- Fetch API
- Chart.js