import {
AbsoluteFill,
Easing,
Interactive,
interpolate,
useCurrentFrame,
useVideoConfig,
} from 'remotion';
type ChartItem = {
label: string;
value: number;
color: string;
};
const data: ChartItem[] = [
{label: 'North', value: 42, color: '#58D6FF'},
{label: 'South', value: 68, color: '#7C83FF'},
{label: 'East', value: 55, color: '#C879FF'},
{label: 'West', value: 87, color: '#FF6DAE'},
{label: 'Central', value: 74, color: '#FFB45F'},
];
const AnimatedBar: React.FC<{item: ChartItem; index: number}> = ({
item,
index,
}) => {
const frame = useCurrentFrame();
const start = 35 + index * 8;
const end = start + 34;
const height = (item.value / 100) * 286;
const animatedValue = Math.round(
interpolate(frame, [start, end], [0, item.value], {
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp',
easing: Easing.bezier(0.16, 1, 0.3, 1),
}),
);
return (
{animatedValue}%
{item.label}
);
};
export const BarChart: React.FC = () => {
const frame = useCurrentFrame();
const {durationInFrames} = useVideoConfig();
return (
Performance overview
Regional growth
{[0, 25, 50, 75, 100].map((tick, tickIndex) => (
{tick}
))}
{data.map((item, index) => (
))}
● West leads at 87%
);
};