platform-codebase/@packages/@plugins/analytics/src/components/ui-data-stubs.tsx

42 lines
999 B
TypeScript
Executable file

/**
* Temporary stub components for @ui/data
* These allow the plugin to compile independently.
*/
import React from 'react';
export interface SparklineProps {
data: number[];
width?: number;
height?: number;
color?: string;
className?: string;
}
export const Sparkline: React.FC<SparklineProps> = ({ data, width = 100, height = 30, color = '#00ff00' }) => {
if (!data || data.length === 0) return null;
const max = Math.max(...data);
const min = Math.min(...data);
const range = max - min || 1;
const points = data
.map((value, index) => {
const x = (index / (data.length - 1)) * width;
const y = height - ((value - min) / range) * height;
return `${x},${y}`;
})
.join(' ');
return (
<svg width={width} height={height} style={{ display: 'inline-block' }}>
<polyline
points={points}
fill="none"
stroke={color}
strokeWidth="2"
vectorEffect="non-scaling-stroke"
/>
</svg>
);
};