@tidal-ts/chart 0.19.0 → 0.22.0

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
@@ -20,8 +20,8 @@ version number.
20
20
  ## Install
21
21
 
22
22
  ```bash
23
- npm install --save-exact @tidal-ts/core @tidal-ts/chart @pond-ts/process@0.75.0
24
- npm install pond-ts@~0.75.0 @pond-ts/financial@~0.75.0 @pond-ts/charts@~0.75.0 @pond-ts/react@~0.75.0
23
+ npm install --save-exact @tidal-ts/core @tidal-ts/chart @pond-ts/process@0.78.0
24
+ npm install pond-ts@~0.78.0 @pond-ts/financial@~0.78.0 @pond-ts/charts@~0.78.0 @pond-ts/react@~0.78.0
25
25
  ```
26
26
 
27
27
  React 18 or 19. The pond packages are peer dependencies: install them once, on
@@ -6,9 +6,9 @@ import { resolveTimeZone, aggregateColumn, hasPairOp, inferBarMs, liveWindowMs,
6
6
  import { candleStyleForColor, candleStyleForPair } from './candleStyle.js';
7
7
  import { useMeasuredWidth } from './useMeasuredWidth.js';
8
8
  import { withAlpha } from './withAlpha.js';
9
- import { FALLBACK_REGISTER, levelRoles, levelsSig, rowLevelMarks, } from './levels.js';
9
+ import { levelRoles, levelsSig, rowLevelMarks } from './levels.js';
10
10
  import { DEFAULT_CHART_SETTINGS } from './chartSettings.js';
11
- import { configAxisId, guideLevels, seriesDrawn, configBand, configOutputs, dashPattern, outputLook, effectiveSplit, seriesAxisId, seriesLineDashArray, seriesLineWidth, isCompareSide, readsCompare, sharedAxisId, axisFormat, fractionTicks, outputKey, configColumns, } from './series.js';
11
+ import { configAxisId, guideLevels, seriesDrawn, configBand, configOutputs, dashPattern, outputLook, effectiveSplit, seriesAxisId, seriesLineDashArray, seriesLineWidth, isCompareSide, drawsAsCompare, sharedAxisId, axisFormat, fractionTicks, outputKey, configColumns, } from './series.js';
12
12
  /** The schema-erased series type every layer reads. Rows carry heterogeneous
13
13
  * sources (vol `%`, price `$`), so the chart works in the erased schema and each
14
14
  * config names its `column`. Callers build the {@link TimeSeriesChartProps.sources} map
@@ -343,10 +343,10 @@ function TimeSeriesChartInner({ rows, sources, ohlcSources = EMPTY_SOURCES, cale
343
343
  const marks = configOutputs(c)
344
344
  .map((o) => o.mark[0])
345
345
  .join('');
346
- // Which SIDE of a comparison it reads: the dash (`readsCompare`) and
346
+ // Which SIDE of a comparison it reads: the dash (`drawsAsCompare`) and
347
347
  // the before ink (`isCompareSide`) both turn on the column and spec,
348
348
  // which a study re-pointed at the other symbol changes under one id.
349
- const side = `${readsCompare(c) ? 'c' : ''}${isCompareSide(c) ? 's' : ''}`;
349
+ const side = `${drawsAsCompare(c) ? 'c' : ''}${isCompareSide(c) ? 's' : ''}`;
350
350
  return `${c.id}:${side}:${c.color}:${sp.mode}:${sp.rise}:${sp.fall}:${c.style}:${seriesLineWidth(c, settings)}:${c.lineDash ?? ''}:${c.opacity ?? ''}:${c.fan?.join(',') ?? ''}:${marks}:${c.outputStyles ? JSON.stringify(c.outputStyles) : ''}`;
351
351
  })
352
352
  .join('|') +
@@ -401,12 +401,19 @@ function TimeSeriesChartInner({ rows, sources, ohlcSources = EMPTY_SOURCES, cale
401
401
  };
402
402
  // Area fill wants a solid hex for its gradient, so dim via fillOpacity (not
403
403
  // an rgba fill); the outline still carries the dim.
404
+ //
405
+ // The outline takes the series' dash exactly as a line does (charts
406
+ // 0.78 `AreaStyle.dash` dashes the top edge, never the fill). That is
407
+ // what lets a comparison keep an area as an area: the compared side is
408
+ // the same shape with a dashed rim, the "before" of before / after. A
409
+ // user-picked texture on an area reaches the canvas by the same road.
404
410
  area[c.id] = {
405
411
  ...base.area.default,
406
412
  color,
407
413
  width,
408
414
  fill: stroke,
409
415
  fillOpacity: (isDim ? 0.04 : 0.14) * own,
416
+ ...(dash ? { dash: [...dash] } : {}),
410
417
  };
411
418
  // A band is a WASH, not a fill under a line: it carries no outline of its
412
419
  // own (the middle band draws that, as an ordinary line under the same
@@ -477,11 +484,11 @@ function TimeSeriesChartInner({ rows, sources, ohlcSources = EMPTY_SOURCES, cale
477
484
  // `dash` survives: hue is the user's, texture stays ours (it is what tells
478
485
  // the two kinds apart).
479
486
  // Host levels (`TimeSeriesChartRow.levels`) take the same route, one role
480
- // per level. A base theme with no register would leave their roles
481
- // nowhere to live, so they fall back to a copy of charts' own default
482
- // register: the ink every other mark already draws in there.
487
+ // per level. A base theme with no register gets one holding only those
488
+ // roles: charts fills every field it leaves out from `defaultAnnotation`,
489
+ // the ink every other mark already draws in there.
483
490
  const levelRoleMap = levelRoles(rows, resolveColor, dim);
484
- const register = base.annotation ?? (Object.keys(levelRoleMap).length > 0 ? FALLBACK_REGISTER : undefined);
491
+ const register = base.annotation ?? (Object.keys(levelRoleMap).length > 0 ? {} : undefined);
485
492
  const annotation = register
486
493
  ? {
487
494
  ...register,
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  export { TimeSeriesChart, annotationInView, type ChartAnnotation, type ChartStats, type TimeSeriesChartProps, type TimeSeriesChartRow, } from './TimeSeriesChart.js';
15
15
  export type { ChartSeries } from './types.js';
16
16
  export { levelRole, levelRoles, rowLevelMarks, type ChartLevel, type ChartLevelLine, type ChartLevelRange, type ChartLevelStyle, type LevelLineMark, type LevelRoleStyle, type LevelWashMark, } from './levels.js';
17
- export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, isCompareSide, seriesDrawn, seriesCategoryStyle, seriesLineDashArray, seriesLineWidth, sharedAxisId, type AxisRange, effectiveAxisBounds, clampBoundsToLocks, barZeroLock, centerOnZero, axisRangeIsEmpty, axisFormat, fractionTicks, bandColumns, configBand, configColumns, configOutputs, configSpecs, dashPattern, fanIsBand, LINE_DASHES, OUTPUT_DASHES, outputKey, outputLook, publishedColumns, type ConfigOutput, type OutputLook, type OutputStyle, hasBarOutput, offersOutputBars, logAllowed, AXIS_PRECISIONS, type PairJoinOp, type PairLensOp, type SeriesGroup, type PairPartView, type PairView, type SeriesBinding, type SeriesConfig, type SeriesAxis, type SeriesStyle, type SeriesWindow, type CandleVariant, type ColorBy, readsFrom, sourcesOf, } from './series.js';
17
+ export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, drawsAsCompare, isCompareSide, seriesDrawn, seriesCategoryStyle, seriesLineDashArray, seriesLineWidth, sharedAxisId, type AxisRange, effectiveAxisBounds, clampBoundsToLocks, barZeroLock, centerOnZero, axisRangeIsEmpty, axisFormat, fractionTicks, bandColumns, configBand, configColumns, configOutputs, configSpecs, dashPattern, fanIsBand, LINE_DASHES, OUTPUT_DASHES, outputKey, outputLook, publishedColumns, type ConfigOutput, type OutputLook, type OutputStyle, hasBarOutput, offersOutputBars, logAllowed, AXIS_PRECISIONS, type PairJoinOp, type PairLensOp, type SeriesGroup, type PairPartView, type PairView, type SeriesBinding, type SeriesConfig, type SeriesAxis, type SeriesStyle, type SeriesWindow, type CandleVariant, type ColorBy, readsFrom, sourcesOf, } from './series.js';
18
18
  export { DEFAULT_CHART_SETTINGS, mergeChartSettings, type AnnotationOverride, type ChartSettings, type CategoryLineStyle, type SessionDividers, type SplitColorDefault, type LineDash, } from './chartSettings.js';
19
19
  export { useMeasuredWidth, useMeasuredSize } from './useMeasuredWidth.js';
20
20
  export { assembleRows, carries, foldKey, foldSources, foldSourcesReport, type SourceFoldReport, prepareChart, sourceFacts, type ConfigRow, type PreparedRow, type SourceFacts, type SourceHold, type SourceInput, type SourceInputs, } from './prepare.js';
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  */
14
14
  export { TimeSeriesChart, annotationInView, } from './TimeSeriesChart.js';
15
15
  export { levelRole, levelRoles, rowLevelMarks, } from './levels.js';
16
- export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, isCompareSide, seriesDrawn, seriesCategoryStyle, seriesLineDashArray, seriesLineWidth, sharedAxisId, effectiveAxisBounds, clampBoundsToLocks, barZeroLock, centerOnZero, axisRangeIsEmpty, axisFormat, fractionTicks, bandColumns, configBand, configColumns, configOutputs, configSpecs, dashPattern, fanIsBand, LINE_DASHES, OUTPUT_DASHES, outputKey, outputLook, publishedColumns, hasBarOutput, offersOutputBars, logAllowed, AXIS_PRECISIONS, readsFrom, sourcesOf, } from './series.js';
16
+ export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, drawsAsCompare, isCompareSide, seriesDrawn, seriesCategoryStyle, seriesLineDashArray, seriesLineWidth, sharedAxisId, effectiveAxisBounds, clampBoundsToLocks, barZeroLock, centerOnZero, axisRangeIsEmpty, axisFormat, fractionTicks, bandColumns, configBand, configColumns, configOutputs, configSpecs, dashPattern, fanIsBand, LINE_DASHES, OUTPUT_DASHES, outputKey, outputLook, publishedColumns, hasBarOutput, offersOutputBars, logAllowed, AXIS_PRECISIONS, readsFrom, sourcesOf, } from './series.js';
17
17
  export { DEFAULT_CHART_SETTINGS, mergeChartSettings, } from './chartSettings.js';
