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

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

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 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                                                                                         
// import React from 'react';
// import { yAxisTickFormatter } from './theme';
 
// export const CustomTooltip = ({ active, payload, label }: any) => {
//   if (!active || !payload || !payload.length) return null;
//   const data = payload[0].payload;
//   return (
//     <div className="rounded-lg bg-[hsl(var(--card))] border border-[hsl(var(--border))] p-3 shadow-lg text-sm">
//       <div className="font-semibold mb-1">
//         {new Date(label).toLocaleString()}
//       </div>
//       <div>Trend: {yAxisTickFormatter(data.trendValue)}</div>
//       <div>Confidence: {(data.confidence * 100).toFixed(1)}%</div>
//       <div>Change Rate: {data.changeRate.toFixed(2)}%</div>
//       {data.notes && (
//         <div className="mt-1 text-[hsl(var(--muted-foreground))] italic">
//           {data.notes}
//         </div>
//       )}
//     </div>
//   );
// };
 
// ================================
import React from 'react';
import { yAxisTickFormatter } from './theme';
 
export const CustomTooltip = ({ active, payload, label }: any) => {
  if (!active || !payload || !payload.length) return null;
  const data = payload[0].payload;
  const isPrediction = data.isPrediction;
 
  return (
    <div className="rounded-lg bg-[hsl(var(--card))]/95 border border-[hsl(var(--border))]/60 p-3 shadow-lg text-xs">
      <div className="font-semibold mb-1">
        {isPrediction ? 'Predicted Next Day' : new Date(label).toLocaleString()}
      </div>
      <div>Trend: {yAxisTickFormatter(data.trendValue)}</div>
      <div>Confidence: {(data.confidence * 100).toFixed(1)}%</div>
      <div>Change Rate: {data.changeRate?.toFixed(2) ?? 0}%</div>
      {data.notes && <div className="mt-1 italic opacity-70">{data.notes}</div>}
    </div>
  );
};