"use client"; // install (please try to align the version of installed @nivo packages) // yarn add @nivo/bar import { ResponsivePie } from "@nivo/pie"; 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. // const favorit = localFont({ // src: "./fonts/ABCFavorit-Bold.woff2", // variable: "--font-favorit", // }); // const fonts = `${favorit.variable}`; type MyResponsivePieProps = { data: PieData[]; }; // Define the theme object const theme = { legends: { text: { fontSize: 12, // Change this value to your desired font size fontWeight: 600, // fontFamily: fonts, }, }, labels: { text: { fontSize: 16, // Change this value to your desired font size for the labels inside the pie fontWeight: 700, // fontFamily: fonts, }, }, }; export const MyResponsivePie: FC = ({ data }) => ( `${d.value.toFixed(2)}%`} // Display value in percentage // defs={[ // { // id: "dots", // type: "patternDots", // background: "inherit", // color: "rgba(255, 255, 255, 0.3)", // size: 4, // padding: 1, // stagger: true, // }, // { // id: "lines", // type: "patternLines", // background: "inherit", // color: "rgba(255, 255, 255, 0.3)", // rotation: -45, // lineWidth: 6, // spacing: 10, // }, // ]} fill={[ { match: { id: "Negative", }, id: "dots", }, { match: { id: "Positive", }, id: "lines", }, ]} legends={[ { anchor: "bottom", direction: "row", justify: false, translateX: 2, translateY: 40, itemsSpacing: 4, itemWidth: 80, itemHeight: 18, itemTextColor: "#4b5563", itemDirection: "left-to-right", itemOpacity: 1, symbolSize: 16, symbolShape: "circle", effects: [ { on: "hover", style: { itemTextColor: "#000", }, }, ], }, ]} theme={theme} // Apply the theme here colors={["#4ade80", "#d6d3d1", "#fb7185"]} /> );