@tidal-ts/chart 0.27.0 → 0.29.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.
@@ -8,7 +8,7 @@ import { useMeasuredWidth } from './useMeasuredWidth.js';
8
8
  import { withAlpha } from './withAlpha.js';
9
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, drawsAsCompare, sharedAxisId, axisFormat, fractionTicks, outputKey, configColumns, } from './series.js';
11
+ import { configAxisId, guideLevels, seriesDrawn, configBand, configOutputs, dashPattern, outputLook, effectiveSplit, seriesAxisId, seriesLineDashArray, seriesLineWidth, seriesOpacity, compareStyleOf, 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
@@ -347,7 +347,7 @@ function TimeSeriesChartInner({ rows, sources, ohlcSources = EMPTY_SOURCES, cale
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
349
  const side = `${drawsAsCompare(c) ? 'c' : ''}${isCompareSide(c) ? 's' : ''}`;
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) : ''}`;
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) : ''}:${c.compareStyle ? JSON.stringify(c.compareStyle) : ''}`;
351
351
  })
352
352
  .join('|') +
353
353
  '#' +
@@ -378,13 +378,16 @@ function TimeSeriesChartInner({ rows, sources, ohlcSources = EMPTY_SOURCES, cale
378
378
  // The compared side draws in the host's BEFORE ink (`compareInk`); every
379
379
  // other series in its own. Its outputs follow it, so a study on the
380
380
  // compared leg is "before" too.
381
- const before = compareInk !== undefined && isCompareSide(c);
381
+ // A colour picked for the one compared line (`compareStyle.color`)
382
+ // overrides the theme's before ink, as it does the config's own.
383
+ const picked = compareStyleOf(c)?.color;
384
+ const before = !picked && compareInk !== undefined && isCompareSide(c);
382
385
  const inkOf = (color) => (before ? compareInk : resolveColor(color));
383
- const stroke = inkOf(c.color);
386
+ const stroke = inkOf(picked ?? c.color);
384
387
  const isDim = dim.has(c.id);
385
388
  // The user's opacity and the chart's dimming compose: a half-opaque line
386
389
  // that is also dimmed is fainter still, never back to full strength.
387
- const own = opacityOf(c.opacity);
390
+ const own = opacityOf(seriesOpacity(c));
388
391
  const alpha = own * (isDim ? 0.22 : 1);
389
392
  const color = withAlpha(stroke, alpha);
390
393
  const width = seriesLineWidth(c, settings);
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, 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 CompareWith, compareWithInput, 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, seriesOpacity, compareStyleOf, 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 CompareWith, compareWithInput, 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, 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, compareWithInput, 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, seriesOpacity, compareStyleOf, 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, compareWithInput, 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/prepare.js CHANGED
@@ -1,4 +1,4 @@
1
- import { applyDerivedReport, COMPARE_PREFIX, holdAcrossGrid, isPinnableSymbol, pinnedPrefix, readsColumn, readsPrefix, } from '@tidal-ts/core';
1
+ import { applyDerivedReport, COMPARE_PREFIX, holdAcrossGrid, lastInEachGrain, otherPrefixOf, parseOtherPrefix, pinnedPrefix, readsColumn, } from '@tidal-ts/core';
2
2
  import { configColumns, configSpecs } from './series.js';
3
3
  import { finiteColumns, lastRow } from './seriesFacts.js';
4
4
  /** The series with one row per key, the last of each run: a restatement
@@ -19,35 +19,93 @@ const specsBySource = (configs) => {
19
19
  (m[c.source] ??= []).push(...configSpecs(c));
20
20
  return m;
21
21
  };
22
- /** Per source, the RAW compare columns its configs read, sorted: what decides
23
- * which joins a spec-less config needs (the comparison's, a locked symbol's). */
24
- const rawCompareColumns = (configs) => {
22
+ /** Per source, the RAW columns its configs read on another reading (another
23
+ * symbol, another source; `otherPrefixOf`), sorted: what decides which joins
24
+ * a spec-less config needs. A split pair's leg carries no spec at all but
25
+ * needs the compare join exactly as a compare-bound spec does. (Asking only
26
+ * the specs left such a leg reading a column nothing ever joined on: it drew
27
+ * nothing and, having no `derive`, was filtered out of the panel too — an
28
+ * invisible, unremovable leg.) */
29
+ const rawOtherColumns = (configs) => {
25
30
  const m = {};
26
31
  for (const c of configs)
27
- if (c.source && !c.derive && c.column.startsWith(COMPARE_PREFIX))
32
+ if (c.source && !c.derive && otherPrefixOf(c.column) !== null)
28
33
  (m[c.source] ??= new Set()).add(c.column);
29
34
  return Object.fromEntries(Object.keys(m)
30
35
  .sort()
31
36
  .map((k) => [k, [...m[k]].sort()]));
32
37
  };
33
- /** Sources with a config reading a RAW compare column — a split pair's leg,
34
- * which carries no spec at all but needs the compare join exactly as a
35
- * compare-bound spec does. (Asking only the specs left such a leg reading a
36
- * column nothing ever joined on: it drew nothing and, having no `derive`, was
37
- * filtered out of the panel too — an invisible, unremovable leg.) */
38
- const rawCompareSources = (configs) => Object.entries(rawCompareColumns(configs))
39
- .filter(([, cols]) => cols.some(readsComparison))
40
- .map(([source]) => source);
38
+ /** The other readings a source's configs read, by the prefix their columns
39
+ * carry: one join each. */
40
+ function prefixesRead(raw, specs) {
41
+ const asked = new Set();
42
+ const note = (column) => {
43
+ const prefix = otherPrefixOf(column);
44
+ if (prefix)
45
+ asked.add(prefix);
46
+ return false;
47
+ };
48
+ for (const column of raw)
49
+ note(column);
50
+ // `readsColumn` visits every leaf while the test answers false.
51
+ for (const spec of specs)
52
+ readsColumn(spec, note);
53
+ return [...asked].sort();
54
+ }
55
+ /**
56
+ * The series an other-reading prefix names, for source `key`'s fold: a symbol's
57
+ * series (`cmp_`, `cmp_@SPY_`) of this source or of another one (`~vol_`,
58
+ * `cmp_~vol_`), or `undefined` when the host did not hand it over.
59
+ *
60
+ * Another source at another grain is first put on this source's keys, so the
61
+ * as-of join pairs rows exactly:
62
+ *
63
+ * - **Coarser** (daily vol read on one-minute price rows): held across the
64
+ * rows (`holdAcrossGrid`), as it draws. Each minute gets its day, and a day
65
+ * with no row is a gap, where a bare as-of join would carry the last day
66
+ * forward for ever.
67
+ * - **Finer** (one-minute price read on the daily vol rows): its last row in
68
+ * each row's grain (`lastInEachGrain`). Joined at the day's midnight key
69
+ * as it is, each day would take the last minute BEFORE it, the previous
70
+ * day's.
71
+ *
72
+ * At the same grain, or reading itself, it joins as it is.
73
+ */
74
+ function otherSeries(inputs, key, base, prefix) {
75
+ const parsed = parseOtherPrefix(prefix);
76
+ if (!parsed)
77
+ return undefined;
78
+ const input = inputs[key];
79
+ const from = parsed.source === undefined ? input : inputs[parsed.source];
80
+ if (!from)
81
+ return undefined;
82
+ const { symbol } = parsed;
83
+ const series = symbol === ''
84
+ ? from.series
85
+ : symbol === COMPARE_PREFIX
86
+ ? (from.compare ?? undefined)
87
+ : from.pinned?.[symbol.slice(PINNED_ANY.length, -1)];
88
+ if (!series)
89
+ return undefined;
90
+ if (parsed.source === undefined || from === input)
91
+ return series;
92
+ // Two sources at different grains meet on this source's own keys, so the
93
+ // join matches them exactly. `undefined` grain = the axis's, the finest.
94
+ const mine = input.hold?.grainMs;
95
+ const theirs = from.hold?.grainMs;
96
+ if (mine === theirs)
97
+ return series;
98
+ const keys = base.keyColumn().begin.subarray(0, base.length);
99
+ // Coarser: held across these rows for one of ITS grains, as it draws, so a
100
+ // source that stops leaves a gap rather than its last value for ever.
101
+ if (theirs !== undefined && (mine === undefined || theirs > mine))
102
+ return holdAcrossGrid(series, keys, theirs);
103
+ // Finer: its last row in each of these rows' grains.
104
+ return lastInEachGrain(series, keys, mine);
105
+ }
41
106
  /** The prefix every locked symbol's columns share (`cmp_@`), which the
42
107
  * comparison's own columns never start with. */
43
108
  const PINNED_ANY = pinnedPrefix('').slice(0, -1);
44
- /** Whether a column is the bar's COMPARISON's — under the compare prefix but
45
- * not a locked symbol's, which has a join of its own. */
46
- const readsComparison = (column) => column.startsWith(COMPARE_PREFIX) && !column.startsWith(PINNED_ANY);
47
- /** Whether a spec reads the comparison anywhere — `usesCompare` minus the
48
- * locked symbols' columns, so a compare locked to `SPY` does not pull the
49
- * bar's comparison onto the series too. */
50
- const specReadsComparison = (spec) => readsColumn(spec, readsComparison);
51
109
  /**
52
110
  * A stable string of everything {@link foldSources} depends on in the configs —
53
111
  * the specs per source and the raw-compare set — so a host can key its fold
@@ -65,7 +123,7 @@ export function foldKey(configs) {
65
123
  // The raw compare COLUMNS, not just the sources: a raw leg reading a locked
66
124
  // symbol (`cmp_@SPY_close`) needs that symbol's join, which a source already
67
125
  // joining the comparison would not otherwise re-fold for.
68
- return JSON.stringify([sorted, rawCompareColumns(configs)]);
126
+ return JSON.stringify([sorted, rawOtherColumns(configs)]);
69
127
  }
70
128
  /**
71
129
  * The fold: each source, joined with the other symbols' series it reads (its
@@ -90,8 +148,7 @@ export function foldSources(inputs, configs) {
90
148
  */
91
149
  export function foldSourcesReport(inputs, configs) {
92
150
  const specs = specsBySource(configs);
93
- const rawCompare = new Set(rawCompareSources(configs));
94
- const rawColumns = rawCompareColumns(configs);
151
+ const rawColumns = rawOtherColumns(configs);
95
152
  const sources = {};
96
153
  const reports = {};
97
154
  for (const [key, input] of Object.entries(inputs)) {
@@ -101,26 +158,21 @@ export function foldSourcesReport(inputs, configs) {
101
158
  // first, or the join pairs it with nothing and a study counts it as a bar
102
159
  // (the hold alone would only pick the later row after both had happened).
103
160
  const series = input.hold ? lastPerKey(input.series) : input.series;
104
- // The other symbols' series this source's configs read, keyed by the
105
- // prefix their columns carry, for the engine's as-of join (core's
106
- // `applyDerivedReport`). Each only when asked: the comparison when a
107
- // compare-bound spec or a raw compare leg reads it (otherwise the fold's
108
- // own skip leaves the spread as a gap — compare off ⇒ not drawn), a locked
109
- // symbol when a config reads its prefix, so a symbol the host still holds
110
- // but nothing reads any more costs no join. The as-of join takes the latest
111
- // row at or before each of this source's rows, so a restated row on the
112
- // other side resolves to its last version with no `lastPerKey` of its own.
161
+ // The other readings this source's configs read (another symbol, another
162
+ // source, or both), keyed by the prefix their columns carry, for the
163
+ // engine's as-of join (core's `applyDerivedReport`). Each only when asked:
164
+ // the comparison when a compare-bound spec or a raw compare leg reads it
165
+ // (otherwise the fold's own skip leaves the spread as a gap — compare off
166
+ // ⇒ not drawn), a locked symbol or another source when a config reads its
167
+ // prefix, so a series the host still holds but nothing reads any more
168
+ // costs no join. The as-of join takes the latest row at or before each of
169
+ // this source's rows, so a restated row on the other side resolves to its
170
+ // last version with no `lastPerKey` of its own.
113
171
  const others = {};
114
- if (input.compare && (rawCompare.has(key) || mine.some(specReadsComparison)))
115
- others[COMPARE_PREFIX] = input.compare;
116
- for (const symbol of Object.keys(input.pinned ?? {}).sort()) {
117
- if (!isPinnableSymbol(symbol))
118
- continue;
119
- const prefix = pinnedPrefix(symbol);
120
- const asked = (rawColumns[key] ?? []).some((col) => col.startsWith(prefix)) ||
121
- mine.some((spec) => readsPrefix(spec, prefix));
122
- if (asked)
123
- others[prefix] = input.pinned[symbol];
172
+ for (const prefix of prefixesRead(rawColumns[key] ?? [], mine)) {
173
+ const other = otherSeries(inputs, key, series, prefix);
174
+ if (other)
175
+ others[prefix] = other;
124
176
  }
125
177
  const folded = applyDerivedReport(series, mine, undefined, others);
126
178
  const out = input.hold
package/dist/series.d.ts CHANGED
@@ -269,6 +269,19 @@ export interface SeriesConfig {
269
269
  * been told otherwise about.
270
270
  */
271
271
  outputStyles?: Readonly<Record<string, OutputStyle>>;
272
+ /**
273
+ * How this config draws when it draws AS a comparison ({@link drawsAsCompare}
274
+ * — the dashed copy of a metric on the other symbol, or a study on it). Each
275
+ * field overrides that one line's default and nothing else: its weight and
276
+ * texture (else the config's own `lineWidth` for the weight, then the
277
+ * settings' `comparisons` category), its colour (else
278
+ * {@link TimeSeriesChartProps.compareInk} on the compared side, else the
279
+ * config's own) and its opacity (else the config's own). An empty entry
280
+ * changes nothing. Ignored on a series that does not draw as a comparison,
281
+ * so a host may keep it on a metric whose copy it builds by spreading the
282
+ * metric, and the copy picks it up.
283
+ */
284
+ compareStyle?: OutputStyle;
272
285
  /**
273
286
  * The outputs of its multi-output source this study runs on, when it runs on
274
287
  * MORE than one — an SMA of a band's `Upper` and `Lower` is one study drawing
@@ -334,6 +347,12 @@ export interface SeriesConfig {
334
347
  * The other side is read as its own PLAIN output, never its compare — so
335
348
  * two metrics wired to each other, or a metric wired to its own study, form
336
349
  * no cycle.
350
+ *
351
+ * The other config may be on **another source** (ATM vol against realized
352
+ * vol on price). The host rebinds its input under `sourcePrefix(source)`
353
+ * (`~price_close`) before any symbol prefix, and the fold joins that
354
+ * source's raw columns onto the metric's rows; its spec runs there, on the
355
+ * metric's rows, like every other part of a compare.
337
356
  */
338
357
  compareWith?: CompareWith;
339
358
  /**
@@ -716,14 +735,22 @@ export declare function seriesCategoryStyle(s: SeriesConfig, settings: ChartSett
716
735
  /** A series' stroke width: its explicit `lineWidth` override, else its category
717
736
  * default from the settings (metrics vs studies). */
718
737
  export declare function seriesLineWidth(s: SeriesConfig, settings?: ChartSettings): number;
738
+ /** A comparison-drawing series' own {@link SeriesConfig.compareStyle}, or
739
+ * `undefined` on any other series (where the field is ignored). */
740
+ export declare function compareStyleOf(s: SeriesConfig): OutputStyle | undefined;
741
+ /** A series' opacity, `0..1`: a comparison's own (`compareStyle.opacity`),
742
+ * else the config's, else full strength. */
743
+ export declare function seriesOpacity(s: SeriesConfig): number;
719
744
  /** The dash pattern a `'dotted'` line draws with — short enough to read as
720
745
  * dots at every weight the panel offers, spaced so it never reads as a dash. */
721
746
  export declare const DOT_PATTERN: readonly [number, number];
722
747
  /** A texture as a dash pattern — `undefined` for solid. */
723
748
  export declare function dashPattern(dash: LineDash | undefined): readonly [number, number] | undefined;
724
749
  /** A series' dash pattern (`undefined` = solid): its own `lineDash`, else its
725
- * category's style. A comparison-reading series always takes its category's:
726
- * there the texture is not decoration but the symbol it reads. */
750
+ * category's style. A comparison-reading series ignores `lineDash` — there the
751
+ * texture is the symbol it reads, and a copy built by spreading its metric
752
+ * would otherwise inherit the metric's — and takes its category's unless its
753
+ * own `compareStyle` names one: a texture picked for that one line. */
727
754
  export declare function seriesLineDashArray(s: SeriesConfig, settings?: ChartSettings): readonly [number, number] | undefined;
728
755
  /** Dash ladders for a multi-output config's 2nd..Nth line, by default.
729
756
  * Distinguishable at a glance and ordered so a longer dash reads as "further
package/dist/series.js CHANGED
@@ -487,7 +487,17 @@ export function seriesCategoryStyle(s, settings) {
487
487
  /** A series' stroke width: its explicit `lineWidth` override, else its category
488
488
  * default from the settings (metrics vs studies). */
489
489
  export function seriesLineWidth(s, settings = DEFAULT_CHART_SETTINGS) {
490
- return s.lineWidth ?? seriesCategoryStyle(s, settings).weight;
490
+ return compareStyleOf(s)?.lineWidth ?? s.lineWidth ?? seriesCategoryStyle(s, settings).weight;
491
+ }
492
+ /** A comparison-drawing series' own {@link SeriesConfig.compareStyle}, or
493
+ * `undefined` on any other series (where the field is ignored). */
494
+ export function compareStyleOf(s) {
495
+ return s.compareStyle && drawsAsCompare(s) ? s.compareStyle : undefined;
496
+ }
497
+ /** A series' opacity, `0..1`: a comparison's own (`compareStyle.opacity`),
498
+ * else the config's, else full strength. */
499
+ export function seriesOpacity(s) {
500
+ return compareStyleOf(s)?.opacity ?? s.opacity ?? 1;
491
501
  }
492
502
  /** The dash pattern a `'dotted'` line draws with — short enough to read as
493
503
  * dots at every weight the panel offers, spaced so it never reads as a dash. */
@@ -497,10 +507,14 @@ export function dashPattern(dash) {
497
507
  return dash === 'dashed' ? DASH_PATTERN : dash === 'dotted' ? DOT_PATTERN : undefined;
498
508
  }
499
509
  /** A series' dash pattern (`undefined` = solid): its own `lineDash`, else its
500
- * category's style. A comparison-reading series always takes its category's:
501
- * there the texture is not decoration but the symbol it reads. */
510
+ * category's style. A comparison-reading series ignores `lineDash` — there the
511
+ * texture is the symbol it reads, and a copy built by spreading its metric
512
+ * would otherwise inherit the metric's — and takes its category's unless its
513
+ * own `compareStyle` names one: a texture picked for that one line. */
502
514
  export function seriesLineDashArray(s, settings = DEFAULT_CHART_SETTINGS) {
503
- if (s.lineDash && !drawsAsCompare(s))
515
+ if (drawsAsCompare(s))
516
+ return dashPattern(compareStyleOf(s)?.lineDash ?? seriesCategoryStyle(s, settings).dash);
517
+ if (s.lineDash)
504
518
  return dashPattern(s.lineDash);
505
519
  return dashPattern(seriesCategoryStyle(s, settings).dash);
506
520
  }
@@ -542,10 +556,10 @@ export function outputLook(c, index, settings = DEFAULT_CHART_SETTINGS) {
542
556
  : undefined
543
557
  : OUTPUT_DASHES[(index - 1) % OUTPUT_DASHES.length];
544
558
  return {
545
- color: own?.color ?? c.color,
559
+ color: own?.color ?? compareStyleOf(c)?.color ?? c.color,
546
560
  width: own?.lineWidth ?? (lead ? width : Math.max(1, width - 0.5)),
547
561
  ...(dash ? { dash } : {}),
548
- opacity: own?.opacity ?? c.opacity ?? 1,
562
+ opacity: own?.opacity ?? seriesOpacity(c),
549
563
  };
550
564
  }
551
565
  /** The effective direction-coloring of a `bar`/`candle` series: the per-series
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidal-ts/chart",
3
- "version": "0.27.0",
3
+ "version": "0.29.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",
@@ -38,7 +38,7 @@
38
38
  "react": "^18.2.0 || ^19.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@tidal-ts/core": "0.27.0"
41
+ "@tidal-ts/core": "0.29.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@pond-ts/charts": "^0.78.0",