@feds01/graphika / tooltip/types
tooltip/types
Interfaces
TooltipRenderer
Defined in: tooltip/types.ts:129
Interface for tooltip renderers.
Implementations of this interface handle the visual rendering of the tooltip, including the tracking line, indicator dots, and tooltip content box.
Methods
clear()
clear(): void;Defined in: tooltip/types.ts:142
Clear/hide the tooltip.
Called when the cursor leaves the graph area.
Returns
void
destroy()
destroy(): void;Defined in: tooltip/types.ts:149
Cleanup resources.
Called when the tooltip manager is destroyed.
Returns
void
render()
render(state): void;Defined in: tooltip/types.ts:135
Render the tooltip with the current state.
Parameters
| Parameter | Type | Description |
|---|---|---|
state | TooltipState | The current tooltip state containing cursor position and line values. |
Returns
void
Type Aliases
LineValue
type LineValue = {
canvasX: number;
canvasY: number;
colour: string;
label: string;
value: number;
};Defined in: tooltip/types.ts:99
Interpolated value for a single line.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
canvasX | number | Canvas X coordinate of the interpolated point. | tooltip/types.ts:109 |
canvasY | number | Canvas Y coordinate of the interpolated point. | tooltip/types.ts:107 |
colour | string | Line colour. | tooltip/types.ts:103 |
label | string | Line label. | tooltip/types.ts:101 |
value | number | Interpolated Y value at current X (in data coordinates). | tooltip/types.ts:105 |
RequiredTooltipOptions
type RequiredTooltipOptions = {
content: Required<TooltipContentOptions>;
enabled: boolean;
format: {
yValue: (y, label) => string;
};
indicators: Required<TooltipIndicatorOptions>;
mode: TooltipMode;
renderMode: "canvas";
trackingLine: Required<TrackingLineOptions>;
};Defined in: tooltip/types.ts:113
Required tooltip options with all fields populated.
Properties
| Property | Type | Defined in |
|---|---|---|
content | Required<TooltipContentOptions> | tooltip/types.ts:118 |
enabled | boolean | tooltip/types.ts:114 |
format | { yValue: (y, label) => string; } | tooltip/types.ts:119 |
format.yValue | (y, label) => string | tooltip/types.ts:119 |
indicators | Required<TooltipIndicatorOptions> | tooltip/types.ts:120 |
mode | TooltipMode | tooltip/types.ts:115 |
renderMode | "canvas" | tooltip/types.ts:116 |
trackingLine | Required<TrackingLineOptions> | tooltip/types.ts:117 |
TooltipContentOptions
type TooltipContentOptions = {
backgroundColor?: string;
borderRadius?: number;
fontSize?: number;
padding?: number;
show?: boolean;
textColour?: string;
};Defined in: tooltip/types.ts:25
Options for the tooltip content box.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
backgroundColor? | string | Background color of the tooltip box. Defaults to 'rgba(255, 255, 255, 0.95)'. | tooltip/types.ts:29 |
borderRadius? | number | Border radius of the tooltip box. Defaults to 4. | tooltip/types.ts:37 |
fontSize? | number | Font size in pixels. Defaults to 12. | tooltip/types.ts:33 |
padding? | number | Padding inside the tooltip box. Defaults to 8. | tooltip/types.ts:35 |
show? | boolean | Whether to show the tooltip box with values. Defaults to true. | tooltip/types.ts:27 |
textColour? | string | Text color. Defaults to '#333'. | tooltip/types.ts:31 |
TooltipFormatOptions
type TooltipFormatOptions = {
yValue?: (y, label) => string;
};Defined in: tooltip/types.ts:41
Options for value formatting in the tooltip.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
yValue? | (y, label) => string | Custom formatter for Y values. Receives value and line label. | tooltip/types.ts:43 |
TooltipIndicatorOptions
type TooltipIndicatorOptions = {
radius?: number;
show?: boolean;
};Defined in: tooltip/types.ts:47
Options for indicator dots shown on lines at the cursor position.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
radius? | number | Radius of indicator dots. Defaults to 4. | tooltip/types.ts:51 |
show? | boolean | Whether to show indicator dots on lines. Defaults to true. | tooltip/types.ts:49 |
TooltipMode
type TooltipMode = "interpolated" | "nearest";Defined in: tooltip/types.ts:55
Mode for determining Y values at cursor position.
TooltipOptions
type TooltipOptions = {
content?: TooltipContentOptions;
enabled?: boolean;
format?: TooltipFormatOptions;
indicators?: TooltipIndicatorOptions;
mode?: TooltipMode;
renderMode?: "canvas";
trackingLine?: TrackingLineOptions;
};Defined in: tooltip/types.ts:58
Options for the tooltip feature.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
content? | TooltipContentOptions | Tooltip content box configuration. | tooltip/types.ts:76 |
enabled? | boolean | Whether to enable the tooltip feature. Defaults to false. | tooltip/types.ts:60 |
format? | TooltipFormatOptions | Value formatting configuration. | tooltip/types.ts:79 |
indicators? | TooltipIndicatorOptions | Indicator dots configuration. | tooltip/types.ts:82 |
mode? | TooltipMode | Mode for determining Y values at cursor position. - 'interpolated': Smoothly interpolate between data points (default) - 'nearest': Snap to the nearest actual data point | tooltip/types.ts:67 |
renderMode? | "canvas" | Rendering mode: 'canvas' draws directly to canvas. Defaults to 'canvas'. | tooltip/types.ts:70 |
trackingLine? | TrackingLineOptions | Tracking line configuration. | tooltip/types.ts:73 |
TooltipState
type TooltipState = {
active: boolean;
canvasX: number;
canvasY: number;
dataX: number;
lineValues: LineValue[];
};Defined in: tooltip/types.ts:86
Current tooltip state.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
active | boolean | Whether the cursor is currently within the graph area. | tooltip/types.ts:88 |
canvasX | number | Current cursor position in canvas coordinates. | tooltip/types.ts:90 |
canvasY | number | - | tooltip/types.ts:91 |
dataX | number | Current cursor position in data X coordinate. | tooltip/types.ts:93 |
lineValues | LineValue[] | Interpolated Y values for each line at the current X position. | tooltip/types.ts:95 |
TrackingLineOptions
type TrackingLineOptions = {
colour?: string;
show?: boolean;
style?: "solid" | "dashed";
width?: number;
};Defined in: tooltip/types.ts:13
Options for the tracking line that follows the cursor.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
colour? | string | Color of the tracking line. Defaults to 'rgba(0, 0, 0, 0.5)'. | tooltip/types.ts:17 |
show? | boolean | Whether to show the vertical tracking line. Defaults to true. | tooltip/types.ts:15 |
style? | "solid" | "dashed" | Line style: 'solid' or 'dashed'. Defaults to 'solid'. | tooltip/types.ts:21 |
width? | number | Line width in pixels. Defaults to 1. | tooltip/types.ts:19 |