@tidal-ts/chart 0.12.1 → 0.14.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 +12 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/prepare.d.ts +1 -1
- package/dist/series.d.ts +40 -5
- package/dist/series.js +30 -4
- package/package.json +2 -2
package/dist/TimeSeriesChart.js
CHANGED
|
@@ -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
|
-
|
|
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
|
'#' +
|
|
@@ -402,7 +407,8 @@ function TimeSeriesChartInner({ rows, sources, ohlcSources = EMPTY_SOURCES, cale
|
|
|
402
407
|
// "colour = series" — and whatever the user has set per output on top.
|
|
403
408
|
// A band's one line (its centre) draws under `c.id`, so its look lands
|
|
404
409
|
// there; a stack's lines each get their own key.
|
|
405
|
-
if ((c.style === 'lines' && c.derive
|
|
410
|
+
if ((c.style === 'lines' && (c.derive || (c.fan && c.fan.length > 0))) ||
|
|
411
|
+
c.style === 'band') {
|
|
406
412
|
configOutputs(c).forEach((out, i) => {
|
|
407
413
|
const look = outputLook(c, i, settings);
|
|
408
414
|
const ink = withAlpha(resolveColor(look.color), opacityOf(look.opacity) * (isDim ? 0.22 : 1));
|
|
@@ -935,8 +941,9 @@ function TimeSeriesChartInner({ rows, sources, ohlcSources = EMPTY_SOURCES, cale
|
|
|
935
941
|
// N layers for ONE config — one per declared output, each on its own
|
|
936
942
|
// theme key so the textures above apply. `col` is the SPEC ID, so every
|
|
937
943
|
// column is named off it by suffix; reading `col` itself finds nothing,
|
|
938
|
-
// exactly as for a band.
|
|
939
|
-
|
|
944
|
+
// exactly as for a band. A multi-column DATA node (`fan`, no `derive`)
|
|
945
|
+
// draws one line per column, named by the column.
|
|
946
|
+
if (!c.derive && !(c.fan && c.fan.length > 0))
|
|
940
947
|
return [];
|
|
941
948
|
const histSplit = effectiveSplit(c, settings);
|
|
942
949
|
const histSeries = (c.source ? histSeriesFor(c.source) : undefined) ?? panelSeries;
|
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, 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
19
|
export { assembleRows, carries, foldKey, foldSources, prepareChart, sourceFacts, type ConfigRow, type PreparedRow, type SourceFacts, type SourceHold, 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, 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
18
|
export { assembleRows, carries, foldKey, foldSources, prepareChart, sourceFacts, } from './prepare.js';
|
package/dist/prepare.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export declare function sourceFacts(sources: Record<string, ChartSeries>): Sourc
|
|
|
125
125
|
* every band and every multi-output study — a MACD's chip sat blank while the
|
|
126
126
|
* hover readout, which reads the series itself, showed a value. `every`,
|
|
127
127
|
* because one op's fold either produces all its outputs or none. */
|
|
128
|
-
export declare function carries(facts: SourceFacts, c: Pick<SeriesConfig, 'source' | 'column' | 'style' | 'derive'>): boolean;
|
|
128
|
+
export declare function carries(facts: SourceFacts, c: Pick<SeriesConfig, 'source' | 'column' | 'style' | 'derive' | 'fan' | 'bandMiddle'>): boolean;
|
|
129
129
|
/**
|
|
130
130
|
* Per row, the configs to show, each stamped with its latest value (or `null`).
|
|
131
131
|
*
|
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
|
*
|
|
@@ -57,8 +65,10 @@ export interface ConfigOutput {
|
|
|
57
65
|
* The outputs a config draws, in order — the one answer to "what lines does
|
|
58
66
|
* this config put on the canvas, and what is each called?".
|
|
59
67
|
*
|
|
60
|
-
*
|
|
68
|
+
* Four shapes:
|
|
61
69
|
*
|
|
70
|
+
* - **A multi-column data node** ({@link SeriesConfig.fan} on a raw config):
|
|
71
|
+
* one output per column of its source it draws, named by the column.
|
|
62
72
|
* - **A fanned study** ({@link SeriesConfig.fan}): one output per source output
|
|
63
73
|
* it runs on, each its own spec (`withFanOutput`) and so its own column.
|
|
64
74
|
* - **A multi-output op**: one per declared suffix, named off the spec id.
|
|
@@ -67,13 +77,19 @@ export interface ConfigOutput {
|
|
|
67
77
|
* A config whose `derive` is gone degrades to its bare column rather than
|
|
68
78
|
* throwing (a persisted config can outlive the op that named it).
|
|
69
79
|
*/
|
|
70
|
-
export declare function configOutputs(c: Pick<SeriesConfig, 'column' | 'derive' | 'fan'>
|
|
80
|
+
export declare function configOutputs(c: Pick<SeriesConfig, 'column' | 'derive' | 'fan'> & {
|
|
81
|
+
outputBars?: boolean;
|
|
82
|
+
}): ConfigOutput[];
|
|
71
83
|
/**
|
|
72
84
|
* The columns a `band` config draws between (and its centre line, when it has
|
|
73
85
|
* one). A fanned band — an SMA of a band's `Upper` and `Lower` — may have no
|
|
74
|
-
* centre at all; an op's own band always does (`bandColumns`)
|
|
86
|
+
* centre at all; an op's own band always does (`bandColumns`) unless it is told
|
|
87
|
+
* not to draw it (`bandMiddle: false`). A multi-column data node's band runs
|
|
88
|
+
* between its first two columns, with no centre.
|
|
75
89
|
*/
|
|
76
|
-
export declare function configBand(c: Pick<SeriesConfig, 'column' | 'derive' | 'fan'>
|
|
90
|
+
export declare function configBand(c: Pick<SeriesConfig, 'column' | 'derive' | 'fan'> & {
|
|
91
|
+
bandMiddle?: boolean;
|
|
92
|
+
}): {
|
|
77
93
|
middle?: string;
|
|
78
94
|
upper: string;
|
|
79
95
|
lower: string;
|
|
@@ -107,6 +123,7 @@ export declare function configColumns(c: {
|
|
|
107
123
|
style: SeriesStyle;
|
|
108
124
|
derive?: DeriveSpec;
|
|
109
125
|
fan?: readonly string[];
|
|
126
|
+
bandMiddle?: boolean;
|
|
110
127
|
}): string[];
|
|
111
128
|
import type { DeriveSpec, SeriesWindow } from '@tidal-ts/core';
|
|
112
129
|
export type { DeriveSpec, SeriesWindow };
|
|
@@ -262,8 +279,26 @@ export interface SeriesConfig {
|
|
|
262
279
|
* spec is the same chain with the bottom pick swapped (`withFanOutput`), so a
|
|
263
280
|
* retune moves every line together. Absent ⇒ the one output `derive` picks.
|
|
264
281
|
* A fan over a band's two edges draws as a `band`; anything else as `lines`.
|
|
282
|
+
*
|
|
283
|
+
* On a DATA node (no `derive`) it is the columns of its source it draws —
|
|
284
|
+
* a price's `open` and `close` — `column` being the first: two may draw as a
|
|
285
|
+
* `band` between them, any number as `lines`.
|
|
265
286
|
*/
|
|
266
287
|
fan?: readonly string[];
|
|
288
|
+
/**
|
|
289
|
+
* Whether a `band` draws its centre line. `false` draws the wash alone (a
|
|
290
|
+
* Bollinger as just its band); omitted ⇒ the centre is drawn when the band
|
|
291
|
+
* has one.
|
|
292
|
+
*/
|
|
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;
|
|
267
302
|
}
|
|
268
303
|
/** The textures in display order. */
|
|
269
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
|
*
|
|
@@ -36,8 +46,10 @@ export const outputKey = (id, i) => `${id}__o${i}`;
|
|
|
36
46
|
* The outputs a config draws, in order — the one answer to "what lines does
|
|
37
47
|
* this config put on the canvas, and what is each called?".
|
|
38
48
|
*
|
|
39
|
-
*
|
|
49
|
+
* Four shapes:
|
|
40
50
|
*
|
|
51
|
+
* - **A multi-column data node** ({@link SeriesConfig.fan} on a raw config):
|
|
52
|
+
* one output per column of its source it draws, named by the column.
|
|
41
53
|
* - **A fanned study** ({@link SeriesConfig.fan}): one output per source output
|
|
42
54
|
* it runs on, each its own spec (`withFanOutput`) and so its own column.
|
|
43
55
|
* - **A multi-output op**: one per declared suffix, named off the spec id.
|
|
@@ -47,8 +59,12 @@ export const outputKey = (id, i) => `${id}__o${i}`;
|
|
|
47
59
|
* throwing (a persisted config can outlive the op that named it).
|
|
48
60
|
*/
|
|
49
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);
|
|
64
|
+
if (!c.derive && c.fan && c.fan.length > 0)
|
|
65
|
+
return c.fan.map((column) => ({ name: column, column, mark: 'line' }));
|
|
50
66
|
if (c.derive && c.fan && c.fan.length > 0) {
|
|
51
|
-
const mark =
|
|
67
|
+
const mark = markOf(c.derive.op, '');
|
|
52
68
|
const derive = c.derive;
|
|
53
69
|
return c.fan.map((name) => ({ name, column: deriveId(withFanOutput(derive, name)), mark }));
|
|
54
70
|
}
|
|
@@ -59,7 +75,7 @@ export function configOutputs(c) {
|
|
|
59
75
|
return outs.map((name) => ({
|
|
60
76
|
name,
|
|
61
77
|
column: `${c.column}${name}`,
|
|
62
|
-
mark:
|
|
78
|
+
mark: markOf(op, name),
|
|
63
79
|
}));
|
|
64
80
|
}
|
|
65
81
|
return [{ name: '', column: c.column, mark: 'line' }];
|
|
@@ -67,9 +83,19 @@ export function configOutputs(c) {
|
|
|
67
83
|
/**
|
|
68
84
|
* The columns a `band` config draws between (and its centre line, when it has
|
|
69
85
|
* one). A fanned band — an SMA of a band's `Upper` and `Lower` — may have no
|
|
70
|
-
* centre at all; an op's own band always does (`bandColumns`)
|
|
86
|
+
* centre at all; an op's own band always does (`bandColumns`) unless it is told
|
|
87
|
+
* not to draw it (`bandMiddle: false`). A multi-column data node's band runs
|
|
88
|
+
* between its first two columns, with no centre.
|
|
71
89
|
*/
|
|
72
90
|
export function configBand(c) {
|
|
91
|
+
const b = bandOf(c);
|
|
92
|
+
if (c.bandMiddle === false && b.middle)
|
|
93
|
+
return { upper: b.upper, lower: b.lower };
|
|
94
|
+
return b;
|
|
95
|
+
}
|
|
96
|
+
function bandOf(c) {
|
|
97
|
+
if (!c.derive && c.fan && c.fan.length > 0)
|
|
98
|
+
return { lower: c.fan[0], upper: c.fan[1] ?? c.fan[0] };
|
|
73
99
|
if (c.derive && c.fan && c.fan.length > 0) {
|
|
74
100
|
const by = new Map(configOutputs(c).map((o) => [o.name, o.column]));
|
|
75
101
|
const middle = by.get('Middle');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tidal-ts/chart",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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.14.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@pond-ts/charts": "^0.73.0",
|