acttrader-charts 1.0.0 → 1.0.2

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
@@ -1,4 +1,4 @@
1
- # @acttrader/stockchart
1
+ # acttrader-charts
2
2
 
3
3
  A performant, zero-dependency stock charting library built on Canvas 2D.
4
4
  Dual ESM/CJS output, TypeScript-first.
@@ -10,7 +10,7 @@ Dual ESM/CJS output, TypeScript-first.
10
10
  ## Installation
11
11
 
12
12
  ```bash
13
- npm install @acttrader/stockchart
13
+ npm install acttrader-charts
14
14
  ```
15
15
 
16
16
  ---
@@ -18,7 +18,7 @@ npm install @acttrader/stockchart
18
18
  ## Basic Usage
19
19
 
20
20
  ```ts
21
- import { ChartEngine } from '@acttrader/stockchart';
21
+ import { ChartEngine } from 'acttrader-charts';
22
22
 
23
23
  const chart = new ChartEngine({
24
24
  container: document.getElementById('chart')!,
@@ -62,7 +62,7 @@ const chart = new ChartEngine({
62
62
  ### Adding Indicators
63
63
 
64
64
  ```ts
65
- import { SMA, EMA, RSI } from '@acttrader/stockchart';
65
+ import { SMA, EMA, RSI } from 'acttrader-charts';
66
66
 
67
67
  chart.addIndicator(new SMA(20, '#f59e0b')); // overlay
68
68
  chart.addIndicator(new RSI(14, '#818cf8')); // sub-pane
@@ -83,7 +83,7 @@ Keyboard shortcuts: `Escape` cancel / deselect · `Delete`/`Backspace` remove se
83
83
  ### Real-time Streaming
84
84
 
85
85
  ```ts
86
- import { WebSocketAdapter } from '@acttrader/stockchart';
86
+ import { WebSocketAdapter } from 'acttrader-charts';
87
87
 
88
88
  const adapter = new WebSocketAdapter(
89
89
  'wss://feed.example.com/ticks',
@@ -249,7 +249,7 @@ new ChartEngine({ ..., durationTimeframeMap: { '1Y': '4h', '5Y': '1D' } });
249
249
  All values are optional; unset keys fall back to `DEFAULT_UI_CONFIG`.
250
250
 
251
251
  ```ts
252
- import { DEFAULT_UI_CONFIG } from '@acttrader/stockchart';
252
+ import { DEFAULT_UI_CONFIG } from 'acttrader-charts';
253
253
  ```
254
254
 
255
255
  | Component key | Configurable properties |
@@ -265,7 +265,7 @@ import { DEFAULT_UI_CONFIG } from '@acttrader/stockchart';
265
265
  **Example:**
266
266
 
267
267
  ```ts
268
- import { resolveUiConfig } from '@acttrader/stockchart';
268
+ import { resolveUiConfig } from 'acttrader-charts';
269
269
 
