Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Sample data for sparkline charts
+ const generateSparklineData = () => {
+ return Array.from({length: 20}, () => Math.random() * 100);
+ };
+
+ // Create sparkline charts
+ const drawSparkline = (elementId, data) => {
+ const canvas = document.createElement('canvas');
+ const ctx = canvas.getContext('2d');
+ const element = document.getElementById(elementId);
+
+ canvas.width = element.offsetWidth;
+ canvas.height = element.offsetHeight;
+ element.appendChild(canvas);
+
+ const points = data.map((value, index) => ({
+ x: (index / (data.length - 1)) * canvas.width,
+ y: canvas.height - ((value / 100) * canvas.height)
+ }));
+
+ ctx.strokeStyle = '#00b4d8';
+ ctx.lineWidth = 2;
+ ctx.beginPath();
+ points.forEach((point, index) => {
+ if (index === 0) {
+ ctx.moveTo(point.x, point.y);
+ } else {
+ ctx.lineTo(point.x, point.y);
+ }
+ });
+ ctx.stroke();
+ };
+
+ // Initialize charts
+ ['winRateChart', 'profitChart', 'tradesChart'].forEach(chartId => {
+ drawSparkline(chartId, generateSparklineData());
+ });
+
+ // Search functionality
+ const searchInput = document.getElementById('searchTrades');
+ searchInput.addEventListener('input', (e) => {
+ // Implement search logic here
+ console.log('Searching:', e.target.value);
+ });
+
+ // Add trade button
+ const addTradeBtn = document.getElementById('addTradeBtn');
+ addTradeBtn.addEventListener('click', () => {
+ // Implement add trade logic here
+ console.log('Add trade clicked');
+ });
+
+ // Responsive navigation
+ window.addEventListener('resize', () => {
+ // Redraw charts on window resize
+ ['winRateChart', 'profitChart', 'tradesChart'].forEach(chartId => {
+ const element = document.getElementById(chartId);
+ element.innerHTML = '';
+ drawSparkline(chartId, generateSparklineData());
+ });
+ });
+ });