**Autobit Talisman** is a high-performance, modular charting and visualization library for the web. It is designed to be **event-driven** and **flexible**, allowing you to compose complex financial charts and data visualizations using a Registry-based arc
npm install autobit-talismanbash
npm install autobit-talisman
`
Quick Start
$3
The easiest way to use Talisman is via the Runtime to bootstrap a chart from a simple configuration.
`typescript
import { Runtime } from 'autobit-talisman';
// 1. Initialize Runtime with a container ID
const runtime = new Runtime('chart-container');
// 2. Define a Manifest (or load from JSON)
const manifest = {
objects: {
'MyChart': MyChartClass // Or a path string if using dynamic loading
},
scripts: {
'main': MyScriptClass
}
};
// 3. Boot
await runtime.boot('main', manifest);
`
---
API Reference (
src/index.ts)
$3
- Runtime: The main entry point. Orchestrates the Registry, PlaneManager, and InputManager. It handles booting the application from a manifest.
- Registry: A central repository for registering factory functions for Objects, Sources, and Triggers. Allows decoupling implementation from configuration.
- InputManager: Handles mouse and pointer events on the chart container, delegating them to the PlaneManager and individual Render Objects.
- ALScriptEngine: An engine for executing AL (Algorithm Language) scripts (legacy/optional).
$3
- PlaneManager: Manages multiple Plane layers (canvases). It efficiently handles rendering only when needed (dirty-render pattern).
- createPlane(name, zIndex): Creates a new drawing layer.
- requestRender(): Triggers a render loop for the next animation frame.
- Plane: A single canvas layer. Manages a list of RenderObjects, coordinate spaces (Time/Price scales), and camera state (Zoom/Pan).
- RenderObject (Interface): The contract for anything drawn on the screen.
- render(ctx): Draw logic.
- hitTest(x, y): Interaction detection.
- LineObject, TextObject: Primitive render implementations.
$3
- DataSource: Base class for data feeds (e.g., WebSocket, REST).
- TriggerChain: Manages a pipeline of triggers attempting to process data packets.
---
The Registry System (Detailed Demo)
The Registry is the heart of Talisman's modularity. It allows you to define "Blueprints" for your chart components and instantiate them dynamically. This is useful for building data-driven dashboards or saving/loading chart configurations.
$3
Create a class that implements RenderObject.
`typescript
import { RenderObject, RenderContext, PlaneManager, Registry } from 'autobit-talisman';
export class MyCustomIndicator implements RenderObject {
id: string;
visible = true;
zIndex = 10;
constructor(id: string, private manager: PlaneManager, registry: Registry) {
this.id = id;
}
render(context: RenderContext) {
const { ctx, width, height } = context;
// Draw a red line across the screen
ctx.beginPath();
ctx.strokeStyle = 'red';
ctx.moveTo(0, height / 2);
ctx.lineTo(width, height / 2);
ctx.stroke();
}
}
`
$3
Register the factory function with your Runtime's Registry.
`typescript
// Ideally, do this in a manifest or setup phase
const manifest = {
objects: {
'CustomIndicator': MyCustomIndicator // Direct Class Reference
},
// ... sources, scripts
};
`
$3
You can now create instances of this object by string name. This is powerful for scripting or configuration files.
`typescript
// Inside a Script or Setup function
const indicator = runtime.registry.createObject('CustomIndicator', 'my-indicator-1');
plane.addObject(indicator);
`
$3
Talisman's Runtime can automatically scan a project or accept a JSON manifest to wire everything up.
manifest.json
`json
{
"objects": {
"Candles": "./charts/CandleStick.ts",
"Volume": "./charts/Volume.ts"
},
"scripts": {
"init": "./scripts/Init.ts"
}
}
`
Init.ts
`typescript
export class Init {
run(context: any) {
const { registry } = context;
// Create objects defined in manifest
const candles = registry.createObject('Candles', 'main-candles');
return [candles]; // Return objects to add to the main plane
}
}
``