@tidal-ts/chart 0.21.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/dist/TimeSeriesChart.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/series.d.ts +25 -1
- package/dist/series.js +14 -3
- package/package.json +2 -2
package/dist/TimeSeriesChart.js
CHANGED
|
@@ -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,
|
|
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 (`
|
|
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 = `${
|
|
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('|') +
|
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/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 (
|
|
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 && !
|
|
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.
|
|
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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react": "^18.2.0 || ^19.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@tidal-ts/core": "0.
|
|
41
|
+
"@tidal-ts/core": "0.22.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@pond-ts/charts": "^0.78.0",
|