@tidal-ts/chart 0.5.1 → 0.6.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.
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useRef, useCallback, Fragment, memo, useEffect, useMemo, useState, } from 'react';
3
- import { AreaChart, BandChart, BarChart, Candlestick, ChartContainer, ChartRow, Layers, LineChart, Marker, Region, TimeAxis, YAxis, YAxisIndicator, } from '@pond-ts/charts';
3
+ import { AreaChart, BandChart, BarChart, Candlestick, ChartContainer, ChartRow, Layers, LineChart, Baseline, Marker, Region, TimeAxis, YAxis, YAxisIndicator, } from '@pond-ts/charts';
4
4
  import { segmentDiscontinuity, weekendSkip } from '@pond-ts/financial';
5
5
  import { resolveTimeZone, aggregateColumn, hasPairOp, inferBarMs, liveWindowMs, ohlcWindow, readNumericColumn, sessionOpenLine, exactSessionSegments, sessionSegments, shiftKeys, sliceBySegments, WINDOW_MS, autoBarWindow, opOutputs, outputMark, } from '@tidal-ts/core';
6
6
  import { candleStyleForColor, candleStyleForPair } from './candleStyle.js';
7
7
  import { useMeasuredWidth } from './useMeasuredWidth.js';
8
8
  import { DEFAULT_CHART_SETTINGS } from './chartSettings.js';
9
- import { configAxisId, seriesDrawn, DASH_PATTERN, effectiveSplit, seriesAxisId, seriesLineDashArray, seriesLineWidth, sharedAxisId, axisFormat, fractionTicks, bandColumns, outputKey, configColumns, } from './series.js';
9
+ import { configAxisId, guideLevels, seriesDrawn, DASH_PATTERN, effectiveSplit, seriesAxisId, seriesLineDashArray, seriesLineWidth, sharedAxisId, axisFormat, fractionTicks, bandColumns, outputKey, configColumns, } from './series.js';
10
10
  /** The schema-erased series type every layer reads. Rows carry heterogeneous
11
11
  * sources (vol `%`, price `$`), so the chart works in the erased schema and each
12
12
  * config names its `column`. Callers build the {@link TimeSeriesChartProps.sources} map
@@ -1214,7 +1214,7 @@ function TimeSeriesChartInner({ rows, sources, ohlcSources = [], calendarDays =
1214
1214
  // density problem — 16 across the top at 1Y, two of them
1215
1215
  // behind our own legend. `false` (not omitted) is required:
1216
1216
  // omitting it auto-labels with the axis formatter.
1217
- label: false, role: a.role, selectable: false }, a.id))), [...visible].reverse().flatMap((c) => {
1217
+ label: false, role: a.role, selectable: false }, a.id))), guideLevels(drawable, row.id, (a) => axisOptions?.[a]?.scaleType === 'log').map((g) => (_jsx(Baseline, { id: g.key, value: g.value, axis: g.axis, label: false, selectable: false, role: "guide" }, g.key))), [...visible].reverse().flatMap((c) => {
1218
1218
  const src = c.source ? sources[c.source] : undefined;
1219
1219
  // Column-level "show only what the data carries": a config
1220
1220
  // whose column is absent from its (folded) series draws
package/dist/series.d.ts CHANGED
@@ -189,6 +189,14 @@ export declare const sharedAxisId: (rowId: string, side: SeriesAxis) => string;
189
189
  export declare const seriesAxisId: (rowId: string, side: SeriesAxis, group: string) => string;
190
190
  /** The axis a config actually scales on: its own when unlinked, else the shared. */
191
191
  export declare const configAxisId: (rowId: string, c: Pick<SeriesConfig, "axis" | "axisGroup">) => string;
192
+ /** The guide levels a row draws: each drawn study's {@link studyLevels} on its
193
+ * own axis, once per (axis, value) — two RSIs sharing an axis draw one 30
194
+ * and one 70. Drawn as `<Baseline role="guide">`; a host styles the role. */
195
+ export declare function guideLevels(drawn: readonly SeriesConfig[], rowId: string, isLog?: (axisId: string) => boolean): {
196
+ key: string;
197
+ axis: string;
198
+ value: number;
199
+ }[];
192
200
  /** Per-axis range state (the terminal machine's `axisRanges` values): `manual`
193
201
  * pins the axis to `[min, max]`; `auto` with values present is the **preserved
194
202
  * manual memory** (the legacy triple — "Auto fit was …" / re-manual restores).
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, inputNames, opOutputs, opParams, outputMark, usesCompare, } from '@tidal-ts/core';
62
+ import { BAND_OUTPUTS, COMPARE_PREFIX, inputNames, opOutputs, opParams, outputMark, studyLevels, 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 ------------------------------------------------------------
@@ -74,6 +74,26 @@ export const sharedAxisId = (rowId, side) => `${rowId}:${side === 'R' ? 'R' : 'L
74
74
  export const seriesAxisId = (rowId, side, group) => `${sharedAxisId(rowId, side)}:${group}`;
75
75
  /** The axis a config actually scales on: its own when unlinked, else the shared. */
76
76
  export const configAxisId = (rowId, c) => c.axisGroup ? seriesAxisId(rowId, c.axis, c.axisGroup) : sharedAxisId(rowId, c.axis);
77
+ /** The guide levels a row draws: each drawn study's {@link studyLevels} on its
78
+ * own axis, once per (axis, value) — two RSIs sharing an axis draw one 30
79
+ * and one 70. Drawn as `<Baseline role="guide">`; a host styles the role. */
80
+ export function guideLevels(drawn, rowId, isLog = () => false) {
81
+ const out = new Map();
82
+ for (const c of drawn) {
83
+ if (!c.derive)
84
+ continue;
85
+ const axis = configAxisId(rowId, c);
86
+ for (const value of studyLevels(c.derive.op)) {
87
+ // A log scale has no 0 or below (%B's 0, a zero line): skip, not NaN.
88
+ if (value <= 0 && isLog(axis))
89
+ continue;
90
+ const key = `guide:${axis}:${value}`;
91
+ if (!out.has(key))
92
+ out.set(key, { key, axis, value });
93
+ }
94
+ }
95
+ return [...out.values()];
96
+ }
77
97
  /**
78
98
  * Whether an axis's entry says nothing — no lock, no pin, no memory, no format
79
99
  * or fit choice — and can therefore be dropped rather than accumulate an empty
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidal-ts/chart",
3
- "version": "0.5.1",
3
+ "version": "0.6.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.5.1"
41
+ "@tidal-ts/core": "0.6.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@pond-ts/charts": "^0.70.0",