@tidal-ts/chart 0.2.1 → 0.2.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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/series.d.ts +46 -0
- package/dist/series.js +47 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
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, seriesLineDashArray, seriesLineWidth, sharedAxisId, type AxisRange, effectiveAxisBounds, clampBoundsToLocks, barZeroLock, centerOnZero, axisRangeIsEmpty, axisFormat, fractionTicks, bandColumns, configColumns, 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, } from './series.js';
|
|
16
|
+
export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, seriesDrawn, seriesLineDashArray, seriesLineWidth, sharedAxisId, type AxisRange, effectiveAxisBounds, clampBoundsToLocks, barZeroLock, centerOnZero, axisRangeIsEmpty, axisFormat, fractionTicks, bandColumns, configColumns, 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';
|
|
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
19
|
export { assembleRows, carries, foldKey, foldSources, prepareChart, sourceFacts, type ConfigRow, type PreparedRow, type SourceFacts, type SourceInput, type SourceInputs, } from './prepare.js';
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
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, seriesLineDashArray, seriesLineWidth, sharedAxisId, effectiveAxisBounds, clampBoundsToLocks, barZeroLock, centerOnZero, axisRangeIsEmpty, axisFormat, fractionTicks, bandColumns, configColumns, hasBarOutput, logAllowed, AXIS_PRECISIONS, } from './series.js';
|
|
15
|
+
export { configAxisId, effectiveSplit, formatSeriesValue, isStudySeries, LINE_WIDTHS, PAIR_JOINS, PAIR_LENSES, seriesAxisId, readsCompare, seriesDrawn, seriesLineDashArray, seriesLineWidth, sharedAxisId, effectiveAxisBounds, clampBoundsToLocks, barZeroLock, centerOnZero, axisRangeIsEmpty, axisFormat, fractionTicks, bandColumns, configColumns, hasBarOutput, 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
18
|
export { assembleRows, carries, foldKey, foldSources, prepareChart, sourceFacts, } from './prepare.js';
|
package/dist/series.d.ts
CHANGED
|
@@ -150,6 +150,27 @@ export interface SeriesConfig {
|
|
|
150
150
|
* spec, while `id` stands still. The render folds the op onto the source
|
|
151
151
|
* series via `applyDerived`. Absent ⇒ raw. */
|
|
152
152
|
derive?: DeriveSpec;
|
|
153
|
+
/**
|
|
154
|
+
* The configs this one is BUILT ON, index-aligned with its spec's inputs
|
|
155
|
+
* (`inputNames(derive)`) — a study's one parent, a joined pair's two legs.
|
|
156
|
+
*
|
|
157
|
+
* The spec names its inputs by COLUMN, and that stays: the column is the
|
|
158
|
+
* DATA, content-addressed, computed once however many configs read it. What
|
|
159
|
+
* a column cannot say is WHICH config a derived one belongs to, and once the
|
|
160
|
+
* same metric can be seated twice — price on two rows, each with its own
|
|
161
|
+
* chain of studies — two configs share a column and "which one is this
|
|
162
|
+
* study on" has two answers. This is the answer, recorded when it was known:
|
|
163
|
+
* at the moment the study was added from one particular config's button.
|
|
164
|
+
*
|
|
165
|
+
* An entry is honoured only while it still names a config that PUBLISHES
|
|
166
|
+
* that input's column. An entry absent, or naming a config that computes
|
|
167
|
+
* something else now (a stale record), falls back to the column — which is
|
|
168
|
+
* how every config written before this field is read. An entry naming a
|
|
169
|
+
* config that is GONE resolves to nothing: the parent was removed, and
|
|
170
|
+
* re-binding its orphan to whichever other config shares the column would
|
|
171
|
+
* hand it to a copy it was never on.
|
|
172
|
+
*/
|
|
173
|
+
parentIds?: readonly (string | undefined)[];
|
|
153
174
|
/** Stroke width (px) for `line`/`area`. Omitted ⇒ the category default from
|
|
154
175
|
* the chart settings (see {@link seriesLineWidth}). */
|
|
155
176
|
lineWidth?: number;
|
|
@@ -489,3 +510,28 @@ export declare const formatCurrency: (v: number, digits: number) => string;
|
|
|
489
510
|
* `-0.23log` (the unit still keeps it off a unitless axis); a percent /
|
|
490
511
|
* unitless suffix trails the value (`22.65%`). */
|
|
491
512
|
export declare function formatSeriesValue(value: number | null, unit?: string): string;
|
|
513
|
+
/**
|
|
514
|
+
* The configs `c` is BUILT ON — the one question every dependency walk asks,
|
|
515
|
+
* in the machine and in any host that draws the graph, answered in one place.
|
|
516
|
+
*
|
|
517
|
+
* By RECORDED PARENT first (`parentIds`, index-aligned with the spec's
|
|
518
|
+
* inputs), and by COLUMN only where no parent was recorded. The spec names its
|
|
519
|
+
* inputs by column, and for the data that is exactly right — but the column
|
|
520
|
+
* cannot say which config a study belongs to once a metric is seated twice,
|
|
521
|
+
* and every walk used to answer by column: removal cascaded through whichever
|
|
522
|
+
* copy a Map kept last, and retuning one study re-pointed the OTHER copy's
|
|
523
|
+
* children at it (`TDL-CMPDUP`). The column fallback is kept for configs
|
|
524
|
+
* written before `parentIds` and for inputs no config was recorded for (a
|
|
525
|
+
* study's bar columns, a pair leg that was not seated). It is a best guess
|
|
526
|
+
* where a column is seated twice — the first config publishing it wins —
|
|
527
|
+
* which is exactly the ambiguity recording a parent exists to remove.
|
|
528
|
+
*
|
|
529
|
+
* A recorded parent that is gone resolves to NOTHING rather than re-binding
|
|
530
|
+
* by column: see {@link SeriesConfig.parentIds}.
|
|
531
|
+
*
|
|
532
|
+
* An input with no config behind it (a raw feed column no one displays)
|
|
533
|
+
* contributes nothing, as before.
|
|
534
|
+
*/
|
|
535
|
+
export declare function sourcesOf(configs: readonly SeriesConfig[], c: SeriesConfig): SeriesConfig[];
|
|
536
|
+
/** Whether `c` is built on `p` — `sourcesOf`, asked the other way round. */
|
|
537
|
+
export declare const readsFrom: (configs: readonly SeriesConfig[], c: SeriesConfig, p: SeriesConfig) => boolean;
|
package/dist/series.js
CHANGED
|
@@ -59,7 +59,7 @@ export function configColumns(c) {
|
|
|
59
59
|
// `@tidal-ts/core` (where the windowing + derive seam live) — imported for
|
|
60
60
|
// `SeriesConfig` below and re-exported so UI code has one import site for the
|
|
61
61
|
// series vocabulary.
|
|
62
|
-
import { BAND_OUTPUTS, COMPARE_PREFIX, opOutputs, opParams, outputMark, usesCompare, } from '@tidal-ts/core';
|
|
62
|
+
import { BAND_OUTPUTS, COMPARE_PREFIX, inputNames, opOutputs, opParams, outputMark, usesCompare, } from '@tidal-ts/core';
|
|
63
63
|
// The app-wide presentation defaults the category resolvers below read.
|
|
64
64
|
import { DEFAULT_CHART_SETTINGS, } from './chartSettings.js';
|
|
65
65
|
// --- Axis identity ------------------------------------------------------------
|
|
@@ -374,3 +374,49 @@ export function formatSeriesValue(value, unit = '') {
|
|
|
374
374
|
return formatCurrency(value, 2);
|
|
375
375
|
return `${value.toFixed(2)}${unit}`;
|
|
376
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* The configs `c` is BUILT ON — the one question every dependency walk asks,
|
|
379
|
+
* in the machine and in any host that draws the graph, answered in one place.
|
|
380
|
+
*
|
|
381
|
+
* By RECORDED PARENT first (`parentIds`, index-aligned with the spec's
|
|
382
|
+
* inputs), and by COLUMN only where no parent was recorded. The spec names its
|
|
383
|
+
* inputs by column, and for the data that is exactly right — but the column
|
|
384
|
+
* cannot say which config a study belongs to once a metric is seated twice,
|
|
385
|
+
* and every walk used to answer by column: removal cascaded through whichever
|
|
386
|
+
* copy a Map kept last, and retuning one study re-pointed the OTHER copy's
|
|
387
|
+
* children at it (`TDL-CMPDUP`). The column fallback is kept for configs
|
|
388
|
+
* written before `parentIds` and for inputs no config was recorded for (a
|
|
389
|
+
* study's bar columns, a pair leg that was not seated). It is a best guess
|
|
390
|
+
* where a column is seated twice — the first config publishing it wins —
|
|
391
|
+
* which is exactly the ambiguity recording a parent exists to remove.
|
|
392
|
+
*
|
|
393
|
+
* A recorded parent that is gone resolves to NOTHING rather than re-binding
|
|
394
|
+
* by column: see {@link SeriesConfig.parentIds}.
|
|
395
|
+
*
|
|
396
|
+
* An input with no config behind it (a raw feed column no one displays)
|
|
397
|
+
* contributes nothing, as before.
|
|
398
|
+
*/
|
|
399
|
+
export function sourcesOf(configs, c) {
|
|
400
|
+
if (!c.derive)
|
|
401
|
+
return [];
|
|
402
|
+
const out = [];
|
|
403
|
+
inputNames(c.derive).forEach((name, i) => {
|
|
404
|
+
const byId = c.parentIds?.[i];
|
|
405
|
+
if (byId != null && byId !== c.id) {
|
|
406
|
+
const recorded = configs.find((x) => x.id === byId);
|
|
407
|
+
if (!recorded)
|
|
408
|
+
return; // its parent is gone — an orphan, not a re-bind
|
|
409
|
+
if (recorded.column === name) {
|
|
410
|
+
out.push(recorded);
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
// Stale: that config computes something else now. Fall through.
|
|
414
|
+
}
|
|
415
|
+
const src = configs.find((x) => x.id !== c.id && x.column === name);
|
|
416
|
+
if (src)
|
|
417
|
+
out.push(src);
|
|
418
|
+
});
|
|
419
|
+
return out;
|
|
420
|
+
}
|
|
421
|
+
/** Whether `c` is built on `p` — `sourcesOf`, asked the other way round. */
|
|
422
|
+
export const readsFrom = (configs, c, p) => sourcesOf(configs, c).some((s) => s.id === p.id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tidal-ts/chart",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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.2.
|
|
41
|
+
"@tidal-ts/core": "0.2.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@pond-ts/charts": "^0.70.0",
|