lightweight-charts-drawing 0.6.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.2 (15/10/2026)
4
+
5
+ ### Changed
6
+
7
+ - Drawing points are on whole bars, as in the reference app: a time between
8
+ two bars (a point drawn on another interval, a time in a gap between
9
+ sessions) is drawn on the bar that holds it, the last bar opening at or
10
+ before it (`timeToX`, `timeToBarIndex`, `timeToXFallback`); it was
11
+ interpolated between the two bars. The stored time is kept, so the point
12
+ comes back to its own bar on its own interval.
13
+ - Drags follow the reference line tool rules: a point that stays on its bar
14
+ keeps its stored time (price-only anchor drags and body moves), a point
15
+ moved to another bar takes that bar's open time (`applyDrag`,
16
+ `translateDrawing`).
17
+
18
+ ### Added
19
+
20
+ - `FutureAxis.pastSlots` / `pastTime` (optional): bars before the first
21
+ loaded bar on the host's trading calendar (whole bars both ways); without
22
+ them, calendar time with the median bar interval as before.
23
+ - `FutureAxis.timeKey` (optional): where a time sits when the bar that holds
24
+ it is looked for (a host maps a daily bar time to its session open).
25
+ - `FutureAxis` exported from the package entry.
26
+ - Unit tests (`npm test`, vitest).
27
+
28
+ ## 0.6.1 (15/10/2026)
29
+
30
+ ### Added
31
+
32
+ - `makeCoords(..., getFuture)` (optional 6th argument, `FutureAxis`): bars
33
+ after the last bar on the symbol's trading calendar, given by the host
34
+ (`slots(time, lastTime)`, `time(k, lastTime)`). With it a point placed after
35
+ the last bar takes the open time of its nearest future bar, a future time is
36
+ drawn on the future bar that holds it (`timeToX`, `xToTime`,
37
+ `timeToBarIndex`, `barIndexToTime`, `timeToXFallback`). Without it, calendar
38
+ time with the median bar interval as before.
39
+
3
40
  ## 0.6.0 (13/10/2026)
4
41
 
5
42
  ### Added
package/dist/index.d.ts CHANGED
@@ -692,6 +692,28 @@ declare type FourPoint = {
692
692
  * finalized with a double-click (the spec carries `variableLength: true`). */
693
693
  declare type FreehandKind = "polyline" | "path" | "brush" | "highlighter";
694
694
 
695
+ /** The symbol's trading calendar around the loaded bars (the host knows the sessions). The time scale continues
696
+ * after the last bar with the bars the symbol would open: the rest of the session, then the next sessions (nights,
697
+ * weekends and holidays skipped); before the first loaded bar it counts the bars the symbol had. Times are epoch
698
+ * seconds. A time is drawn on the bar that holds it (the last bar opening at or before it). */
699
+ export declare type FutureAxis = {
700
+ /** Future bars that open after `lastTime` and at or before `time` (0 = still on the last bar). */
701
+ slots: (time: number, lastTime: number) => number;
702
+ /** Open time of the k-th future bar (k >= 1), null past the host's range. */
703
+ time: (k: number, lastTime: number) => number | null;
704
+ /** Bars from the bar that holds `time` to the first loaded bar (opening at `firstTime`), that bar counted
705
+ * (>= 1 for a time before the first bar). Absent = calendar time with the median bar interval. */
706
+ pastSlots?: (time: number, firstTime: number) => number;
707
+ /** Open time of the k-th bar before the first loaded bar (k >= 1), null past the host's range. Give it with
708
+ * `pastSlots`. */
709
+ pastTime?: (k: number, firstTime: number) => number | null;
710
+ /** Where a time sits when the bar that holds it is looked for, non-decreasing over the bar times. The host maps a
711
+ * daily bar time to its session open (the reference opens a daily bar there: a pre-market time belongs to the
712
+ * previous daily bar, a point drawn on a daily bar goes to the first intraday bar of its day). Identity when
713
+ * absent. */
714
+ timeKey?: (time: number) => number;
715
+ };
716
+
695
717
  /** One regression trend line (TV study plot style). */
696
718
  /** Gann level line (TV levels.N: color, width, visible). */
697
719
  declare type GannLine = {
@@ -817,7 +839,9 @@ export declare function makeCoords(chart: IChartApi, series: ISeriesApi<SeriesTy
817
839
  getIndicatorValues?: (sec: number | null) => number[], getTimeInfo?: () => {
818
840
  timeZone: string;
819
841
  intraday: boolean;
820
- }): Coords;
842
+ },
843
+ /** Future bars on the trading calendar; null (or absent) = calendar time extrapolated with the bar interval. */
844
+ getFuture?: () => FutureAxis | null): Coords;
821
845
 
822
846
  /** Point-count migration (10/07/2026): several kinds moved to TV's point
823
847
  * models. Old saved drawings are padded/synthesized best-effort so they keep
@@ -1286,9 +1310,10 @@ export declare type TimeAxisLabel = {
1286
1310
 
1287
1311
  /** Shared time→x with the off-bar fallback, for non-drawing renderers (event
1288
1312
  * markers, etc.) that paint at arbitrary times. Mirrors the `timeToX` method:
1289
- * try lightweight-charts' exact mapping first, then the gap-aware logical
1290
- * interpolation. `sec` is UNIX seconds. Returns null with no data. */
1291
- export declare function timeToXFallback(chart: IChartApi, sec: number, bars: OHLC[]): number | null;
1313
+ * try lightweight-charts' exact mapping first, then the bar that holds the
1314
+ * time (off the loaded bars: the host's calendar `future` when given).
1315
+ * `sec` is UNIX seconds. Returns null with no data. */
1316
+ export declare function timeToXFallback(chart: IChartApi, sec: number, bars: OHLC[], future?: FutureAxis | null): number | null;
1292
1317
 
1293
1318
  /** TV _onAnchoredChange: anchoring stores the current screen point as pane
1294
1319
  * fractions; unanchoring turns the fixed point back into a data point (bar