Docs

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.

what controls it
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

FolderPurpose
src/chartAstroneumChart and chart-level features: replay, multi-chart, alerts, templates, transformed datafeeds
src/engineThe drawing engine: store, panes, views, about 50 indicators, optional workers
src/widgetThe UI around the canvas: period bar, drawing bar, dialogs
src/datafeedThe built-in datafeeds, the binary codec and the history cache
src/extensionThe drawing tools: Fibonacci, Gann, pitchforks and more
src/entriesOne 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 typeExample: from 0.4.1-beta.7Use it for
prerelease0.4.1-beta.8another beta (what a merge does)
patch0.4.1bug fixes only
minor0.5.0new features
major1.0.0breaking 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.