import React from "react"; import { Group } from "@visx/group"; import { AreaClosed } from "@visx/shape"; import { AxisLeft, AxisBottom, AxisScale } from "@visx/axis"; import { LinearGradient } from "@visx/gradient"; import { curveMonotoneX } from "@visx/curve"; import { week_distribution } from "./AreaChart"; const axisColor = "#fff"; const axisBottomTickLabelProps = { textAnchor: "middle" as const, fontFamily: "Arial", fontSize: 10, fill: axisColor, }; const axisLeftTickLabelProps = { dx: "-0.25em", dy: "0.25em", fontFamily: "Arial", fontSize: 10, textAnchor: "end" as const, fill: axisColor, }; export default function AreaChart({ data, gradientColor, width, yMax, margin, xScale, yScale, hideBottomAxis = false, hideLeftAxis = false, top, left, children, }: { data: week_distribution[]; gradientColor: string; xScale: AxisScale; yScale: AxisScale; width: number; yMax: number; margin: { top: number; right: number; bottom: number; left: number }; hideBottomAxis?: boolean; hideLeftAxis?: boolean; top?: number; left?: number; children?: React.ReactNode; }) { if (width < 10) return null; return ( data={data} x={(d) => xScale(d.week) || 0} y={(d) => yScale(d.indice_base_100) || 0} yScale={yScale} strokeWidth={1} stroke="url(#gradient)" fill="url(#gradient)" curve={curveMonotoneX} /> {!hideBottomAxis && ( 520 ? 10 : 5} stroke={axisColor} tickStroke={axisColor} tickLabelProps={axisBottomTickLabelProps} /> )} {!hideLeftAxis && ( )} {children} ); }