How it works
A picture of the parts of Astroneum and how data moves through them. Read this when you want to know why the chart behaves the way it does.
The big picture
Astroneum is a React component on top of a drawing engine. Your app gives it a datafeed (where the bars come from) and settings; the engine turns bars into pixels.
- The engine knows nothing about React. It takes a container element and draws into it. That keeps the drawing fast and testable.
- The React layer is glue. It creates the engine, passes props in, and renders the dialogs and toolbars around the canvas.
- The datafeed is the only thing you must provide. Everything else has a default.
What is on screen
Hover or tab through the parts to see what each one is and which prop controls it.
Main pane
The price chart: candles or a line, the overlay indicators such as EMA, and the drawings you make.
styles={{ candle: { type: 'line' } }}
mainIndicators={[{ name: 'EMA' }]}Every pane stacks a main canvas for the data (bars, lines, indicator values) and an overlay canvas on top for things that change constantly, like the crosshair and the drawing you are making. The overlay repaints without redrawing every bar.
The life of data
First load
Live updates
Once subscribed, the datafeed calls the chart's callback with the newest bar. The chart compares timestamps with the last bar it has. You can try this rule by hand in Getting started, step 4.
- Recalculation is batched. If ten ticks arrive in the same instant, indicators are calculated once, with the latest data.
- A tick that only changes the last bar takes a lighter layout path than a new bar, because the axis width cannot have changed.
Scrolling back in time
How indicators are calculated
An indicator is a function from bars to numbers, plus a description of how to draw them. New data marks indicators stale; after a brief wait (so a burst of ticks costs one calculation) the work is queued at background priority and the panes redraw when it finishes.
The calculation may return a promise, which is how the optional indicator workers plug in without changing anything else.
Where the code lives
| Folder | Purpose |
|---|---|
src/chart | AstroneumChart and chart-level features: replay, multi-chart, alerts, templates, transformed datafeeds |
src/engine | The drawing engine: store, panes, views, about 50 indicators, optional workers |
src/widget | The UI around the canvas: period bar, drawing bar, dialogs |
src/datafeed | The built-in datafeeds, the binary codec and the history cache |
src/extension | The drawing tools: Fibonacci, Gann, pitchforks and more |
src/entries | One tiny file per subpath import such as astroneum/replay |
demo/ | This website and the live demo (a Next.js app) |
For contributors: releases and deploys
Merging to main does the work. Nobody runs a release by hand for a beta; a stable release is a deliberate click.
| Bump type | Example: from 0.4.1-beta.7 | Use it for |
|---|---|---|
prerelease | 0.4.1-beta.8 | another beta (what a merge does) |
patch | 0.4.1 | bug fixes only |
minor | 0.5.0 | new features |
major | 1.0.0 | breaking changes, after 1.0 |
On GitHub: Actions, Auto Version Bump, Run workflow. A published npm version can never be reused, so a bump to a number that already exists fails.