Skip to content

Price lines

Price lines are horizontal lines at a price — for orders, positions, alerts, and the like. The library draws the line and, when it’s draggable, follows the pointer and reports the price; you own the state and decide whether to keep a move. It’s a small subpath export built on the core primitive hook.

import { addPriceLine } from '@lightfin/core/price-lines'
const order = addPriceLine(chart, {
price: 101.25,
title: 'Buy limit 1.0',
color: '#26a69a',
draggable: true,
})
order.on('dragEnd', price => api.modifyOrder(id, price))

addPriceLine(chart, options) needs only price; everything else has a default. Lines added later draw on top and are grabbed first where they overlap.

OptionTypeDefaultNotes
pricenumber— (required)Where the line sits.
colorstringtheme line colorLine, label, and axis badge color.
titlestring''Label on the line at the right edge; empty for none.
lineStyle'solid' | 'dashed' | 'dotted''dashed'—
lineWidthnumber1—
axisLabelbooleantrueShow the price in a badge on the price axis.
draggablebooleanfalseLet the user drag the line vertically.
MemberNotes
optionsThe current (readonly) options.
setOptions(patch)Merge a partial update and redraw.
on(type, handler)Subscribe to a drag event; returns an unsubscribe function.
remove()Remove the line.

Only fire while draggable is set:

EventPayloadFires when
dragnumberThe line is being dragged; it already sits at this price. Call setOptions({ price }) here to snap it to the tick size.
dragEndnumberA drag finished at this price — the moment to send an order update.
order.on('drag', price => order.setOptions({ price: snapToTick(price) }))
order.on('dragEnd', price => api.modifyOrder(id, price))