@tidal-ts/chart 0.13.0 → 0.15.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.
@@ -336,8 +336,13 @@ function TimeSeriesChartInner({ rows, sources, ohlcSources = EMPTY_SOURCES, cale
336
336
  .map((c) => {
337
337
  const sp = effectiveSplit(c, settings);
338
338
  // The per-output ink, texture and opacity too — and the FAN, whose
339
- // outputs are what the per-output keys are named after.
340
- return `${c.id}:${c.color}:${sp.mode}:${sp.rise}:${sp.fall}:${c.style}:${seriesLineWidth(c, settings)}:${c.lineDash ?? ''}:${c.opacity ?? ''}:${c.fan?.join(',') ?? ''}:${c.outputStyles ? JSON.stringify(c.outputStyles) : ''}`;
339
+ // outputs are what the per-output keys are named after, and each
340
+ // output's MARK, which says whether its ink is a line's or a bar's
341
+ // (`outputBars` moves a MACD's Hist from one to the other).
342
+ const marks = configOutputs(c)
343
+ .map((o) => o.mark[0])
344
+ .join('');
345
+ return `${c.id}:${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) : ''}`;
341
346
  })
342
347
  .join('|') +
343
348
  '#' +
package/dist/index.d.ts CHANGED
@@ -13,10 +13,10 @@
13
13
  */
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
- export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, 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, 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';
16
+ export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, 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
17
  export { DEFAULT_CHART_SETTINGS, mergeChartSettings, type AnnotationOverride, type ChartSettings, type CategoryLineStyle, type SessionDividers, type SplitColorDefault, type LineDash, } from './chartSettings.js';
18
18
  export { useMeasuredWidth, useMeasuredSize } from './useMeasuredWidth.js';
19
- export { assembleRows, carries, foldKey, foldSources, prepareChart, sourceFacts, type ConfigRow, type PreparedRow, type SourceFacts, type SourceHold, type SourceInput, type SourceInputs, } from './prepare.js';
19
+ 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';
20
20
  export { finiteColumns, firstLast, lastRow } from './seriesFacts.js';
21
21
  export { createLiveValue } from '@pond-ts/charts';
22
22
  export type { TrackerInfo, TrackerSample, LiveValue } from '@pond-ts/charts';
package/dist/index.js CHANGED
@@ -12,10 +12,10 @@
12
12
  * style builders) stay internal until a consumer asks.
13
13
  */
14
14
  export { TimeSeriesChart, annotationInView, } from './TimeSeriesChart.js';
15
- export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, 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, logAllowed, AXIS_PRECISIONS, readsFrom, sourcesOf, } from './series.js';
15
+ export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, 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
16
  export { DEFAULT_CHART_SETTINGS, mergeChartSettings, } from './chartSettings.js';
17
17
  export { useMeasuredWidth, useMeasuredSize } from './useMeasuredWidth.js';
18
- export { assembleRows, carries, foldKey, foldSources, prepareChart, sourceFacts, } from './prepare.js';
18
+ export { assembleRows, carries, foldKey, foldSources, foldSourcesReport, prepareChart, sourceFacts, } from './prepare.js';
19
19
  export { finiteColumns, firstLast, lastRow } from './seriesFacts.js';
20
20
  // Re-exported so a host wires the live pill / tracker without a second import
21
21
  // site for the library the chart is built on.
package/dist/prepare.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { DeriveNodeTiming, DeriveSkip } from '@tidal-ts/core';
1
2
  import { type SeriesConfig } from './series.js';
2
3
  import type { ChartSeries } from './types.js';
3
4
  /**
@@ -109,6 +110,27 @@ export declare function foldKey(configs: readonly SeriesConfig[]): string;
109
110
  * source is the caller's affair (it will not be carried).
110
111
  */
111
112
  export declare function foldSources(inputs: SourceInputs, configs: readonly SeriesConfig[]): Record<string, ChartSeries>;
