Skip to main content
A candlestick chart shows how a price moved in each trading session. Each candle has a body from the open to the close and a wick from the low to the high, coloured by whether the session rose or fell.
The candlestick ships as its own package, @graphysdk/geom-candlestick, on a 0.x version line. While it is on 0.x, a minor release may change its aesthetics, style parts or look; pin a caret range (^0.1.0) to take only patches. Tell us what works and what doesn’t on Discord.

Install

It peer-depends on @graphysdk/react and nothing else. Register the plugin once with createGraphyKit, which adds kit.geom.candlestick() and binds kit.GraphProvider to the same plugin:

One candle per session

Map the session to x, and each price to its aesthetic:
All four prices are required. The sessions sit one per band at equal spacing, so a weekend or holiday takes no room. The session axis is always discrete, even for dates. The price axis fits the prices rather than holding zero: A session rises when its close is at or above its open, so a doji (open equal to close) counts as rising and draws as a flat body. The close is the candle’s y: a highlight or a headline that reads y reads the close. A y in the root mapping does not reach the candlestick layer, and the compiler warns that it is ignored.

Horizontal

Add kit.coord.flip(). The sessions move to the vertical axis and the wicks lie across.

Body width

width sets how much of its band each body spans, as a fraction from just above 0 up to 1, like a bar’s. It defaults to 0.6; at 1 neighbouring bodies touch. The wick stays on the band centre.
A width above 1 is clamped to the full band, and one at or below 0 falls back to the default; the compiler warns in both cases.

Styling

A candle’s colour says which way its session went, so it comes from a part per direction. The bodies’ other properties and the wicks have builders of their own:
A wick takes its direction’s stroke unless a wick entry names one. A chart-wide style.geom({ fill }) does not reach the candles, so it cannot flatten them to one colour. To colour the candles from the data instead, see Mapped colour. Each session carries a candlestickDirection variable, 'rising' or 'falling', which replaces a data column of the same name. Name it in an entry’s where to style one direction’s bodies or wicks:

Mapped colour

color is opt-in. Map it to candlestickDirection to colour the directions through a colour scale, with a legend:
Map it to a column you compute to colour by your own rule. A third value paints a doji (open equal to close) apart from both directions:
Hollow candles colour each session by its close against the previous close, and hollow out the bodies that closed above their open:
Or map it to a data column to colour the candles by its groups. Colour then no longer shows the direction, so give it a second cue, such as hollow rising bodies:
A mapped colour replaces the direction parts’ built-in colours and beats their defaults entries. An overrides entry beats the mapped colour, which is why the hollow bodies above are an override. A wick follows its body’s colour unless a wick entry names one.

Hover and highlight

Hovering a session emphasises its candle, and the tooltip lists its open, high, low and close, each labelled by its column’s label (or its key when it has none). A press anywhere along the wick takes its session. A highlight raises each matched candle whole, wick and body together. Match on a price, or on the direction:

Not yet supported

  • The editor’s chart-type picker and the chart agent. In editable mode the candlestick renders, hovers, selects and takes annotations on each session’s close, but it is authored in code.
  • Data labels. dataLabels prints nothing on a candle yet.
  • Volume and OHLC bars. Draw volume as a separate bar chart; OHLC ticks in place of a body are not drawn yet.
  • Aggregation. Duplicate rows for one session all draw; aggregate them first with transform.aggregate().