Documentation

AI Integration Context

Use this file as context for coding assistants integrating @hyperprop/charting-library.

What this library is#

  • Canvas-based chart rendering and interaction engine.
  • Framework-agnostic (no React/Vue dependency).
  • Strong support for price lines, order lines, and trading-style widgets.

What this library is not#

  • Not an order execution engine.
  • Not a broker/exchange API.
  • No persistence/state backend.

All business rules (order lifecycle, fills, validation, permissions) must be handled in app code.

Integration model#

  1. App owns source-of-truth state.
  2. App translates state -> setData, setPriceLines, setOrderLines.
  3. App listens to onOrderAction/onChartClick.
  4. App mutates state.
  5. App re-renders lines/data into chart.

This pattern is required for reliable drag/update behavior during live ticks.

Canonical event handling#

  • move -> update stored price immediately.
  • custom action (for example execute) -> run domain logic in app.
  • dragging: true -> interim updates during drag.
  • dragging: false -> drag completed.

Common mistakes to avoid#

  • Treating chart line visuals as source-of-truth.
  • Putting broker logic inside chart callbacks directly.
  • Ignoring interim drag events while streaming data.
  • Assuming action is closed enum. It is open (string) by design.

Useful option groups#

  • Display: backgroundColor, axis, grid, watermark, crosshair, tickerLine
  • Candles: candleBodyWidthRatio, candleMinWidth, candleWickWidth
  • Stability: autoScaleSmoothing, autoScaleIgnoreLatestCandle
  • Interaction: doubleClickEnabled, doubleClickAction
  • Overlays: priceLines, orderLines

Suggested docs for AI prompts#

When using this library in another repo, include:

  1. docs/API.md
  2. docs/EVENTS.md
  3. docs/BRACKETS.md (if trading/order workflows)
  4. this file (AI_CONTEXT.md)

That gives enough context for most integration tasks without reading source.