Skip to content

@feds01/graphika


@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()
ts
clear(): void;

Defined in: tooltip/types.ts:142

Clear/hide the tooltip.

Called when the cursor leaves the graph area.

Returns

void

destroy()
ts
destroy(): void;

Defined in: tooltip/types.ts:149

Cleanup resources.

Called when the tooltip manager is destroyed.

Returns

void

render()
ts
render(state): void;

Defined in: tooltip/types.ts:135

Render the tooltip with the current state.

Parameters
ParameterTypeDescription
stateTooltipStateThe current tooltip state containing cursor position and line values.
Returns

void

Type Aliases

LineValue

ts
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

PropertyTypeDescriptionDefined in
canvasXnumberCanvas X coordinate of the interpolated point.tooltip/types.ts:109
canvasYnumberCanvas Y coordinate of the interpolated point.tooltip/types.ts:107
colourstringLine colour.tooltip/types.ts:103
labelstringLine label.tooltip/types.ts:101
valuenumberInterpolated Y value at current X (in data coordinates).tooltip/types.ts:105

RequiredTooltipOptions

ts
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

PropertyTypeDefined in
contentRequired<TooltipContentOptions>tooltip/types.ts:118
enabledbooleantooltip/types.ts:114
format{ yValue: (y, label) => string; }tooltip/types.ts:119
format.yValue(y, label) => stringtooltip/types.ts:119
indicatorsRequired<TooltipIndicatorOptions>tooltip/types.ts:120
modeTooltipModetooltip/types.ts:115
renderMode"canvas"tooltip/types.ts:116
trackingLineRequired<TrackingLineOptions>tooltip/types.ts:117

TooltipContentOptions

ts
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

PropertyTypeDescriptionDefined in
backgroundColor?stringBackground color of the tooltip box. Defaults to 'rgba(255, 255, 255, 0.95)'.tooltip/types.ts:29
borderRadius?numberBorder radius of the tooltip box. Defaults to 4.tooltip/types.ts:37
fontSize?numberFont size in pixels. Defaults to 12.tooltip/types.ts:33
padding?numberPadding inside the tooltip box. Defaults to 8.tooltip/types.ts:35
show?booleanWhether to show the tooltip box with values. Defaults to true.tooltip/types.ts:27
textColour?stringText color. Defaults to '#333'.tooltip/types.ts:31

TooltipFormatOptions

ts
type TooltipFormatOptions = {
  yValue?: (y, label) => string;
};

Defined in: tooltip/types.ts:41

Options for value formatting in the tooltip.

Properties

PropertyTypeDescriptionDefined in
yValue?(y, label) => stringCustom formatter for Y values. Receives value and line label.tooltip/types.ts:43

TooltipIndicatorOptions

ts
type TooltipIndicatorOptions = {
  radius?: number;
  show?: boolean;
};

Defined in: tooltip/types.ts:47

Options for indicator dots shown on lines at the cursor position.

Properties

PropertyTypeDescriptionDefined in
radius?numberRadius of indicator dots. Defaults to 4.tooltip/types.ts:51
show?booleanWhether to show indicator dots on lines. Defaults to true.tooltip/types.ts:49

TooltipMode

ts
type TooltipMode = "interpolated" | "nearest";

Defined in: tooltip/types.ts:55

Mode for determining Y values at cursor position.


TooltipOptions

ts
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

PropertyTypeDescriptionDefined in
content?TooltipContentOptionsTooltip content box configuration.tooltip/types.ts:76
enabled?booleanWhether to enable the tooltip feature. Defaults to false.tooltip/types.ts:60
format?TooltipFormatOptionsValue formatting configuration.tooltip/types.ts:79
indicators?TooltipIndicatorOptionsIndicator dots configuration.tooltip/types.ts:82
mode?TooltipModeMode for determining Y values at cursor position. - 'interpolated': Smoothly interpolate between data points (default) - 'nearest': Snap to the nearest actual data pointtooltip/types.ts:67
renderMode?"canvas"Rendering mode: 'canvas' draws directly to canvas. Defaults to 'canvas'.tooltip/types.ts:70
trackingLine?TrackingLineOptionsTracking line configuration.tooltip/types.ts:73

TooltipState

ts
type TooltipState = {
  active: boolean;
  canvasX: number;
  canvasY: number;
  dataX: number;
  lineValues: LineValue[];
};

Defined in: tooltip/types.ts:86

Current tooltip state.

Properties

PropertyTypeDescriptionDefined in
activebooleanWhether the cursor is currently within the graph area.tooltip/types.ts:88
canvasXnumberCurrent cursor position in canvas coordinates.tooltip/types.ts:90
canvasYnumber-tooltip/types.ts:91
dataXnumberCurrent cursor position in data X coordinate.tooltip/types.ts:93
lineValuesLineValue[]Interpolated Y values for each line at the current X position.tooltip/types.ts:95

TrackingLineOptions

ts
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

PropertyTypeDescriptionDefined in
colour?stringColor of the tracking line. Defaults to 'rgba(0, 0, 0, 0.5)'.tooltip/types.ts:17
show?booleanWhether 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?numberLine width in pixels. Defaults to 1.tooltip/types.ts:19

Released under the ISC License.