"use client"; // install (please try to align the version of installed @nivo packages) // yarn add @nivo/bar import { ResponsiveBar } from "@nivo/bar"; import { FC } from "react"; // make sure parent container have a defined height when using // responsive component, otherwise height will be 0 and // no chart will be rendered. // website examples showcase many properties, // you'll often use just a few of them. type MyResponsiveBarProps = { data: BarData[]; filter: string; }; export const MyResponsiveBar: FC = ({ data, filter }) => { // Determine the keys based on the filter let currentPeriodLabel = "Current Period"; let previousPeriodLabel = "Previous Period"; if (filter === "days") { currentPeriodLabel = "Today"; previousPeriodLabel = "Yesterday"; } else if (filter === "weeks") { currentPeriodLabel = "This month"; previousPeriodLabel = "Last month"; } const keys = [currentPeriodLabel, previousPeriodLabel]; return ( `${e.id}: ${e.formattedValue} in emotion: ${e.indexValue}` } theme={{ axis: { legend: { text: { fontSize: 12, fontWeight: 600, fill: "#4b5563", }, }, ticks: { text: { fontSize: 12, fontWeight: 500, fill: "#4b5563", }, }, }, legends: { text: { fontSize: 12, fontWeight: 600, fill: "#4b5563", }, }, }} /> ); };