Skip to content

Documentation / @finchart/indicators / pointAndFigureSeries

Function: pointAndFigureSeries() ​

pointAndFigureSeries(options): Series<PointAndFigureColumn>

Defined in: indicators/src/point-and-figure-series.ts:241

Draws pointAndFigure's columns as X's and O's. A column's boxes are cells one slot wide (the slot is the column's, as a candle's is) and one boxSize high. An X is two strokes across the cell, an O a closed polyline of twelve sides; both leave a margin of the cell so a stack does not touch. Colours follow tone (the candle's up/down), the stroke width is --chart-pnf-width.

The series assumes of the value axis what every series assumes — that it is monotone: a price between two others lands between their pixels — and nothing else about its shape. Everything below follows from that alone. Only the boxes whose cells reach into the pane are drawn, found by binary search on the cell edges' pixels (monotone in the box index), so a column zoomed to a hundred-box window draws that window, however tall it is. A box's cell is measured on the axis it is drawn on as twice the distance from the box's price to the nearer edge of its cell, so a glyph always sits inside its cell — on a log axis, which folds every price at or below zero onto one spot, the box holding zero measures nothing. Below a floor — a cell narrower or shorter than 4 px — a glyph is only a smudge, so a run of such boxes is drawn as one bar from the top of its highest to the bottom of its lowest, in the same colour. The boxes are judged by halving: a stretch of boxes that spans fewer than 4 px holds no legible cell (a cell cannot be taller than the stretch it lies in), so it joins the run whole, and only a stretch that spans more is split and looked into. Together those bound a frame: a glyph needs 4 px of the pane's height to itself, so at most the pane's cells at the floor (its area over 16 px²) plus the box at each edge of a visible column that only partly reaches in, and a bar per run of smaller boxes. The axis is asked, per column, about its edges and the window (two halvings, log₂ of its boxes each), then once per stretch the halving looks into — at most the pane's height over 4 px, plus two, per level of halving: for a 600 px pane and a column of 2⁴⁷ boxes some seven thousand times, for a column of a hundred boxes a few hundred, never once per box; a column too narrow for a glyph is asked twice.

Two things stay the axis's: it keeps a pixel finite where its own arithmetic would leave the doubles (a linear axis over ±Number.MAX_VALUE, a log axis over two adjacent doubles), and when a log axis fits a range that crosses zero it asks the accessor's getPositiveFloor, which this accessor answers with the column's lowest box above zero rather than its low.

coordinates is the candle's accessor with the column's fields at the door — the value is close, the span low..high (what a probe snaps to), one column per x and no gaps. Decimation is PnfAggregation at one point per pixel, declared: columns are merged, never thinned. The y axis is claimed half a box beyond the lowest and highest box so the end glyphs are not clipped (as far as the double range allows).

Parameters ​

options ​

PointAndFigureSeriesOptions

Returns ​

Series<PointAndFigureColumn>