mirror of
https://github.com/ruvnet/RuView
synced 2026-07-29 18:31:44 +00:00
fdc7142dfa
- Added IosRssiService to handle synthetic RSSI data for iOS. - Created WebRssiService to simulate RSSI scanning on the web. - Defined shared types for WifiNetwork and RssiService in rssi.service.ts. - Introduced simulation service to generate synthetic sensing data. - Implemented WebSocket service for real-time data handling with reconnection logic. - Established Zustand stores for managing application state related to MAT and pose data. - Developed theme context and utility functions for consistent styling and formatting. - Added type definitions for various application entities including API responses and sensing data. - Created utility functions for color mapping and URL validation. - Configured TypeScript settings for the mobile application.
65 lines
1.5 KiB
TypeScript
65 lines
1.5 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { View, ViewStyle } from 'react-native';
|
|
import { colors } from '../theme/colors';
|
|
|
|
type SparklineChartProps = {
|
|
data: number[];
|
|
color?: string;
|
|
height?: number;
|
|
style?: ViewStyle;
|
|
};
|
|
|
|
const defaultHeight = 72;
|
|
|
|
export const SparklineChart = ({
|
|
data,
|
|
color = colors.accent,
|
|
height = defaultHeight,
|
|
style,
|
|
}: SparklineChartProps) => {
|
|
const normalizedData = data.length > 0 ? data : [0];
|
|
|
|
const chartData = useMemo(
|
|
() =>
|
|
normalizedData.map((value, index) => ({
|
|
x: index,
|
|
y: value,
|
|
})),
|
|
[normalizedData],
|
|
);
|
|
|
|
const yValues = normalizedData.map((value) => Number(value) || 0);
|
|
const yMin = Math.min(...yValues);
|
|
const yMax = Math.max(...yValues);
|
|
const yPadding = yMax - yMin === 0 ? 1 : (yMax - yMin) * 0.2;
|
|
|
|
return (
|
|
<View style={style}>
|
|
<View
|
|
accessibilityRole="image"
|
|
style={{
|
|
height,
|
|
width: '100%',
|
|
borderRadius: 4,
|
|
borderWidth: 1,
|
|
borderColor: color,
|
|
opacity: 0.2,
|
|
backgroundColor: 'transparent',
|
|
}}
|
|
>
|
|
<View
|
|
style={{
|
|
flex: 1,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
}}
|
|
>
|
|
{chartData.map((point) => (
|
|
<View key={point.x} style={{ position: 'absolute', left: `${(point.x / Math.max(normalizedData.length - 1, 1)) * 100}%` }} />
|
|
))}
|
|
</View>
|
|
</View>
|
|
</View>
|
|
);
|
|
};
|