"use client" import { LineChart, Line, CartesianGrid, XAxis, YAxis, PieChart, Pie } from "recharts" import { SubComplete } from "./page" export function SubsChart({ data }: { data: Array }) { const pieData: Array<{ story: string, occurrences: number }> = [] data.forEach(dataRow => { const story = dataRow.story.title const exists = pieData.findIndex(pieRow => story === pieRow.story) if (exists === -1) { //add the story to pieData if it doesn't already exist pieData.push({ story: story, occurrences: 0 }) return } pieData[exists].occurrences++ }) console.log(pieData) return ( <> ) }