import { Chart, ChartAxis, ChartBar, ChartStack, ChartTooltip } from '@patternfly/react-charts/victory';
import { getResizeObserver } from '@patternfly/react-core';
import { useEffect, useRef, useState } from 'react';
interface Bar {
x: string;
y: number;
}
export const ChartStackMonthlyResponsive: React.FunctionComponent = () => {
const containerRef = useRef(null);
const observer = useRef(() => {});
const [width, setWidth] = useState(0);
const handleResize = () => {
if (containerRef.current && containerRef.current.clientWidth) {
setWidth(containerRef.current.clientWidth);
}
};
const bars: Bar[] = [];
for (let i = 1; i < 32; i++) {
bars.push({ x: `Aug. ${i}`, y: Math.floor(Math.random() * 6) + 1 });
}
const renderSocketBars = () => {
const socketBars = bars.map((tick, index) => ({
key: index,
x: tick.x,
y: tick.y,
name: 'Sockets',
label: `${tick.x} Sockets: ${tick.y}`
}));
return