import React from 'react'; import { View } from 'react-native'; import { Text } from '../ui/Text'; import { useProgressStore } from '../../store/progressStore'; import { useThemeColors } from '~/utils/themeUtils'; interface ProgressChartProps { type: 'accuracy' | 'cards' | 'time'; period: 'week' | 'month' | 'year'; } export const ProgressChart: React.FC = ({ type, period }) => { const { getChartData } = useProgressStore(); const data = getChartData(type); const colors = useThemeColors(); if (data.length === 0) { return ( Keine Daten verfügbar ); } const getYLabel = () => { switch (type) { case 'accuracy': return 'Genauigkeit (%)'; case 'cards': return 'Karten'; case 'time': return 'Minuten'; default: return ''; } }; const getColor = () => { switch (type) { case 'accuracy': return '#10B981'; // green case 'cards': return '#3B82F6'; // blue case 'time': return '#F59E0B'; // amber default: return '#6B7280'; } }; // Get max value for scaling const maxValue = Math.max(...data.map((d) => d.value)); const minValue = Math.min(...data.map((d) => d.value)); // Simple bar chart implementation return ( {getYLabel()} Ø {Math.round(data.reduce((sum, d) => sum + d.value, 0) / data.length)} {type === 'accuracy' ? '%' : ''} {/* Simple Bar Chart */} {data.slice(-7).map((item, index) => { const height = maxValue > 0 ? (item.value / maxValue) * 100 : 0; return ( {item.label} ); })} {/* Summary Stats */} Min {Math.min(...data.map((d) => d.value))} {type === 'accuracy' ? '%' : ''} Max {Math.max(...data.map((d) => d.value))} {type === 'accuracy' ? '%' : ''} Gesamt {type === 'accuracy' ? `${Math.round(data.reduce((sum, d) => sum + d.value, 0) / data.length)}%` : data.reduce((sum, d) => sum + d.value, 0)} ); };