Skip to content

useDrawingTools

Manage drawing tools (chart overlays) — selection, magnet snapping, lock, visibility and clearing.

const {
categories,
activeTool,
magnetMode,
isLocked,
isVisible,
autoRetrigger,
selectTool,
clearActiveTool,
setMagnetMode,
toggleLock,
toggleVisibility,
removeAllDrawings,
setAutoRetrigger,
} = useDrawingTools();
Field/MethodTypeDescription
categoriesDrawingCategoryItem[]Tool categories with nested tools
activeToolstring | nullName of the last selected tool
magnetMode"normal" | "weak" | "strong"Snap-to-OHLC mode
isLockedbooleanWhether all drawings are locked
isVisiblebooleanWhether all drawings are visible
autoRetriggerbooleanRe-arm the tool after finishing a shape (default true)
selectTool(name)—Start drawing via chart.createOverlay
clearActiveTool()—Deselect the tool (local state only)
setMagnetMode(mode)—Change magnet mode for all drawings
toggleLock()—Toggle lock on all drawings
toggleVisibility()—Show/hide all drawings
removeAllDrawings()—Remove all drawings in the drawing_tools group
setAutoRetrigger(v)—Enable/disable auto re-arming
interface DrawingToolItem {
name: string; // klinecharts overlay name, e.g. "arrow", "fibRetracement"
localeKey: string; // localization key
}
interface DrawingCategoryItem {
key: string; // "singleLine" | "moreLine" | "polygon" | "fibonacci" | "wave"
tools: DrawingToolItem[];
}
Category (key)Tools
singleLinehorizontalStraightLine, horizontalRayLine, horizontalSegment, verticalStraightLine, verticalRayLine, verticalSegment, straightLine, rayLine, segment, arrow, priceLine
moreLinepriceChannelLine, parallelStraightLine
polygoncircle, rect, parallelogram, triangle
fibonaccifibonacciLine, fibonacciSegment, fibonacciCircle, fibonacciSpiral, fibonacciSpeedResistanceFan, fibonacciExtension, gannBox
wavexabcd, abcd, threeWaves, fiveWaves, eightWaves, anyWaves
annotationbrush

The overlay templates behind these tools are documented in Drawing Overlays.