MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / createTooltip

Function createTooltip

src/components/createTooltip.ts:19–201  ·  view source on GitHub ↗
(container: HTMLElement)

Source from the content-addressed store, hash-verified

17};
18
19export function createTooltip(container: HTMLElement): Tooltip {
20 const computedPosition = getComputedStyle(container).position;
21 const didSetRelative = computedPosition === 'static';
22 const previousInlinePosition = didSetRelative ? container.style.position : null;
23
24 if (didSetRelative) {
25 container.style.position = 'relative';
26 }
27
28 const root = document.createElement('div');
29 root.style.position = 'absolute';
30 root.style.left = '0';
31 root.style.top = '0';
32 root.style.pointerEvents = 'none';
33 root.style.userSelect = 'none';
34 root.style.boxSizing = 'border-box';
35
36 // Theme-friendly default visuals with CSS variable override points.
37 root.style.zIndex = 'var(--chartgpu-tooltip-z, 10)';
38 root.style.padding = 'var(--chartgpu-tooltip-padding, 6px 8px)';
39 root.style.borderRadius = 'var(--chartgpu-tooltip-radius, 8px)';
40 root.style.borderStyle = 'solid';
41 root.style.borderWidth = 'var(--chartgpu-tooltip-border-width, 1px)';
42 root.style.borderColor =
43 'var(--chartgpu-tooltip-border, rgba(224,224,224,0.35))';
44 root.style.boxShadow =
45 'var(--chartgpu-tooltip-shadow, 0 6px 18px rgba(0,0,0,0.35))';
46 root.style.maxWidth = 'var(--chartgpu-tooltip-max-width, min(320px, 100%))';
47 root.style.overflow = 'hidden';
48 root.style.fontFamily =
49 'var(--chartgpu-tooltip-font-family, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji")';
50 root.style.fontSize = 'var(--chartgpu-tooltip-font-size, 12px)';
51 root.style.lineHeight = 'var(--chartgpu-tooltip-line-height, 1.2)';
52 root.style.color = 'var(--chartgpu-tooltip-color, #e0e0e0)';
53 root.style.background = 'var(--chartgpu-tooltip-bg, rgba(26,26,46,0.95))';
54 root.style.whiteSpace = 'normal';
55
56 // Transition-ready baseline; keep fade-out visible until completion.
57 root.style.opacity = '0';
58 root.style.transitionProperty = 'opacity';
59 const fadeMs = 140;
60 root.style.transitionDuration = `${fadeMs}ms`;
61 root.style.transitionTimingFunction = 'ease';
62 root.style.willChange = 'opacity';
63
64 // Keep it out of layout/paint when hidden.
65 root.style.display = 'none';
66 root.style.visibility = 'hidden';
67
68 root.setAttribute('role', 'tooltip');
69 container.appendChild(root);
70
71 let disposed = false;
72 let transitionToken = 0;
73 let hideTimeoutId: number | null = null;
74 let rafId: number | null = null;
75
76 const clearPendingTransitions = (): void => {

Callers 3

createRenderCoordinatorFunction · 0.90
setOptionsFunction · 0.90
createOverlaysMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected