MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / XAxisLabel

Function XAxisLabel

apps/start/src/components/charts/x-axis.tsx:29–74  ·  view source on GitHub ↗
({
  label,
  x,
  crosshairX,
  isHovering,
  tickerHalfWidth,
}: XAxisLabelProps)

Source from the content-addressed store, hash-verified

27}
28
29function XAxisLabel({
30 label,
31 x,
32 crosshairX,
33 isHovering,
34 tickerHalfWidth,
35}: XAxisLabelProps) {
36 const fadeBuffer = 20;
37 const fadeRadius = tickerHalfWidth + fadeBuffer;
38
39 let opacity = 1;
40 if (isHovering && crosshairX !== null) {
41 const distance = Math.abs(x - crosshairX);
42 if (distance < tickerHalfWidth) {
43 opacity = 0;
44 } else if (distance < fadeRadius) {
45 opacity = (distance - tickerHalfWidth) / fadeBuffer;
46 }
47 }
48
49 // Zero-width container approach for perfect centering
50 // The wrapper is positioned exactly at x with width:0
51 // The inner span overflows and is centered via text-align
52 return (
53 <div
54 className="absolute"
55 style={{
56 left: x,
57 bottom: 12,
58 width: 0,
59 display: "flex",
60 justifyContent: "center",
61 }}
62 >
63 <span
64 className={cn("whitespace-nowrap text-chart-label text-xs")}
65 style={{
66 opacity,
67 transition: "opacity 0.4s ease-in-out",
68 }}
69 >
70 {label}
71 </span>
72 </div>
73 );
74}
75
76export function XAxis(props: XAxisProps) {
77 const { containerRef } = useChartStable();

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected