import { ScaleBand, ScaleLinear } from "d3-scale"; import React, { Fragment, useEffect, useRef } from "react"; type Props = { dataset: number[]; height: number; xScale: ScaleBand; yScale: ScaleLinear; }; export const BarWithAnimation = ({ dataset, height, xScale, yScale, }: Props) => { // console.log("dataset:", dataset); const preDataset = useRef(dataset); useEffect(() => { preDataset.current = dataset; }, [dataset]); const getStyle = (i: number) => { const style = { // fill: "red", animationName: `inmoveleftright-${i}`, animationDuration: "1s", // animationDirection: "alternate", animationIterationCount: "1", // transformOrigin: "bottom", }; return style; }; return ( {dataset.map((d, i) => { // console.log("d", d, "i", i, "x:", xScale(i), "y", yScale(d)); return ( ); })} ); };