openalgo-charts 2.1.7 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,12 +4,12 @@
4
4
 
5
5
  **A from-scratch, dependency-free HTML5-canvas charting engine for OpenAlgo.**
6
6
 
7
- Professional interactive charts, 102 built-in indicators plus your own custom ones, 51 drawing tools, order flow, market replay, linked chart grids, on-chart trading, vector SVG export and an optional WebGL2 backend. Eight lazy-loaded tiers, zero runtime dependencies, 73.31 KB Brotli for the base engine, and a one-call widget tier that adds the toolbar, drawing rail, dialogs and shortcuts.
7
+ Professional interactive charts, 102 built-in indicators plus your own custom ones, 51 drawing tools, order flow, market replay, linked chart grids, on-chart trading, vector SVG export and an optional WebGL2 backend. Eight lazy-loaded tiers, zero runtime dependencies, 74.00 KB Brotli for the base engine, and a one-call widget tier that adds the toolbar, drawing rail, dialogs and shortcuts.
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/openalgo-charts.svg?color=cb3837&label=npm)](https://www.npmjs.com/package/openalgo-charts)
10
10
  [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
11
- [![bundle](https://img.shields.io/badge/brotli-73.31%20KB%20base%20%C2%B7%20197.58%20KB%20all%20tiers-brightgreen.svg)](#size-budget)
12
- [![tests](https://img.shields.io/badge/tests-4337%20passing-brightgreen.svg)](#develop)
11
+ [![bundle](https://img.shields.io/badge/brotli-74.00%20KB%20base%20%C2%B7%20201.15%20KB%20all%20tiers-brightgreen.svg)](#size-budget)
12
+ [![tests](https://img.shields.io/badge/tests-4376%20passing-brightgreen.svg)](#develop)
13
13
  [![dependencies](https://img.shields.io/badge/runtime%20deps-0-brightgreen.svg)](#principles)
14
14
 
15
15
  [**Documentation**](https://marketcalls.github.io/openalgo-charts/)  ·  [**Live examples**](https://marketcalls.github.io/openalgo-charts/examples)  ·  [**Getting started**](./docs/getting-started.md)  ·  [**Migrating to 2.0**](./docs/migrating-to-2.md)  ·  [**Architecture**](./ARCHITECTURE.md)
@@ -43,14 +43,14 @@ Every chart in the [live gallery](https://marketcalls.github.io/openalgo-charts/
43
43
 
44
44
  ## Install
45
45
 
46
- Current version: **2.1.7**.
46
+ Current version: **2.1.8**.
47
47
 
48
- This release adds a searchable Objects panel and shared object-management API for
49
- drawings, indicators and host-registered profiles. Dialogs fit narrow chart panes,
50
- and indicator visibility survives settings changes and layout restoration.
51
- See the [Objects guide](https://marketcalls.github.io/openalgo-charts/docs/objects/),
52
- the [2.1.7 changelog](./CHANGELOG.md#217) and
53
- [OpenAlgo compatibility guide](https://marketcalls.github.io/openalgo-charts/docs/openalgo-compatibility/).
48
+ This release adds proportional wheel and trackpad navigation, horizontal wheel pan,
49
+ price-axis wheel scaling and smooth autoscale transitions. The packaged widget now
50
+ provides responsive mobile controls that share its drawings, objects and dialogs.
51
+ See the [interaction guide](https://marketcalls.github.io/openalgo-charts/docs/interactions/),
52
+ the [mobile guide](https://marketcalls.github.io/openalgo-charts/docs/mobile/) and
53
+ the [2.1.8 changelog](./CHANGELOG.md#218).
54
54
 
55
55
  ```bash
56
56
  npm install openalgo-charts
@@ -71,7 +71,7 @@ in front of npm rather than being places you upload to. A chart is one HTML file
71
71
  ```html
72
72
  <div id="chart" style="width:100vw;height:100vh"></div>
73
73
  <script type="module">
74
- import { createChart } from 'https://unpkg.com/openalgo-charts@2.1.7/dist/openalgo-charts.mjs';
74
+ import { createChart } from 'https://unpkg.com/openalgo-charts@2.1.8/dist/openalgo-charts.mjs';
75
75
  const chart = createChart(document.getElementById('chart'), { timezone: 'Asia/Kolkata' });
76
76
  chart.addSeries('candlestick').setData(bars);
77
77
  </script>
@@ -94,6 +94,7 @@ const widget = createWidget('#terminal', {
94
94
  feed: new OpenAlgoDataFeed({ baseUrl: 'http://127.0.0.1:5000', apiKey: 'YOUR_KEY' }),
95
95
  symbol: 'RELIANCE', exchange: 'NSE', interval: '5m',
96
96
  theme: 'dark',
97
+ mobile: 'auto', // compact controls at 640 CSS px or less, or on a coarse pointer
97
98
  persist: true,
98
99
  onOrder: (order) => broker.place(order), // the right-click menu offers order entry only when this is set
99
100
  });
@@ -102,7 +103,7 @@ widget.chart; // the Chart underneath, every base API available
102
103
  widget.draw; // the DrawingController the rail drives
103
104
  ```
104
105
 
105
- `openalgo-charts/widget` is the eighth tier and the only one that builds DOM: a top bar (symbol search, interval pills, chart type, Indicators, capture, settings, theme), the drawing rail with pins and flyouts, a status line, toasts, a right-click menu, a keymap with a `?` panel, and optional layout persistence. Every dialog is generated from a schema the engine already ships (`chartSettingsSchema`, the indicator descriptor, `drawingSettingsSchema`), so no control exists without something behind it, and the chrome takes its colours from the active `ChartTheme` through `--oac-` tokens, so `setTheme` recolours canvas and chrome together. It drives the engine only through the public API, and the build proves it: the ESLint tier ACL and `npm run shake` keep it out of every other bundle, and importing the module touches no DOM, so it can sit in code that also runs on a server. The guide is [`docs/widget.md`](./docs/widget.md).
106
+ `openalgo-charts/widget` is the eighth tier and the only one that builds DOM: a top bar (symbol search, interval pills, chart type, Indicators, capture, settings, theme), the drawing rail with pins and flyouts, a status line, responsive mobile header and bottom controls, toasts, a right-click menu, a keymap with a `?` panel, and optional layout persistence. Every dialog is generated from a schema the engine already ships (`chartSettingsSchema`, the indicator descriptor, `drawingSettingsSchema`), so no control exists without something behind it, and the chrome takes its colours from the active `ChartTheme` through `--oac-` tokens, so `setTheme` recolours canvas and chrome together. It drives the engine only through the public API, and the build proves it: the ESLint tier ACL and `npm run shake` keep it out of every other bundle, and importing the module touches no DOM, so it can sit in code that also runs on a server. The guide is [`docs/widget.md`](./docs/widget.md).
106
107
 
107
108
  ## Tiers
108
109
 
@@ -110,16 +111,16 @@ Import only what you use. Each tier is a separate bundle that registers into the
110
111
 
111
112
  | Import | Contents | Brotli |
112
113
  |---|---|---|
113
- | `openalgo-charts` | Engine, 13 chart types, panes &amp; scales, primitives, registries, chart state, chart linking, bar cache, interval registry, trading overlay, SVG export, render backend port, OpenAlgo feeds | 73.31 KB |
114
+ | `openalgo-charts` | Engine, 13 chart types, panes &amp; scales, primitives, registries, chart state, chart linking, bar cache, interval registry, trading overlay, SVG export, render backend port, OpenAlgo feeds | 74.00 KB |
114
115
  | `openalgo-charts/indicators` | 102 built-in indicators, the `registerIndicator` contract for your own, and the Tier-2 (external-data) contract | 28.05 KB |
115
116
  | `openalgo-charts/draw` | 51 drawing tools + a headless drawing controller, clipboard, settings schema, level palette, freehand geometry and SVG icons | 25.90 KB |
116
117
  | `openalgo-charts/transform` | Heikin Ashi, Renko, Range bars, Line Break, Point &amp; Figure, Kagi | 2.66 KB |
117
118
  | `openalgo-charts/profile` | Volume Profile, Market Profile (TPO) with compact pixel letters, Footprint, order flow | 14.96 KB |
118
119
  | `openalgo-charts/trade` | Order / position / bracket tools + DOM ladder | 7.61 KB |
119
120
  | `openalgo-charts/webgl` | WebGL2 series backend: batched, analytically anti-aliased GPU rendering of the standard chart types behind `renderer: 'auto'`, with a session-long fallback to the 2D path | 6.38 KB |
120
- | `openalgo-charts/widget` | The chart with its chrome in one call: `createWidget` adds a top bar, the drawing rail, a status line, the settings and indicator dialogs, drawing properties, a right-click menu, a keymap with a `?` panel and optional layout persistence. The only tier that ships DOM | 38.72 KB |
121
+ | `openalgo-charts/widget` | The chart with its chrome in one call: `createWidget` adds a top bar, the drawing rail, a status line, the settings and indicator dialogs, drawing properties, a right-click menu, a keymap with a `?` panel and optional layout persistence. The only tier that ships DOM | 41.59 KB |
121
122
 
122
- Everything together is **197.58 KB Brotli**; a widget terminal (base + draw + indicators + widget, what one `createWidget` call loads) is 165.97 KB. Figures are the measured `size-limit` output. The trade tier is listed as its delta over the base, so loading base + trade costs 80.92 KB.
123
+ Everything together is **201.15 KB Brotli**; a widget terminal (base + draw + indicators + widget, what one `createWidget` call loads) is 169.54 KB. Figures are the measured `size-limit` output. The trade tier is listed as its delta over the base, so loading base + trade costs 81.61 KB.
123
124
 
124
125
  ## What's built
125
126
 
@@ -411,16 +412,16 @@ Enforced in CI by [`size-limit`](./.size-limit.json). Nothing is excluded, becau
411
412
 
412
413
  | Bundle | Limit | Actual |
413
414
  |---|---|---|
414
- | Base engine | 74 KB | 73.31 KB |
415
- | Base + trade | 82 KB | 80.92 KB |
415
+ | Base engine | 75 KB | 74.00 KB |
416
+ | Base + trade | 83 KB | 81.61 KB |
416
417
  | Indicators tier | 30 KB | 28.05 KB |
417
418
  | Draw tier | 26 KB | 25.90 KB |
418
419
  | Transform tier | 5 KB | 2.66 KB |
419
420
  | Profile tier | 15 KB | 14.96 KB |
420
421
  | WebGL2 tier | 7 KB | 6.38 KB |
421
- | Widget tier | 40 KB | 38.72 KB |
422
- | Widget terminal (base + draw + indicators + widget) | 168 KB | 165.97 KB |
423
- | **Everything** | **200 KB** | **197.58 KB** |
422
+ | Widget tier | 42 KB | 41.59 KB |
423
+ | Widget terminal (base + draw + indicators + widget) | 170 KB | 169.54 KB |
424
+ | **Everything** | **202 KB** | **201.15 KB** |
424
425
 
425
426
  ## Documentation
426
427
 
@@ -465,7 +466,7 @@ See [Contributing](./CONTRIBUTING.md) for setup, targeted checks, documentation
465
466
  ```bash
466
467
  npm install # install dev toolchain
467
468
  npm run typecheck # strict TypeScript check
468
- npm test # unit tests (vitest) - 4337 across 193 files
469
+ npm test # unit tests (vitest) - 4376 across 196 files
469
470
  npm run build # Rollup -> dist/ (minified ESM per tier + types)
470
471
  npm run size # size-limit (Brotli) against the budget
471
472
  npm run e2e # Playwright Chromium smoke tests
@@ -482,7 +483,7 @@ npm run verify # lint + typecheck + test + build + demo tests + dts + size +
482
483
 
483
484
  ## Status &amp; limitations
484
485
 
485
- Version **2.1.7**. All engine build phases are implemented. Upgrading a 1.9.x host: [Migrating to 2.0](./docs/migrating-to-2.md).
486
+ Version **2.1.8**. All engine build phases are implemented. Upgrading a 1.9.x host: [Migrating to 2.0](./docs/migrating-to-2.md).
486
487
 
487
488
  Known gaps, stated plainly:
488
489
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Library version string. Matches package.json (including locally prepared releases). */
2
- declare const VERSION = "2.1.7";
2
+ declare const VERSION = "2.1.8";
3
3
  /** Returns the current library version. */
4
4
  declare function version(): string;
5
5
 
@@ -261,6 +261,8 @@ declare class PriceScale {
261
261
  * scale to manual mode so autoscale stops overriding it.
262
262
  */
263
263
  scaleAroundCenter(factor: number): void;
264
+ /** Scale around a screen coordinate, retaining its price in every scale mode. */
265
+ scaleAtY(y: number, factor: number): void;
264
266
  /**
265
267
  * Pan the visible range vertically by `dy` media px (dragging the plot up/down).
266
268
  * Works in transformed space so it's correct for log scales, and respects
@@ -276,7 +278,7 @@ declare class PriceScale {
276
278
  * percent span. Log is the one that pads in price space and shows it, which
277
279
  * is long-standing behaviour and left alone here.
278
280
  */
279
- autoscale(low: number, high: number): void;
281
+ autoscale(low: number, high: number, progress?: number): boolean;
280
282
  /**
281
283
  * The baseline actually in force, or null when this mode does not rebase or
282
284
  * the value it was given cannot carry one.
@@ -374,6 +376,8 @@ declare class TimeScale {
374
376
  get width(): number;
375
377
  get barSpacing(): number;
376
378
  setBarSpacing(value: number): void;
379
+ /** Bound a pending zoom target without changing the displayed viewport. */
380
+ constrainBarSpacing(value: number): number;
377
381
  get rightOffset(): number;
378
382
  setRightOffset(value: number): void;
379
383
  /** Logical index of the latest bar; the right edge anchors to baseIndex+rightOffset. */
@@ -1430,7 +1434,7 @@ declare class Pane {
1430
1434
  setScaleHeights(plotHeight: number): void;
1431
1435
  private _layout;
1432
1436
  /** Autoscale each active price scale from its own series (independent axes). */
1433
- autoscale(ctx: PaneRenderContext): void;
1437
+ autoscale(ctx: PaneRenderContext, progress?: number): boolean;
1434
1438
  private _autoscaleScale;
1435
1439
  /**
1436
1440
  * Hold every locked scale's price-per-bar ratio against the geometry it is
@@ -3438,6 +3442,8 @@ interface ChartOptions {
3438
3442
  * instruments. Off restores the single-frame step.
3439
3443
  */
3440
3444
  animZoom?: boolean;
3445
+ /** Ease automatic price ranges during navigation. Defaults to animZoom (true). */
3446
+ animAutoscale?: boolean;
3441
3447
  /**
3442
3448
  * What a wheel zoom holds still: the bar under the cursor, or the right edge
3443
3449
  * (the latest bar). Default `'cursor'`, which is what the chart has always
@@ -3865,13 +3871,17 @@ declare class Chart {
3865
3871
  private _lastDragT;
3866
3872
  private _dragVelocity;
3867
3873
  private _kineticHandle;
3874
+ private _kineticEpoch;
3868
3875
  private _zoomHandle;
3869
3876
  /** The glide in flight, so a second wheel tick folds into it (see ZoomGlide.add). */
3870
3877
  private _zoomGlide;
3871
3878
  private _zoomGlideStart;
3872
3879
  private _zoomGlideApplied;
3873
- private _zoomGlideX;
3874
3880
  private readonly _animZoom;
3881
+ private readonly _animAutoscale;
3882
+ private _autoscaleTime;
3883
+ private _autoscaleFrames;
3884
+ private _navigationEpoch;
3875
3885
  private readonly _zoomAnchor;
3876
3886
  private readonly _doubleClick;
3877
3887
  private readonly _firstDataId;
@@ -4721,6 +4731,8 @@ declare class Chart {
4721
4731
  /** One zoom step, applied now. Shared by the instant path and each glide frame. */
4722
4732
  private _applyZoom;
4723
4733
  private _startZoomGlide;
4734
+ private _beginAutoscaleMotion;
4735
+ private _stopNavigationMotion;
4724
4736
  private _stopZoomGlide;
4725
4737
  /**
4726
4738
  * Restore the preferred visible bar count and re-enable