270
270
  new ChartEngine({
271
271
  container,
@@ -285,7 +285,7 @@ import {
285
285
  DEFAULT_PRICE_AXIS_CONFIG,
286
286
  DEFAULT_CROSSHAIR_CONFIG,
287
287
  // ...
288
- } from '@acttrader/stockchart';
288
+ } from 'acttrader-charts';
289
289
  ```
290
290
 
291
291
  ### `ChartLabels` — i18n / translation
@@ -293,7 +293,7 @@ import {
293
293
  All user-visible strings can be overridden for translation. Only keys you supply are replaced; the rest fall back to `DEFAULT_LABELS` (English).
294
294
 
295
295
  ```ts
296
- import { DEFAULT_LABELS, resolveLabels } from '@acttrader/stockchart';
296
+ import { DEFAULT_LABELS, resolveLabels } from 'acttrader-charts';
297
297
  ```
298
298
 
299
299
  Pass overrides directly in `ChartConfig`:
@@ -378,8 +378,8 @@ new ChartEngine({
378
378
  ### `ChartTheme` — colors
379
379
 
380
380
  ```ts
381
- import { DARK_THEME, LIGHT_THEME } from '@acttrader/stockchart';
382
- import type { ChartTheme } from '@acttrader/stockchart';
381
+ import { DARK_THEME, LIGHT_THEME } from 'acttrader-charts';
382
+ import type { ChartTheme } from 'acttrader-charts';
383
383
  ```
384
384
 
385
385
  Pass a full or partial theme object to customize colors:
@@ -491,7 +491,7 @@ chart.setState(state);
491
491
  Use together with the `stateChange` event to persist chart config per symbol:
492
492
 
493
493
  ```ts
494
- import type { ChartState } from '@acttrader/stockchart';
494
+ import type { ChartState } from 'acttrader-charts';
495
495
 
496
496
  chart.on('stateChange', ({ symbol, state }) => {
497
497
  localStorage.setItem(`chart:${symbol}`, JSON.stringify(state));
@@ -637,7 +637,7 @@ chart.on('tradeLevelConfirmed',({ label, type }) => {});
637
637
  Implement `IIndicator` and pass it to `addIndicator()`:
638
638
 
639
639
  ```ts
640
- import type { IIndicator, OHLCVBar, IndicatorResult } from '@acttrader/stockchart';
640
+ import type { IIndicator, OHLCVBar, IndicatorResult } from 'acttrader-charts';
641
641
 
642
642
  class MyIndicator implements IIndicator {
643
643
  name = 'MyInd';
@@ -617,6 +617,34 @@ interface ChartConfig {
617
617
  * Default: `2`.
618
618
  */
619
619
  mobileBarDivisor?: 2 | 3 | 4;
620
+ /**
621
+ * Initial number of candles visible when the chart first loads (desktop).
622
+ * On mobile this value is further divided by `mobileBarDivisor` unless
623
+ * `defaultMobileVisibleBars` is also set.
624
+ * Default: `80`.
625
+ *
626
+ * @deprecated Use `targetCandleWidth` instead. The chart will automatically
627
+ * calculate the appropriate number of visible bars based on the canvas width.
628
+ * This option remains as an explicit override when a fixed bar count is needed.
629
+ */
630
+ defaultVisibleBars?: number;
631
+ /**
632
+ * Initial number of candles visible when the chart first loads on
633
+ * touch/mobile devices. When set, overrides the `mobileBarDivisor` logic.
634
+ * Default: `defaultVisibleBars / mobileBarDivisor`.
635
+ *
636
+ * @deprecated Use `targetCandleWidth` instead. The chart will automatically
637
+ * calculate the appropriate number of visible bars based on the canvas width.
638
+ * This option remains as an explicit override when a fixed bar count is needed.
639
+ */
640
+ defaultMobileVisibleBars?: number;
641
+ /**
642
+ * Target pixel width per candle slot used to auto-calculate the initial
643
+ * number of visible bars from the canvas width. Ignored when
644
+ * `defaultVisibleBars` is explicitly provided.
645
+ * Default: `10`.
646
+ */
647
+ targetCandleWidth?: number;
620
648
  /**
621
649
  * Which side of the quote to use for candle close/high/low during live
622
650
  * tick updates. Defaults to `'bid'` (forex convention). Set to `'ask'`
@@ -726,6 +754,8 @@ type DrawingToolType = "horizontalLine" | "verticalLine" | "trendLine" | "rectan
726
754
  interface DrawingPoint {
727
755
  barIndex: number;
728
756
  price: number;
757
+ /** Unix-ms timestamp of the bar at this point — used to re-anchor drawings after data reload. */
758
+ timestamp?: number;
729
759
  }
730
760
  /** A resize handle on a drawing — identifies which point can be dragged */
731
761
  interface DrawingHandle {
@@ -617,6 +617,34 @@ interface ChartConfig {
617
617
  * Default: `2`.
618
618
  */
619
619
  mobileBarDivisor?: 2 | 3 | 4;
620
+ /**
621
+ * Initial number of candles visible when the chart first loads (desktop).
622
+ * On mobile this value is further divided by `mobileBarDivisor` unless
623
+ * `defaultMobileVisibleBars` is also set.
624
+ * Default: `80`.
625
+ *
626
+ * @deprecated Use `targetCandleWidth` instead. The chart will automatically
627
+ * calculate the appropriate number of visible bars based on the canvas width.
628
+ * This option remains as an explicit override when a fixed bar count is needed.
629
+ */
630
+ defaultVisibleBars?: number;
631
+ /**
632
+ * Initial number of candles visible when the chart first loads on
633
+ * touch/mobile devices. When set, overrides the `mobileBarDivisor` logic.
634
+ * Default: `defaultVisibleBars / mobileBarDivisor`.
635
+ *
636
+ * @deprecated Use `targetCandleWidth` instead. The chart will automatically
637
+ * calculate the appropriate number of visible bars based on the canvas width.
638
+ * This option remains as an explicit override when a fixed bar count is needed.
639
+ */
640
+ defaultMobileVisibleBars?: number;
641
+ /**
642
+ * Target pixel width per candle slot used to auto-calculate the initial
643
+ * number of visible bars from the canvas width. Ignored when
644
+ * `defaultVisibleBars` is explicitly provided.
645
+ * Default: `10`.
646
+ */
647
+ targetCandleWidth?: number;
620
648
  /**
621
649
  * Which side of the quote to use for candle close/high/low during live
622
650
  * tick updates. Defaults to `'bid'` (forex convention). Set to `'ask'`
@@ -726,6 +754,8 @@ type DrawingToolType = "horizontalLine" | "verticalLine" | "trendLine" | "rectan
726
754
  interface DrawingPoint {
727
755
  barIndex: number;
728
756
  price: number;
757
+ /** Unix-ms timestamp of the bar at this point — used to re-anchor drawings after data reload. */
758
+ timestamp?: number;
729
759
  }
730
760
  /** A resize handle on a drawing — identifies which point can be dragged */
731
761
  interface DrawingHandle {