113
+ /** What a fold did to one source — {@link foldSourcesReport}. */
114
+ export interface SourceFoldReport {
115
+ /** Rows in the series as the chart gets it: for a held source (`hold`),
116
+ * the grid's length, not the source's own. */
117
+ rows: number;
118
+ /** The specs the engine could not run, once each (`applyDerivedReport`). */
119
+ skipped: DeriveSkip[];
120
+ /** Each step as the engine ran it: cost, and whether it was served warm. */
121
+ nodes: DeriveNodeTiming[];
122
+ /** The whole fold of this source, join and hold included, in ms. */
123
+ ms: number;
124
+ }
125
+ /**
126
+ * {@link foldSources} with the report: per source, what the engine skipped and
127
+ * what each step cost — what a pipeline view shows on its nodes. The same fold;
128
+ * `foldSources` is this without the report.
129
+ */
130
+ export declare function foldSourcesReport(inputs: SourceInputs, configs: readonly SeriesConfig[]): {
131
+ sources: Record<string, ChartSeries>;
132
+ reports: Record<string, SourceFoldReport>;
133
+ };
112
134
  /** Per-source data facts, read columnar: which columns carry real (finite)
113
135
  * values ("show only what the data carries") and the latest bar (the chip /
114
136
  * controls value readout). One `toObjects()` pass per source here was the
package/dist/prepare.js CHANGED
@@ -1,4 +1,4 @@
1
- import { applyDerived, COMPARE_PREFIX, holdAcrossGrid, joinUnderPrefix, usesCompare, } from '@tidal-ts/core';
1
+ import { applyDerivedReport, COMPARE_PREFIX, holdAcrossGrid, joinUnderPrefix, usesCompare, } 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
@@ -58,10 +58,20 @@ export function foldKey(configs) {
58
58
  * source is the caller's affair (it will not be carried).
59
59
  */
60
60
  export function foldSources(inputs, configs) {
61
+ return foldSourcesReport(inputs, configs).sources;
62
+ }
63
+ /**
64
+ * {@link foldSources} with the report: per source, what the engine skipped and
65
+ * what each step cost — what a pipeline view shows on its nodes. The same fold;
66
+ * `foldSources` is this without the report.
67
+ */
68
+ export function foldSourcesReport(inputs, configs) {
61
69
  const specs = specsBySource(configs);
62
70
  const rawCompare = new Set(rawCompareSources(configs));
63
- const out = {};
71
+ const sources = {};
72
+ const reports = {};
64
73
  for (const [key, input] of Object.entries(inputs)) {
74
+ const t0 = performance.now();
65
75
  const mine = specs[key] ?? [];
66
76
  // A coarse source is folded before it is held, so a restated row has to go
67
77
  // first, or the join pairs it with nothing and a study counts it as a bar
@@ -76,10 +86,19 @@ export function foldSources(inputs, configs) {
76
86
  // not the library's `onConflict: 'prefix'`).
77
87
  if (compare && (rawCompare.has(key) || mine.some(usesCompare)))
78
88
  series = joinUnderPrefix(series, compare);
79
- const folded = applyDerived(series, mine);
80
- out[key] = input.hold ? holdAcrossGrid(folded, input.hold.grid, input.hold.grainMs) : folded;
89
+ const folded = applyDerivedReport(series, mine);
90
+ const out = input.hold
91
+ ? holdAcrossGrid(folded.series, input.hold.grid, input.hold.grainMs)
92
+ : folded.series;
93
+ sources[key] = out;
94
+ reports[key] = {
95
+ rows: out.length,
96
+ skipped: folded.skipped,
97
+ nodes: folded.nodes,
98
+ ms: Math.round((performance.now() - t0) * 1000) / 1000,
99
+ };
81
100
  }
82
- return out;
101
+ return { sources, reports };
83
102
  }
84
103
  /** Per-source data facts, read columnar: which columns carry real (finite)
85
104
  * values ("show only what the data carries") and the latest bar (the chip /
package/dist/series.d.ts CHANGED
@@ -32,7 +32,15 @@ export declare function bandColumns(column: string): {
32
32
  * the toggle on a study with nothing to colour would be a control that does
33
33
  * nothing.
34
34
  */
35
- export declare function hasBarOutput(c: Pick<SeriesConfig, 'style' | 'derive' | 'column' | 'fan'>): boolean;
35
+ export declare function hasBarOutput(c: Pick<SeriesConfig, 'style' | 'derive' | 'column' | 'fan' | 'outputBars'>): boolean;
36
+ /**
37
+ * Whether {@link SeriesConfig.outputBars} means anything for a config: a
38
+ * `lines` study whose op draws an output as bars (a MACD), however it is drawn
39
+ * now. {@link hasBarOutput} answers "does it draw bars?", which turns false
40
+ * the moment the bars become lines — a host gating its bars/lines control on
41
+ * that would hide the control with no way back.
42
+ */
43
+ export declare function offersOutputBars(c: Pick<SeriesConfig, 'style' | 'derive' | 'column' | 'fan'>): boolean;
36
44
  /**
37
45
  * The per-output theme key for a `lines` config.
38
46
  *
@@ -69,7 +77,9 @@ export interface ConfigOutput {
69
77
  * A config whose `derive` is gone degrades to its bare column rather than
70
78
  * throwing (a persisted config can outlive the op that named it).
71
79
  */
72
- export declare function configOutputs(c: Pick<SeriesConfig, 'column' | 'derive' | 'fan'>): ConfigOutput[];
80
+ export declare function configOutputs(c: Pick<SeriesConfig, 'column' | 'derive' | 'fan'> & {
81
+ outputBars?: boolean;
82
+ }): ConfigOutput[];
73
83
  /**
74
84
  * The columns a `band` config draws between (and its centre line, when it has
75
85
  * one). A fanned band — an SMA of a band's `Upper` and `Lower` — may have no
@@ -281,6 +291,14 @@ export interface SeriesConfig {
281
291
  * has one.
282
292
  */
283
293
  bandMiddle?: boolean;
294
+ /**
295
+ * Whether a `lines` study draws the outputs its op draws as BARS (a MACD's
296
+ * `Hist`) as bars. `false` draws every output as a line; omitted ⇒ each
297
+ * output takes its op's own mark (`outputMark`). Only a `lines` study reads
298
+ * it ({@link offersOutputBars}): a single-output histogram (an Awesome
299
+ * Oscillator) is `style: 'bar'`, and becomes a line by its `style`.
300
+ */
301
+ outputBars?: boolean;
284
302
  }
