diff --git a/apps/webapp/app/components/primitives/charts/ChartLoading.tsx b/apps/webapp/app/components/primitives/charts/ChartLoading.tsx
index 8e7ee031f81..6862970b1f7 100644
--- a/apps/webapp/app/components/primitives/charts/ChartLoading.tsx
+++ b/apps/webapp/app/components/primitives/charts/ChartLoading.tsx
@@ -187,72 +187,60 @@ function ChartBarLoadingBackground() {
);
}
-function ChartLineLoadingBackground() {
- // Generate line points with configurable starting position and constraints
- const generateLinePoints = (startY: number, minY: number, maxY: number) => {
- const numPoints = 10;
- const points = [];
- let lastY = startY;
-
- for (let i = 0; i < numPoints; i++) {
- // Calculate x value that spreads points across the full width
- const x = i * (9 / (numPoints - 1));
+type ChartPoint = { x: number; y: number };
- // Create less extreme variations that move smoothly
- const change = Math.random() * 6 - 3; // Range from -3 to +3
- const y = Math.max(minY, Math.min(maxY, lastY + change)); // Apply constraints
+function generateLinePoints(startY: number, minY: number, maxY: number): ChartPoint[] {
+ const numPoints = 10;
+ const points = [];
+ let lastY = startY;
- points.push({ x, y });
- lastY = y;
- }
+ for (let i = 0; i < numPoints; i++) {
+ const x = i * (9 / (numPoints - 1));
+ const change = Math.random() * 6 - 3;
+ const y = Math.max(minY, Math.min(maxY, lastY + change));
- return points;
- };
+ points.push({ x, y });
+ lastY = y;
+ }
- // Generate points for both lines
- const points = useMemo(() => generateLinePoints(30, 10, 90), []);
- const secondPoints = useMemo(() => generateLinePoints(40, 30, 90), []);
-
- const generateSmoothPath = (points: Array<{ x: number; y: number }>) => {
- if (points.length < 2) return "";
+ return points;
+}
- let path = `M0,${50 - points[0].y}`;
+function generateSmoothPath(points: ChartPoint[]) {
+ if (points.length < 2) return "";
- // Use curve command for smooth lines
- for (let i = 0; i < points.length - 1; i++) {
- const x1 = points[i].x;
- const y1 = 50 - points[i].y;
- const x2 = points[i + 1].x;
- const y2 = 50 - points[i + 1].y;
+ let path = `M0,${50 - points[0].y}`;
- // Bezier control points (create smooth curve)
- const cx1 = (x1 + x2) / 2;
- const cy1 = y1;
- const cx2 = (x1 + x2) / 2;
- const cy2 = y2;
+ for (let i = 0; i < points.length - 1; i++) {
+ const x1 = points[i].x;
+ const y1 = 50 - points[i].y;
+ const x2 = points[i + 1].x;
+ const y2 = 50 - points[i + 1].y;
+ const cx1 = (x1 + x2) / 2;
+ const cy1 = y1;
+ const cx2 = (x1 + x2) / 2;
+ const cy2 = y2;
- path += ` C${cx1},${cy1} ${cx2},${cy2} ${x2},${y2}`;
- }
+ path += ` C${cx1},${cy1} ${cx2},${cy2} ${x2},${y2}`;
+ }
- return path;
- };
+ return path;
+}
- const generateAreaPath = (points: Array<{ x: number; y: number }>) => {
- const curvePath = generateSmoothPath(points);
- const lastX = 9;
- return `${curvePath} L${lastX},50 L0,50 Z`;
- };
+function generateAreaPath(points: ChartPoint[]) {
+ return `${generateSmoothPath(points)} L9,50 L0,50 Z`;
+}
- // Component to render a line with area fill and animation
- const AnimatedLine = ({
- points,
- gradientId,
- delay = 0,
- }: {
- points: Array<{ x: number; y: number }>;
- gradientId: string;
- delay?: number;
- }) => (
+function AnimatedLine({
+ points,
+ gradientId,
+ delay = 0,
+}: {
+ points: ChartPoint[];
+ gradientId: string;
+ delay?: number;
+}) {
+ return (
<>
>
);
+}
+
+function ChartLineLoadingBackground() {
+ const points = useMemo(() => generateLinePoints(30, 10, 90), []);
+ const secondPoints = useMemo(() => generateLinePoints(40, 30, 90), []);
return (