fix: Statistik komplett überarbeitet - korrekte Filterung, Diagramme nach Zeitraum, Granularität
This commit is contained in:
@@ -22,7 +22,20 @@ const CATS = ['Filament','Zubehör','Ersatzteile','Werkzeug','Sonstiges'];
|
||||
const CAT_COLORS = { Filament:'#4ecdc4', Zubehör:'#ffe66d', Ersatzteile:'#ff6b9d', Werkzeug:'#60a5fa', Sonstiges:'#c084fc' };
|
||||
|
||||
const fmt = v => `${(v||0).toFixed(2)} €`;
|
||||
const fmtMonth = m => { if (!m) return ''; const [y,mo] = m.split('-'); return ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'][parseInt(mo)-1]+' '+y.slice(2); };
|
||||
const fmtMonth = m => {
|
||||
if (!m) return '';
|
||||
// YYYY-MM → "Jan 26"
|
||||
if (/^\d{4}-\d{2}$/.test(m)) {
|
||||
const [y,mo] = m.split('-');
|
||||
return ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'][parseInt(mo)-1]+' '+y.slice(2);
|
||||
}
|
||||
// YYYY-MM-DD → "15.06."
|
||||
if (/^\d{4}-\d{2}-\d{2}$/.test(m)) {
|
||||
const [,mo,d] = m.split('-');
|
||||
return `${d}.${mo}.`;
|
||||
}
|
||||
return m;
|
||||
};
|
||||
|
||||
const PERIODS = [
|
||||
{ id:'week', label:'Diese Woche' },
|
||||
@@ -230,7 +243,7 @@ export default function Statistik({ mobile }) {
|
||||
{/* Balkendiagramm Einnahmen vs Ausgaben */}
|
||||
{data.monthlyData.length > 0 && (
|
||||
<div style={S.card}>
|
||||
<div style={S.head}>EINNAHMEN VS. AUSGABEN (MONATLICH)</div>
|
||||
<div style={S.head}>EINNAHMEN VS. AUSGABEN {data.granularity==='day'?'(TÄGLICH)':data.granularity==='week'?'(WÖCHENTLICH)':'(MONATLICH)'}</div>
|
||||
<ResponsiveContainer width="100%" height={200}>
|
||||
<BarChart data={data.monthlyData} margin={{top:0,right:0,bottom:0,left:0}}>
|
||||
<XAxis dataKey="month" tickFormatter={fmtMonth} tick={{fill:'rgba(255,255,255,0.3)',fontSize:10}} axisLine={false} tickLine={false}/>
|
||||
@@ -249,7 +262,7 @@ export default function Statistik({ mobile }) {
|
||||
<div style={{display:'flex',gap:12,flexWrap:'wrap'}}>
|
||||
{data.cumulativeData.length > 1 && (
|
||||
<div style={{...S.card,flex:1,minWidth:200}}>
|
||||
<div style={S.head}>KUMULIERTER NETTOGEWINN</div>
|
||||
<div style={S.head}>NETTOGEWINN IM ZEITVERLAUF</div>
|
||||
<ResponsiveContainer width="100%" height={160}>
|
||||
<LineChart data={data.cumulativeData} margin={{top:5,right:5,bottom:0,left:0}}>
|
||||
<XAxis dataKey="month" tickFormatter={fmtMonth} tick={{fill:'rgba(255,255,255,0.3)',fontSize:9}} axisLine={false} tickLine={false}/>
|
||||
|
||||
Reference in New Issue
Block a user