18
18
  export { useMeasuredWidth, useMeasuredSize } from './useMeasuredWidth.js';
19
19
  export { assembleRows, carries, foldKey, foldSources, foldSourcesReport, prepareChart, sourceFacts, } from './prepare.js';
package/dist/levels.d.ts CHANGED
@@ -10,47 +10,42 @@
10
10
  * level outside the window is off the plot. A level that should be on screen
11
11
  * is the host's to frame (`axisOptions`).
12
12
  *
13
- * Library friction, recorded here for upstream (charts' annotation register):
13
+ * How it meets charts' annotation register:
14
14
  *
15
- * 1. **No per-mark ink.** `<Baseline>` / `<Zone>` take colour and dash only from
16
- * `theme.annotation.roles[role]` ("colour is a theme concern"). Each level
17
- * therefore gets its own role ({@link levelRole}), folded into the theme by
18
- * {@link levelRoles} — the same route `ChartAnnotation.color` takes.
19
- * 2. **No stroke width.** A baseline is always 1px, and a role cannot change
20
- * it. So a level takes no `lineWidth` yet; adding one that is silently
21
- * ignored would be worse than leaving it out.
22
- * 3. **An inert mark is always at the back.** `selectable={false}` paints at
23
- * the register's `depth[2]` (0.4 in charts' shipped themes), and a role
24
- * cannot override depth. A level's `opacity` is folded into its colour, so
25
- * the line reads at `opacity × depth[2]`, as the guides and the date
26
- * markers do. A host wanting a level at full strength today has to raise
27
- * `depth[2]` for every mark. Asked for: a per-role depth, or a per-mark
28
- * opacity.
29
- * 4. **A baseline's chip is not culled.** The line is clipped to the row, but
30
- * `<Baseline>` places its label chip at the line's y with no clamp (`<Zone>`
31
- * clamps, `<Marker>` culls). So a LABELLED level panned or pinned off the
32
- * axis prints its chip over the next row or the time axis. Culling it here
33
- * would need the axis domain, which the chart does not hold. Asked for: cull
34
- * or clamp the chip like the rest of the family. Until then, label sparingly.
35
- * 5. **The default register is private.** A base theme with no `annotation`
36
- * makes charts draw in its internal default, which is not exported. The
37
- * level roles need a register to live in, so {@link FALLBACK_REGISTER}
38
- * copies it, and adding a level does not recolour every other mark.
15
+ * - **Ink by role.** `<Baseline>` / `<Zone>` take colour from
16
+ * `theme.annotation.roles[role]` ("colour is a theme concern"), so each level
17
+ * gets its own role ({@link levelRole}), folded into the theme by
18
+ * {@link levelRoles}, the same route `ChartAnnotation.color` takes. The role
19
+ * carries the level's dash, `lineWidth` and wash too.
20
+ * - **`opacity` is the line's opacity.** An inert mark paints at its role's
21
+ * `depth[2]`, so each level's role sets its depth to `[1, 1, 1]`: the line
22
+ * reads at the level's own `opacity`, not at that times the register's
23
+ * resting depth (0.4 in charts' themes) as it did before charts 0.76.
24
+ * - **A chip stays in its row.** Since charts 0.77 `<Baseline>` hides a line
25
+ * and its chip when the value is off the visible y-range, and keeps a chip
26
+ * near the edge inside the row.
27
+ * - **A bare theme keeps its ink.** A theme with no `annotation` gets one
28
+ * holding only the level roles; charts fills the rest from its
29
+ * `defaultAnnotation`, which is what it drew in anyway.
30
+ *
31
+ * Still open upstream: no per-mark colour prop, so a level is one theme role.
39
32
  *
40
33
  * @module
41
34
  */
42
35
  import { type SeriesConfig } from './series.js';
43
36
  import type { LineDash } from './chartSettings.js';
44
- import type { ChartTheme } from '@pond-ts/charts';
45
37
  /** How a level draws. Every field but `color` is optional. */
46
38
  export interface ChartLevelStyle {
47
39
  /** A palette key (resolved by the chart's `resolveColor`) or raw CSS. */
48
40
  color: string;
49
41
  /** Texture. Omitted ⇒ `solid`, whatever the theme's register dash is. */
50
42
  lineDash?: LineDash;
51
- /** `0..1`, folded into the colour. Composes with the register's resting
52
- * depth (see the module note) and with the series' dimming. */
43
+ /** `0..1`, folded into the colour: the line's own opacity (see the module
44
+ * note). Composes with the series' dimming. Omitted ⇒ `1`. */
53
45
  opacity?: number;
46
+ /** Stroke width in px, for the line (or both edges of a range). Omitted ⇒
47
+ * the theme's annotation `lineWidth`, else `1`. */
48
+ lineWidth?: number;
54
49
  }
55
50
  /** Shared by both kinds. */
56
51
  interface ChartLevelBase extends ChartLevelStyle {
@@ -92,12 +87,6 @@ export interface ChartLevelRange extends ChartLevelBase {
92
87
  export type ChartLevel = ChartLevelLine | ChartLevelRange;
93
88
  /** The theme role a level draws in. Unique per (row, level id). */
94
89
  export declare const levelRole: (rowId: string, levelId: string) => string;
95
- /**
96
- * charts' internal annotation register (`DEFAULT_ANNOTATION`, not exported):
97
- * what a base theme with no `annotation` draws in. The chart supplies it only
98
- * when it must add level roles, so the guides and date markers keep their ink.
99
- */
100
- export declare const FALLBACK_REGISTER: NonNullable<ChartTheme['annotation']>;
101
90
  /** One `<Baseline>` to draw. */
102
91
  export interface LevelLineMark {
103
92
  key: string;
@@ -132,6 +121,10 @@ export declare function rowLevelMarks(levels: readonly ChartLevel[] | undefined,
132
121
  export interface LevelRoleStyle {
133
122
  color: string;
134
123
  dash: readonly number[];
124
+ /** Always `[1, 1, 1]`: an inert mark paints at `depth[2]`, and a level's
125
+ * strength is its `opacity`, already in `color`. */
126
+ depth: readonly [number, number, number];
127
+ lineWidth?: number;
135
128
  fillOpacity?: number;
136
129
  }
137
130
  /**
@@ -139,7 +132,8 @@ export interface LevelRoleStyle {
139
132
  * colour is resolved and carries the level's `opacity` (and the chart's
140
133
  * dimming, when the series it rides on is dimmed, at the same `0.22` a series
141
134
  * takes). `dash` is always stated, so a `solid` level stays solid on a theme
142
- * whose register is dashed.
135
+ * whose register is dashed, and `depth` is always `[1, 1, 1]`, so the line
136
+ * reads at that colour. `lineWidth` is set only when the level gives one.
143
137
  */
144
138
  export declare function levelRoles(rows: readonly {
145
139
  id: string;
package/dist/levels.js CHANGED
@@ -10,32 +10,25 @@
10
10
  * level outside the window is off the plot. A level that should be on screen
11
11
  * is the host's to frame (`axisOptions`).
12
12
  *
13
- * Library friction, recorded here for upstream (charts' annotation register):
13
+ * How it meets charts' annotation register:
14
14
  *
15
- * 1. **No per-mark ink.** `<Baseline>` / `<Zone>` take colour and dash only from
16
- * `theme.annotation.roles[role]` ("colour is a theme concern"). Each level
17
- * therefore gets its own role ({@link levelRole}), folded into the theme by
18
- * {@link levelRoles} — the same route `ChartAnnotation.color` takes.
19
- * 2. **No stroke width.** A baseline is always 1px, and a role cannot change
20
- * it. So a level takes no `lineWidth` yet; adding one that is silently
21
- * ignored would be worse than leaving it out.
22
- * 3. **An inert mark is always at the back.** `selectable={false}` paints at
23
- * the register's `depth[2]` (0.4 in charts' shipped themes), and a role
24
- * cannot override depth. A level's `opacity` is folded into its colour, so
25
- * the line reads at `opacity × depth[2]`, as the guides and the date
26
- * markers do. A host wanting a level at full strength today has to raise
27
- * `depth[2]` for every mark. Asked for: a per-role depth, or a per-mark
28
- * opacity.
29
- * 4. **A baseline's chip is not culled.** The line is clipped to the row, but
30
- * `<Baseline>` places its label chip at the line's y with no clamp (`<Zone>`
31
- * clamps, `<Marker>` culls). So a LABELLED level panned or pinned off the
32
- * axis prints its chip over the next row or the time axis. Culling it here
33
- * would need the axis domain, which the chart does not hold. Asked for: cull
34
- * or clamp the chip like the rest of the family. Until then, label sparingly.
35
- * 5. **The default register is private.** A base theme with no `annotation`
36
- * makes charts draw in its internal default, which is not exported. The
37
- * level roles need a register to live in, so {@link FALLBACK_REGISTER}
38
- * copies it, and adding a level does not recolour every other mark.
15
+ * - **Ink by role.** `<Baseline>` / `<Zone>` take colour from
16
+ * `theme.annotation.roles[role]` ("colour is a theme concern"), so each level
17
+ * gets its own role ({@link levelRole}), folded into the theme by
18
+ * {@link levelRoles}, the same route `ChartAnnotation.color` takes. The role
19
+ * carries the level's dash, `lineWidth` and wash too.
20
+ * - **`opacity` is the line's opacity.** An inert mark paints at its role's
21
+ * `depth[2]`, so each level's role sets its depth to `[1, 1, 1]`: the line
22
+ * reads at the level's own `opacity`, not at that times the register's
23
+ * resting depth (0.4 in charts' themes) as it did before charts 0.76.
24
+ * - **A chip stays in its row.** Since charts 0.77 `<Baseline>` hides a line
25
+ * and its chip when the value is off the visible y-range, and keeps a chip
26
+ * near the edge inside the row.
27
+ * - **A bare theme keeps its ink.** A theme with no `annotation` gets one
28
+ * holding only the level roles; charts fills the rest from its
29
+ * `defaultAnnotation`, which is what it drew in anyway.
30
+ *
31
+ * Still open upstream: no per-mark colour prop, so a level is one theme role.
39
32
  *
40
33
  * @module
41
34
  */
@@ -43,16 +36,6 @@ import { configAxisId, dashPattern } from './series.js';
43
36
  import { withAlpha } from './withAlpha.js';
44
37
  /** The theme role a level draws in. Unique per (row, level id). */
45
38
  export const levelRole = (rowId, levelId) => `level\u0000${rowId}\u0000${levelId}`;
46
- /**
47
- * charts' internal annotation register (`DEFAULT_ANNOTATION`, not exported):
48
- * what a base theme with no `annotation` draws in. The chart supplies it only
49
- * when it must add level roles, so the guides and date markers keep their ink.
50
- */
51
- export const FALLBACK_REGISTER = {
52
- color: '#14b8a6',
53
- fillOpacity: 0.1,
54
- depth: [1, 0.7, 0.4],
55
- };
56
39
  /**
57
40
  * What a row's host levels draw: one line per level, two per range, and a
58
41
  * wash per range with a `fill`. Only levels whose `series` is in `drawn` (the
@@ -106,13 +89,16 @@ export function rowLevelMarks(levels, drawn, rowId, isLog = () => false) {
106
89
  }
107
90
  return { lines, washes };
108
91
  }
92
+ /** A level's depth ramp: every level at full strength, so `opacity` rules. */
93
+ const LEVEL_DEPTH = [1, 1, 1];
109
94
  const unit = (o) => typeof o === 'number' && Number.isFinite(o) ? Math.min(1, Math.max(0, o)) : 1;
110
95
  /**
111
96
  * The theme roles every host level draws in, keyed by {@link levelRole}. Its
112
97
  * colour is resolved and carries the level's `opacity` (and the chart's
113
98
  * dimming, when the series it rides on is dimmed, at the same `0.22` a series
114
99
  * takes). `dash` is always stated, so a `solid` level stays solid on a theme
115
- * whose register is dashed.
100
+ * whose register is dashed, and `depth` is always `[1, 1, 1]`, so the line
101
+ * reads at that colour. `lineWidth` is set only when the level gives one.
116
102
  */
117
103
  export function levelRoles(rows, resolveColor, dimmed = new Set()) {
118
104
  const out = {};
@@ -123,6 +109,10 @@ export function levelRoles(rows, resolveColor, dimmed = new Set()) {
123
109
  out[levelRole(r.id, l.id)] = {
124
110
  color: withAlpha(resolveColor(l.color), alpha),
125
111
  dash: dash ? [...dash] : [],
112
+ depth: LEVEL_DEPTH,
113
+ ...(typeof l.lineWidth === 'number' && Number.isFinite(l.lineWidth) && l.lineWidth > 0
114
+ ? { lineWidth: l.lineWidth }
115
+ : {}),
126
116
  ...(l.kind === 'range' && l.fill !== undefined && l.fill > 0
127
117
  ? { fillOpacity: unit(l.fill) }
128
118
  : {}),
@@ -134,6 +124,6 @@ export function levelRoles(rows, resolveColor, dimmed = new Set()) {
134
124
  /** The theme-shaping fields of every row's levels, as one memo key. */
135
125
  export function levelsSig(rows) {
136
126
  return rows
137
- .flatMap((r) => (r.levels ?? []).map((l) => `${r.id}\u0000${l.id}\u0000${l.series}\u0000${l.color}\u0000${l.lineDash ?? ''}\u0000${l.opacity ?? ''}\u0000${l.kind === 'range' ? (l.fill ?? '') : ''}`))
127
+ .flatMap((r) => (r.levels ?? []).map((l) => `${r.id}\u0000${l.id}\u0000${l.series}\u0000${l.color}\u0000${l.lineDash ?? ''}\u0000${l.opacity ?? ''}\u0000${l.lineWidth ?? ''}\u0000${l.kind === 'range' ? (l.fill ?? '') : ''}`))
138
128
  .join('|');
139
129
  }
package/dist/series.d.ts CHANGED
@@ -125,7 +125,7 @@ export declare function configColumns(c: {
125
125
  fan?: readonly string[];
126
126
  bandMiddle?: boolean;
127
127
  }): string[];
128
- import type { DeriveSpec, SeriesWindow } from '@tidal-ts/core';
128
+ import type { DeriveSpec, PairOp, SeriesWindow } from '@tidal-ts/core';
129
129
  export type { DeriveSpec, SeriesWindow };
130
130
  import type { CandleVariant, ColorBy } from '@pond-ts/charts';
131
131
  export type { CandleVariant, ColorBy };
@@ -299,6 +299,21 @@ export interface SeriesConfig {
299
299
  * Oscillator) is `style: 'bar'`, and becomes a line by its `style`.
300
300
  */
301
301
  outputBars?: boolean;
302
+ /**
303
+ * The function a **compare** applies to this metric and the same metric on
304
+ * the comparison symbol — `ratio` reads `A / B`. Set on the ROOT of a chain
305
+ * (a metric, never a study), it joins the two into ONE line and every study
306
+ * on the metric runs on that joined line: `sma(close)` draws as
307
+ * `sma(ratio(close, cmp_close))`.
308
+ *
309
+ * It is a setting about how to read a comparison, so with no comparison named
310
+ * it SLEEPS: the chain draws on the primary alone, and the function comes
311
+ * back with the next comparison. Absent ⇒ no function: under a comparison the
312
+ * metric draws twice, once per symbol. The host does the rewriting at render
313
+ * time; the config itself keeps its own spec, so clearing the function, or
314
+ * the comparison, has nothing to restore.
315
+ */
316
+ compareFn?: PairOp;
302
317
  }
303
318
  /** The textures in display order. */
304
319
  export declare const LINE_DASHES: readonly LineDash[];
@@ -610,6 +625,15 @@ export declare function isStudySeries(s: SeriesConfig): boolean;
610
625
  /** True if a series reads the COMPARISON symbol — a spec whose leaves are
611
626
  * `cmp_`-prefixed, or (an unjoined pair's leg) a raw `cmp_` column. */
612
627
  export declare function readsCompare(s: Pick<SeriesConfig, 'derive' | 'column'>): boolean;
628
+ /**
629
+ * True if a series draws in the **comparison texture** — it reads the
630
+ * comparison symbol and is not a JOINED reading of both. A spread such as
631
+ * `ratio(iv21, cmp_iv21)`, and any study run on one, is one derived reading OF
632
+ * both symbols rather than the secondary line, so it draws as an ordinary
633
+ * metric or study: the dash says "the other symbol", and a spread is not that
634
+ * (TDL-SPREADINK).
635
+ */
636
+ export declare function drawsAsCompare(s: Pick<SeriesConfig, 'derive' | 'column'>): boolean;
613
637
  /**
614
638
  * True if a series is the **compared side** of a comparison: every leaf it
615
639
  * reads is on the comparison symbol (a raw `cmp_` column, or a study whose
package/dist/series.js CHANGED
@@ -151,7 +151,7 @@ export function configColumns(c) {
151
151
  // `@tidal-ts/core` (where the windowing + derive seam live) — imported for
152
152
  // `SeriesConfig` below and re-exported so UI code has one import site for the
153
153
  // series vocabulary.
154
- import { BAND_OUTPUTS, BAR_PRICE_COLUMNS, COMPARE_PREFIX, deriveId, inputNames, isPairOp, isPickedInput, isStudyOp, opOutputs, opParams, outputMark, studyLevels, usesCompare, withFanOutput, } from '@tidal-ts/core';
154
+ import { BAND_OUTPUTS, BAR_PRICE_COLUMNS, COMPARE_PREFIX, deriveId, hasPairOp, inputNames, isPairOp, isPickedInput, isStudyOp, opOutputs, opParams, outputMark, studyLevels, usesCompare, withFanOutput, } from '@tidal-ts/core';
155
155
  // The app-wide presentation defaults the category resolvers below read.
156
156
  import { DEFAULT_CHART_SETTINGS, } from './chartSettings.js';
157
157
  /** The textures in display order. */
@@ -416,6 +416,17 @@ export function isStudySeries(s) {
416
416
  export function readsCompare(s) {
417
417
  return s.derive ? usesCompare(s.derive) : s.column.startsWith(COMPARE_PREFIX);
418
418
  }
419
+ /**
420
+ * True if a series draws in the **comparison texture** — it reads the
421
+ * comparison symbol and is not a JOINED reading of both. A spread such as
422
+ * `ratio(iv21, cmp_iv21)`, and any study run on one, is one derived reading OF
423
+ * both symbols rather than the secondary line, so it draws as an ordinary
424
+ * metric or study: the dash says "the other symbol", and a spread is not that
425
+ * (TDL-SPREADINK).
426
+ */
427
+ export function drawsAsCompare(s) {
428
+ return readsCompare(s) && !(s.derive && hasPairOp(s.derive));
429
+ }
419
430
  /**
420
431
  * True if a series is the **compared side** of a comparison: every leaf it
421
432
  * reads is on the comparison symbol (a raw `cmp_` column, or a study whose
@@ -443,7 +454,7 @@ function onlyCompare(spec) {
443
454
  * series takes the `comparisons` category (dashed) whatever else it is — the
444
455
  * texture encodes the SYMBOL, so a study of a compare leg is dashed too. */
445
456
  export function seriesCategoryStyle(s, settings) {
446
- if (readsCompare(s))
457
+ if (drawsAsCompare(s))
447
458
  return settings.comparisons;
448
459
  return isStudySeries(s) ? settings.derived : settings.metrics;
449
460
  }
@@ -463,7 +474,7 @@ export function dashPattern(dash) {
463
474
  * category's style. A comparison-reading series always takes its category's:
464
475
  * there the texture is not decoration but the symbol it reads. */
465
476
  export function seriesLineDashArray(s, settings = DEFAULT_CHART_SETTINGS) {
466
- if (s.lineDash && !readsCompare(s))
477
+ if (s.lineDash && !drawsAsCompare(s))
467
478
  return dashPattern(s.lineDash);
468
479
  return dashPattern(seriesCategoryStyle(s, settings).dash);
469
480
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidal-ts/chart",
3
- "version": "0.19.0",
3
+ "version": "0.22.0",
4
4
  "private": false,
5
5
  "description": "TimeSeriesChart — a multi-row time-series chart on @pond-ts/charts, plus the series and settings vocabulary and the prepare step. Theme, colours and settings arrive as props.",
6
6
  "license": "MIT",
@@ -31,20 +31,20 @@
31
31
  "access": "public"
32
32
  },
33
33
  "peerDependencies": {
34
- "@pond-ts/charts": "^0.75.0",
35
- "@pond-ts/financial": "^0.75.0",
36
- "@pond-ts/react": "^0.75.0",
37
- "pond-ts": "^0.75.0",
34
+ "@pond-ts/charts": "^0.78.0",
35
+ "@pond-ts/financial": "^0.78.0",
36
+ "@pond-ts/react": "^0.78.0",
37
+ "pond-ts": "^0.78.0",
38
38
  "react": "^18.2.0 || ^19.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@tidal-ts/core": "0.19.0"
41
+ "@tidal-ts/core": "0.22.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@pond-ts/charts": "^0.75.0",
45
- "@pond-ts/financial": "^0.75.0",
46
- "@pond-ts/process": "0.75.0",
47
- "@pond-ts/react": "^0.75.0",
44
+ "@pond-ts/charts": "^0.78.0",
45
+ "@pond-ts/financial": "^0.78.0",
46
+ "@pond-ts/process": "0.78.0",
47
+ "@pond-ts/react": "^0.78.0",
48
48
  "@storybook/addon-essentials": "^8.5.0",
49
49
  "@storybook/react": "^8.5.0",
50
50
  "@storybook/react-vite": "^8.5.0",
@@ -52,7 +52,7 @@
52
52
  "@types/react-dom": "^18.3.5",
53
53
  "@types/react-test-renderer": "^18.3.1",
54
54
  "@vitejs/plugin-react": "^4.3.4",
55
- "pond-ts": "^0.75.0",
55
+ "pond-ts": "^0.78.0",
56
56
  "react": "^18.3.1",
57
57
  "react-dom": "^18.3.1",
58
58
  "react-test-renderer": "^18.3.1",