@graphysdk/geom-candlestick
v0.1.1-beta.1792157616330
Published
Candlestick geom for the Graphy charting SDK (beta)
Readme
@graphysdk/geom-candlestick
Beta. This geom is on a
0.xversion line: a minor release may change its aesthetics, style parts or look. Use a caret range (^0.1.0) to take only patches.
A candlestick geom for the Graphy charting SDK. It draws each trading session's open, high, low and close as a body between the open and close and a wick from the low to the high, coloured by whether the session rose or fell.
Learn more at graphy.dev.
Install
npm install @graphysdk/geom-candlestick @graphysdk/reactRequires React 19. Its only peer is @graphysdk/react.
Usage
Data is one row per session. Map the session to x, and the four prices to open, high, low and close:
import { createGraphyKit, GraphRenderer } from '@graphysdk/react';
import { candlestick } from '@graphysdk/geom-candlestick';
const kit = createGraphyKit({ plugins: [candlestick] });
const spec = kit.pipe(
kit.createSpec({ x: 'date' }),
kit.geom.candlestick({ aes: { open: 'open', high: 'high', low: 'low', close: 'close' } }),
kit.scale.x.discrete(),
kit.scale.y.continuous()
);
export function Prices({ data }) {
return (
<kit.GraphProvider spec={spec} data={data}>
<GraphRenderer />
</kit.GraphProvider>
);
}Set params: { width } to change how much of its band each body spans, a fraction in (0, 1] defaulting to 0.6, as on a bar.
The close is the candle's y, so a highlight or headline that reads y reads the close. A y in the root mapping is ignored on the candlestick layer, with a warning.
Colour the sessions with kit.style.geom.candlestick.rising() and kit.style.geom.candlestick.falling(), the wicks with kit.style.geom.candlestick.wick(), and the bodies' shared look with kit.style.geom.candlestick().
color is opt-in. Map it to candlestickDirection to colour the directions through a colour scale with a legend, or to a data column to colour the candles by its groups. A mapped colour beats the direction parts' built-in look and defaults entries; an overrides entry beats it.
Docs
Feedback
This geom is released early to hear what works. Tell us on Discord.
Licence
This package is available under PolyForm Noncommercial, Small Business, or a 32-day Free Trial. Free Trial is local or internal evaluation only — it does not cover a public page. See what you can do under the trial.
For a commercial licence, talk to us.
