"use client";
import { useState } from "react";
import {
LineChart,
Line,
XAxis,
YAxis,
Tooltip,
ResponsiveContainer,
CartesianGrid,
Legend,
} from "recharts";
interface Series {
date: string;
count: number;
}
interface TopRow {
label: string;
count: number;
}
export default function AnalyticsCharts({
impSeries,
clkSeries,
impSeriesBot,
clkSeriesBot,
topPages,
topReferrers,
totals,
}: {
impSeries: Series[];
clkSeries: Series[];
impSeriesBot: Series[];
clkSeriesBot: Series[];
topPages: TopRow[];
topReferrers: TopRow[];
totals: { impHuman: number; impBot: number; clkHuman: number; clkBot: number };
}) {
const [includeBots, setIncludeBots] = useState(false);
const imp = includeBots ? impSeriesBot : impSeries;
const clk = includeBots ? clkSeriesBot : clkSeries;
const totImp = includeBots ? totals.impHuman + totals.impBot : totals.impHuman;
const totClk = includeBots ? totals.clkHuman + totals.clkBot : totals.clkHuman;
const ctr = totImp ? ((totClk / totImp) * 100).toFixed(2) + "%" : "—";
return (
<>
No data yet.
) : (| {r.label} | {r.count.toLocaleString()} |