Skip to content
EliteChart

computeAxisPlusBbox

Documentation


Documentation / @elitechart/core / computeAxisPlusBbox

code
function computeAxisPlusBbox(
   vp, 
   cursor, 
   style?): 
  | {
  size: number;
  x: number;
  y: number;
}
  | null;

Defined in: renderer/axis-plus-button.ts:84

Decide whether the "+" button should be visible given the current cursor position. Returns null when off, or the button's bounding box when on.

Visibility zone is symmetric around plotRight: the button stays on while the cursor is inside the plot within hoverRadiusX of the right edge OR inside the price gutter next to it. This prevents the button from flickering off the moment the cursor crosses the axis line while trying to click it.

Parameters

vp

Viewport

cursor

| { x: number; y: number; } | null

style?

AxisPlusButtonStyle = DEFAULT_AXIS_PLUS_BUTTON_STYLE

Returns

| { size: number; x: number; y: number; } | null

Example

code
import { computeAxisPlusBbox, drawAxisPlusButton } from '@elitechart/core';
const bbox = computeAxisPlusBbox(viewport, cursor);
if (bbox !== null) drawAxisPlusButton(paint, bbox);