@tidal-ts/chart 0.28.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.
- package/dist/TimeSeriesChart.js +8 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/series.d.ts +23 -2
- package/dist/series.js +20 -6
- 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, 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
|
-
|
|
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
|
|
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/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
|
|
@@ -722,14 +735,22 @@ export declare function seriesCategoryStyle(s: SeriesConfig, settings: ChartSett
|
|
|
722
735
|
/** A series' stroke width: its explicit `lineWidth` override, else its category
|
|
723
736
|
* default from the settings (metrics vs studies). */
|
|
724
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;
|
|
725
744
|
/** The dash pattern a `'dotted'` line draws with — short enough to read as
|
|
726
745
|
* dots at every weight the panel offers, spaced so it never reads as a dash. */
|
|
727
746
|
export declare const DOT_PATTERN: readonly [number, number];
|
|
728
747
|
/** A texture as a dash pattern — `undefined` for solid. */
|
|
729
748
|
export declare function dashPattern(dash: LineDash | undefined): readonly [number, number] | undefined;
|
|
730
749
|
/** A series' dash pattern (`undefined` = solid): its own `lineDash`, else its
|
|
731
|
-
* category's style. A comparison-reading series
|
|
732
|
-
*
|
|
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. */
|
|
733
754
|
export declare function seriesLineDashArray(s: SeriesConfig, settings?: ChartSettings): readonly [number, number] | undefined;
|
|
734
755
|
/** Dash ladders for a multi-output config's 2nd..Nth line, by default.
|
|
735
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
|
|
501
|
-
*
|
|
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 (
|
|
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
|
|
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.
|
|
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.
|
|
41
|
+
"@tidal-ts/core": "0.29.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@pond-ts/charts": "^0.78.0",
|