285
303
  /** The textures in display order. */
286
304
  export declare const LINE_DASHES: readonly LineDash[];
package/dist/series.js CHANGED
@@ -23,6 +23,16 @@ export function hasBarOutput(c) {
23
23
  return false;
24
24
  return configOutputs(c).some((o) => o.mark === 'bar');
25
25
  }
26
+ /**
27
+ * Whether {@link SeriesConfig.outputBars} means anything for a config: a
28
+ * `lines` study whose op draws an output as bars (a MACD), however it is drawn
29
+ * now. {@link hasBarOutput} answers "does it draw bars?", which turns false
30
+ * the moment the bars become lines — a host gating its bars/lines control on
31
+ * that would hide the control with no way back.
32
+ */
33
+ export function offersOutputBars(c) {
34
+ return hasBarOutput({ ...c, outputBars: undefined });
35
+ }
26
36
  /**
27
37
  * The per-output theme key for a `lines` config.
28
38
  *
@@ -49,10 +59,12 @@ export const outputKey = (id, i) => `${id}__o${i}`;
49
59
  * throwing (a persisted config can outlive the op that named it).
50
60
  */
51
61
  export function configOutputs(c) {
62
+ // `outputBars: false` draws an op's bar outputs as lines.
63
+ const markOf = (op, name) => c.outputBars === false ? 'line' : outputMark(op, name);
52
64
  if (!c.derive && c.fan && c.fan.length > 0)
53
65
  return c.fan.map((column) => ({ name: column, column, mark: 'line' }));
54
66
  if (c.derive && c.fan && c.fan.length > 0) {
55
- const mark = outputMark(c.derive.op, '');
67
+ const mark = markOf(c.derive.op, '');
56
68
  const derive = c.derive;
57
69
  return c.fan.map((name) => ({ name, column: deriveId(withFanOutput(derive, name)), mark }));
58
70
  }
@@ -63,7 +75,7 @@ export function configOutputs(c) {
63
75
  return outs.map((name) => ({
64
76
  name,
65
77
  column: `${c.column}${name}`,
66
- mark: outputMark(op, name),
78
+ mark: markOf(op, name),
67
79
  }));
68
80
  }
69
81
  return [{ name: '', column: c.column, mark: 'line' }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidal-ts/chart",
3
- "version": "0.13.0",
3
+ "version": "0.15.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.13.0"
41
+ "@tidal-ts/core": "0.15.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@pond-ts/charts": "^0.73.0",