All files / lib/awareness/collective/components/charts CustomDot.tsx

0% Statements 0/11
0% Branches 0/1
0% Functions 0/1
0% Lines 0/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                                           
import React from 'react';
import { trendColorMap } from './theme';
 
interface Props {
  cx?: number;
  cy?: number;
  payload?: any;
}
 
const clamp = (n: number, min = 0, max = 1) => Math.max(min, Math.min(max, n));
 
export const CustomDot: React.FC<Props> = ({ cx = 0, cy = 0, payload }) => {
  if (!payload) return null;
 
  const color = trendColorMap[payload.originalTrend as keyof typeof trendColorMap];
  const conf = clamp(payload.confidence ?? 0.5);
  const radius = 4 + conf * 6;
  const fillOpacity = 0.4 + conf * 0.6;
 
  return <circle cx={cx} cy={cy} r={radius} fill={color} fillOpacity={fillOpacity} />;
};