mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 16:45:24 +02:00
feat: exclude 2023 data & improve weekly sales tooltip (add Sell Out €)
This commit is contained in:
@@ -64,7 +64,7 @@ const WoWTooltip = ({ active, payload, label, data }: any) => {
|
|||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<span className="font-mono font-semibold text-slate-200">
|
<span className="font-mono font-semibold text-slate-200">
|
||||||
{p.dataKey === 'sellOut'
|
{p.dataKey === 'sellOut'
|
||||||
? `€${Number(p.value).toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 0})}`
|
? `€${Number(p.value).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 0 })}`
|
||||||
: `${Number(p.value).toLocaleString()} u`}
|
: `${Number(p.value).toLocaleString()} u`}
|
||||||
</span>
|
</span>
|
||||||
{wowEl}
|
{wowEl}
|
||||||
@@ -101,12 +101,12 @@ const ComparisonTooltip = ({ active, payload, label }: any) => {
|
|||||||
dataByYear[year] = {};
|
dataByYear[year] = {};
|
||||||
}
|
}
|
||||||
// Use the color from the Sell Out line for consistency for that year block
|
// Use the color from the Sell Out line for consistency for that year block
|
||||||
if (metric.toLowerCase().includes('so')) {
|
if (metric.toLowerCase().includes('sell out')) {
|
||||||
dataByYear[year].sellOut = p.value;
|
dataByYear[year].sellOut = p.value;
|
||||||
dataByYear[year].color = p.stroke || p.color;
|
dataByYear[year].color = p.stroke || p.color;
|
||||||
} else if (metric.toLowerCase().includes('units')) {
|
} else if (metric.toLowerCase().includes('units')) {
|
||||||
dataByYear[year].units = p.value;
|
dataByYear[year].units = p.value;
|
||||||
if(!dataByYear[year].color) { // fallback color from units line
|
if (!dataByYear[year].color) { // fallback color from units line
|
||||||
dataByYear[year].color = p.stroke || p.color;
|
dataByYear[year].color = p.stroke || p.color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ const ComparisonTooltip = ({ active, payload, label }: any) => {
|
|||||||
<span className="font-medium" style={{ color: yearData.color }}>Sell Out:</span>
|
<span className="font-medium" style={{ color: yearData.color }}>Sell Out:</span>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<span className="font-mono font-semibold" style={{ color: yearData.color }}>
|
<span className="font-mono font-semibold" style={{ color: yearData.color }}>
|
||||||
€{Number(yearData.sellOut).toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 0})}
|
€{Number(yearData.sellOut).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 0 })}
|
||||||
</span>
|
</span>
|
||||||
{sellOutGrowthEl}
|
{sellOutGrowthEl}
|
||||||
</div>
|
</div>
|
||||||
@@ -427,12 +427,12 @@ const DataGrid: React.FC<DataGridProps> = ({ data }) => {
|
|||||||
<XAxis
|
<XAxis
|
||||||
dataKey="name"
|
dataKey="name"
|
||||||
stroke="#64748b"
|
stroke="#64748b"
|
||||||
tick={{fontSize: 12}}
|
tick={{ fontSize: 12 }}
|
||||||
interval={isComparisonView ? 2 : 'preserveStartEnd'}
|
interval={isComparisonView ? 2 : 'preserveStartEnd'}
|
||||||
/>
|
/>
|
||||||
<YAxis
|
<YAxis
|
||||||
stroke="#64748b"
|
stroke="#64748b"
|
||||||
tickFormatter={(val) => `€${(val/1000).toFixed(0)}k`}
|
tickFormatter={(val) => `€${(val / 1000).toFixed(0)}k`}
|
||||||
/>
|
/>
|
||||||
<Tooltip content={(props: any) => isComparisonView ? <ComparisonTooltip {...props} /> : <WoWTooltip {...props} data={chartData} />} />
|
<Tooltip content={(props: any) => isComparisonView ? <ComparisonTooltip {...props} /> : <WoWTooltip {...props} data={chartData} />} />
|
||||||
<Legend />
|
<Legend />
|
||||||
|
|||||||
@@ -224,8 +224,8 @@ export const processCSV = (fileOrContent: File | string): Promise<SalesRecord[]>
|
|||||||
const data: SalesRecord[] = results.data.map((row: any, index: number) => {
|
const data: SalesRecord[] = results.data.map((row: any, index: number) => {
|
||||||
return mapRowToRecord(row, index);
|
return mapRowToRecord(row, index);
|
||||||
})
|
})
|
||||||
// Filter: Valid Year AND Allowed Customer
|
// Filter: Valid Year > 2023 (exclude incomplete 2023 data) AND Allowed Customer
|
||||||
.filter((r: SalesRecord) => r.year > 0 && isAllowedCustomer(r.customer));
|
.filter((r: SalesRecord) => r.year > 2023 && isAllowedCustomer(r.customer));
|
||||||
|
|
||||||
resolve(data);
|
resolve(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user