@orangecharts/wrun-chart-host 0.1.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/README.md +72 -0
- package/dist/constants/governed-exchanges.constants.d.ts +11 -0
- package/dist/constants/governed-exchanges.constants.js +11 -0
- package/dist/constants/indicator-sets.constants.d.ts +8 -0
- package/dist/constants/indicator-sets.constants.js +8 -0
- package/dist/constants/interval.constants.d.ts +34 -0
- package/dist/constants/interval.constants.js +121 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +28 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +65 -0
- package/dist/constants/tpo-color-schemes.constants.d.ts +30 -0
- package/dist/constants/tpo-color-schemes.constants.js +32 -0
- package/dist/host-env.d.ts +102 -0
- package/dist/host-env.js +26 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +96 -0
- package/dist/indicators/controls/tpo-letter.util.d.ts +2 -0
- package/dist/indicators/controls/tpo-letter.util.js +13 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +99 -0
- package/dist/indicators/controls/tpo-session.util.js +389 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +64 -0
- package/dist/interfaces/kscript-diagnostics.interface.js +1 -0
- package/dist/interfaces/om-panel-data.interface.d.ts +103 -0
- package/dist/interfaces/om-panel-data.interface.js +7 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +2659 -0
- package/dist/interfaces/wrun-runtime.interface.js +55 -0
- package/dist/utility/chart/calendar-interval.util.d.ts +24 -0
- package/dist/utility/chart/calendar-interval.util.js +81 -0
- package/dist/utility/chart/candle-bar-end.util.d.ts +15 -0
- package/dist/utility/chart/candle-bar-end.util.js +23 -0
- package/dist/utility/chart/cme-realtime.util.d.ts +24 -0
- package/dist/utility/chart/cme-realtime.util.js +53 -0
- package/dist/utility/chart/interval-ladder.util.d.ts +27 -0
- package/dist/utility/chart/interval-ladder.util.js +92 -0
- package/dist/utility/chart/kscript-drawing-prep.util.d.ts +40 -0
- package/dist/utility/chart/kscript-drawing-prep.util.js +184 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +95 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +805 -0
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +166 -0
- package/dist/utility/chart/kscript-legend-entries.util.js +538 -0
- package/dist/utility/chart/kscript-output-role.util.d.ts +32 -0
- package/dist/utility/chart/kscript-output-role.util.js +215 -0
- package/dist/utility/chart/kscript-provenance-keys.util.d.ts +22 -0
- package/dist/utility/chart/kscript-provenance-keys.util.js +56 -0
- package/dist/utility/chart/kscript-run-result-normalize.util.d.ts +53 -0
- package/dist/utility/chart/kscript-run-result-normalize.util.js +476 -0
- package/dist/utility/chart/kscript-run-result-shape.util.d.ts +14 -0
- package/dist/utility/chart/kscript-run-result-shape.util.js +66 -0
- package/dist/utility/chart/kscript-titancharts-container.util.d.ts +29 -0
- package/dist/utility/chart/kscript-titancharts-container.util.js +151 -0
- package/dist/utility/chart/kscript-viewport-overlays.util.d.ts +83 -0
- package/dist/utility/chart/kscript-viewport-overlays.util.js +443 -0
- package/dist/utility/chart/om-panel-push-style.util.d.ts +78 -0
- package/dist/utility/chart/om-panel-push-style.util.js +301 -0
- package/dist/utility/chart/om-panel.util.d.ts +166 -0
- package/dist/utility/chart/om-panel.util.js +815 -0
- package/dist/utility/chart/om-series.util.d.ts +42 -0
- package/dist/utility/chart/om-series.util.js +330 -0
- package/dist/utility/chart/om-target.util.d.ts +11 -0
- package/dist/utility/chart/om-target.util.js +24 -0
- package/dist/utility/chart/om-widget.util.d.ts +148 -0
- package/dist/utility/chart/om-widget.util.js +413 -0
- package/dist/utility/chart/overlay-output-budget.util.d.ts +16 -0
- package/dist/utility/chart/overlay-output-budget.util.js +109 -0
- package/dist/utility/chart/overlay-paint-flags.util.d.ts +24 -0
- package/dist/utility/chart/overlay-paint-flags.util.js +55 -0
- package/dist/utility/chart/profile-row-height.util.d.ts +21 -0
- package/dist/utility/chart/profile-row-height.util.js +110 -0
- package/dist/utility/chart/session-interval.util.d.ts +1 -0
- package/dist/utility/chart/session-interval.util.js +35 -0
- package/dist/utility/chart/technical-script-legend-value.util.d.ts +18 -0
- package/dist/utility/chart/technical-script-legend-value.util.js +53 -0
- package/dist/utility/chart/trading-day.util.d.ts +70 -0
- package/dist/utility/chart/trading-day.util.js +238 -0
- package/dist/utility/chart/wrun-legend-name.util.d.ts +25 -0
- package/dist/utility/chart/wrun-legend-name.util.js +87 -0
- package/dist/utility/chart/wrun-run-result.util.d.ts +977 -0
- package/dist/utility/chart/wrun-run-result.util.js +5179 -0
- package/dist/utility/chart/wrun-visibility-chart.util.d.ts +25 -0
- package/dist/utility/chart/wrun-visibility-chart.util.js +22 -0
- package/dist/utility/indicators/heatmap-sensitivity.util.d.ts +62 -0
- package/dist/utility/indicators/heatmap-sensitivity.util.js +82 -0
- package/dist/utility/number-format.util.d.ts +68 -0
- package/dist/utility/number-format.util.js +188 -0
- package/dist/utility/v2/opra-governed.util.d.ts +1 -0
- package/dist/utility/v2/opra-governed.util.js +13 -0
- package/dist/utility/wrun/wrun-auto-row.util.d.ts +54 -0
- package/dist/utility/wrun/wrun-auto-row.util.js +96 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +341 -0
- package/dist/utility/wrun/wrun-batched-marks.util.js +938 -0
- package/dist/utility/wrun/wrun-batched-readout.util.d.ts +75 -0
- package/dist/utility/wrun/wrun-batched-readout.util.js +171 -0
- package/dist/utility/wrun/wrun-box-segment.util.d.ts +185 -0
- package/dist/utility/wrun/wrun-box-segment.util.js +570 -0
- package/dist/utility/wrun/wrun-build-memo.util.d.ts +133 -0
- package/dist/utility/wrun/wrun-build-memo.util.js +301 -0
- package/dist/utility/wrun/wrun-builtin-twin-ports.util.d.ts +25 -0
- package/dist/utility/wrun/wrun-builtin-twin-ports.util.js +75 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.js +40 -0
- package/dist/utility/wrun/wrun-canvas-cache.util.d.ts +28 -0
- package/dist/utility/wrun/wrun-canvas-cache.util.js +56 -0
- package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +69 -0
- package/dist/utility/wrun/wrun-canvas-readout.util.js +53 -0
- package/dist/utility/wrun/wrun-canvases.util.d.ts +295 -0
- package/dist/utility/wrun/wrun-canvases.util.js +1432 -0
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +77 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +296 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +154 -0
- package/dist/utility/wrun/wrun-card-style.util.js +539 -0
- package/dist/utility/wrun/wrun-chart-context.util.d.ts +89 -0
- package/dist/utility/wrun/wrun-chart-context.util.js +213 -0
- package/dist/utility/wrun/wrun-chart-names.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-chart-names.util.js +33 -0
- package/dist/utility/wrun/wrun-chart-time.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-chart-time.util.js +23 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +13 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +44 -0
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +40 -0
- package/dist/utility/wrun/wrun-color-facts.util.js +88 -0
- package/dist/utility/wrun/wrun-color-settings.lazy.d.ts +26 -0
- package/dist/utility/wrun/wrun-color-settings.lazy.js +9 -0
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +351 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +1363 -0
- package/dist/utility/wrun/wrun-footprint-modes.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-footprint-modes.util.js +24 -0
- package/dist/utility/wrun/wrun-frames.d.ts +217 -0
- package/dist/utility/wrun/wrun-frames.js +1021 -0
- package/dist/utility/wrun/wrun-handles.util.d.ts +792 -0
- package/dist/utility/wrun/wrun-handles.util.js +2050 -0
- package/dist/utility/wrun/wrun-heatmap-cell-budget.util.d.ts +156 -0
- package/dist/utility/wrun/wrun-heatmap-cell-budget.util.js +342 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +218 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +667 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +40 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +27 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +182 -0
- package/dist/utility/wrun/wrun-hover.util.js +534 -0
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +246 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +587 -0
- package/dist/utility/wrun/wrun-integration-budget.util.d.ts +47 -0
- package/dist/utility/wrun/wrun-integration-budget.util.js +122 -0
- package/dist/utility/wrun/wrun-latest-snapshot.d.ts +19 -0
- package/dist/utility/wrun/wrun-latest-snapshot.js +7 -0
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +131 -0
- package/dist/utility/wrun/wrun-levels-child.util.js +514 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +75 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.js +9 -0
- package/dist/utility/wrun/wrun-market-facts.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-market-facts.util.js +238 -0
- package/dist/utility/wrun/wrun-output-style.util.d.ts +344 -0
- package/dist/utility/wrun/wrun-output-style.util.js +1239 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +84 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.js +142 -0
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +120 -0
- package/dist/utility/wrun/wrun-overlay-result.util.js +219 -0
- package/dist/utility/wrun/wrun-pack.util.d.ts +70 -0
- package/dist/utility/wrun/wrun-pack.util.js +301 -0
- package/dist/utility/wrun/wrun-pane-format.util.d.ts +180 -0
- package/dist/utility/wrun/wrun-pane-format.util.js +299 -0
- package/dist/utility/wrun/wrun-panel-style.lazy.d.ts +25 -0
- package/dist/utility/wrun/wrun-panel-style.lazy.js +15 -0
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +174 -0
- package/dist/utility/wrun/wrun-panel-style.util.js +726 -0
- package/dist/utility/wrun/wrun-param-values.util.d.ts +69 -0
- package/dist/utility/wrun/wrun-param-values.util.js +230 -0
- package/dist/utility/wrun/wrun-refusal.util.d.ts +263 -0
- package/dist/utility/wrun/wrun-refusal.util.js +1259 -0
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +199 -0
- package/dist/utility/wrun/wrun-registry-errors.util.js +257 -0
- package/dist/utility/wrun/wrun-render-select.util.d.ts +336 -0
- package/dist/utility/wrun/wrun-render-select.util.js +1157 -0
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +434 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +1971 -0
- package/dist/utility/wrun/wrun-setting-words.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-setting-words.lazy.js +9 -0
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +79 -0
- package/dist/utility/wrun/wrun-setting-words.util.js +176 -0
- package/dist/utility/wrun/wrun-socket-row-store.d.ts +98 -0
- package/dist/utility/wrun/wrun-socket-row-store.js +417 -0
- package/dist/utility/wrun/wrun-style-flags.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-style-flags.util.js +21 -0
- package/dist/utility/wrun/wrun-style-words.util.d.ts +148 -0
- package/dist/utility/wrun/wrun-style-words.util.js +439 -0
- package/dist/utility/wrun/wrun-table-look.util.d.ts +125 -0
- package/dist/utility/wrun/wrun-table-look.util.js +225 -0
- package/dist/utility/wrun/wrun-text-look.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-text-look.util.js +227 -0
- package/dist/utility/wrun/wrun-text-params.util.d.ts +106 -0
- package/dist/utility/wrun/wrun-text-params.util.js +171 -0
- package/dist/utility/wrun/wrun-tpo-rows.util.d.ts +71 -0
- package/dist/utility/wrun/wrun-tpo-rows.util.js +438 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +58 -0
- package/dist/utility/wrun/wrun-visibility-table.d.ts +437 -0
- package/dist/utility/wrun/wrun-visibility-table.js +237 -0
- package/dist/utility/wrun/wrun-volume-profile.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +278 -0
- package/package.json +38 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number formatting for browser-run Indicator (wrun) overlays: the axis
|
|
3
|
+
* ticks of a wrun lower pane and the legend values of a wrun overlay.
|
|
4
|
+
*
|
|
5
|
+
* The native path this rides (lane fix round 2, R6): a volume-based
|
|
6
|
+
* technical script installs a meta-level `getYLabel` of
|
|
7
|
+
* `partiallyFormatNumbers(price, digits, undefined, true)` (the app's
|
|
8
|
+
* K/M/B formatter from 1K, chart.add-indicator.ts), which titan's axis
|
|
9
|
+
* consults before its own digit default; every other technical script
|
|
10
|
+
* falls through to the chart-level formatter, which prints the MAIN pane's
|
|
11
|
+
* precision as a raw float ("60000000.00" for USD liquidations,
|
|
12
|
+
* "-1730005" for CVD). A wrun lower pane gets the same meta-level hook: a
|
|
13
|
+
* magnitude from 1K reads through the app's K/M/B formatter, a smaller one
|
|
14
|
+
* at the pane's OWN step precision (titan's digits for that scale, what the
|
|
15
|
+
* engine would print by itself). The main price axis is never touched.
|
|
16
|
+
*
|
|
17
|
+
* Legend values: an on-price wrun output is a price, so it prints at the
|
|
18
|
+
* chart's price precision (the main legend's own formatter, 0.1412 on a
|
|
19
|
+
* sub-dollar symbol instead of "0.14"); a lower-pane value prints K/M/B from
|
|
20
|
+
* 1K like its axis and, below that, the built-in legend rule
|
|
21
|
+
* (formatTechnicalScriptLegendValue), byte for byte the kScript original's.
|
|
22
|
+
* Never the axis digits: titan derives them from the tick step, which grows
|
|
23
|
+
* as the pane gets shorter, so the same value read "59" on a 60 px pane and
|
|
24
|
+
* "59.36" on a tall one (QA 204), and "0" for 0.43 (TEMPLATE-QA B15 C38).
|
|
25
|
+
* An output's `unit` prints after the value even when it declares no
|
|
26
|
+
* `format` (the suffix units wrun-output-style stamps). No surface prints a
|
|
27
|
+
* negative zero: a value that rounds to zero at the printed decimals carries
|
|
28
|
+
* no sign ("0.00", never "-0" or "-0.00%").
|
|
29
|
+
*
|
|
30
|
+
* Declared formats (WRUN-INPUTS-PLAN 1.3, the output `format` key and the
|
|
31
|
+
* `{{name:format}}` placeholder): one frozen word list, one formatter
|
|
32
|
+
* (`formatWrunValue`), shared by the legend, the hover card, the HUD tiles
|
|
33
|
+
* and every template placeholder, so a value reads the same on every
|
|
34
|
+
* surface. A declared word overrides the placement rule above.
|
|
35
|
+
*
|
|
36
|
+
* WRUN-STYLE (OT19 OT32, DW23, X1 X2): the word list grows `usd` and `auto`
|
|
37
|
+
* and every word takes the companions `decimals`, `signed` and `unit`. The
|
|
38
|
+
* eight legacy words without a companion keep today's text byte for byte;
|
|
39
|
+
* `usd`, `auto` and any companion print through the shared
|
|
40
|
+
* `formatWrunNumber` (wrun-style-words.util, the kit's twin). A declared
|
|
41
|
+
* pane's axis (`define.paneAxis`) prints its ticks the same way.
|
|
42
|
+
*
|
|
43
|
+
* Proven twins (`builtinTwinOf`, wrun-builtin-twin.util): a twin stands in
|
|
44
|
+
* for a shipped built-in at parity (look, maths, labels), so it prints
|
|
45
|
+
* exactly like that built-in instead of by the rules above. Its values take
|
|
46
|
+
* the built-in legend rule (formatTechnicalScriptLegendValue: at least 2
|
|
47
|
+
* decimals, two significant digits below 1, the chart's price digits for a
|
|
48
|
+
* price-pane line of a built-in that is not volume-scaled), ahead of any
|
|
49
|
+
* declared word, K/M/B from 1M like the built-in (an OBV twin reads
|
|
50
|
+
* "457500.00", never the pane's "458K"), and its pane keeps the built-in's
|
|
51
|
+
* own axis label (wrunBuiltinTwinYLabel).
|
|
52
|
+
*/
|
|
53
|
+
import { VOLUME_BASED_INDICATORS } from '../../constants/indicator-sets.constants.js';
|
|
54
|
+
import { TECHNICAL_INDICATOR_SCRIPT_KEY_SET } from '../../constants/scriptEditor/technicalIndicatorScriptKeys.constants.js';
|
|
55
|
+
import { formatTechnicalScriptLegendValue, roundLegendValueToTick, technicalScriptLegendDecimals, } from '../chart/technical-script-legend-value.util.js';
|
|
56
|
+
import { partiallyFormatNumbers } from '../number-format.util.js';
|
|
57
|
+
import { builtinTwinOf } from './wrun-builtin-twin.util.js';
|
|
58
|
+
import { formatWrunNumber, WRUN_MAX_VALUE_DECIMALS, WRUN_VALUE_FORMATS, } from './wrun-style-words.util.js';
|
|
59
|
+
/** The frozen format words an output, a block, a pane axis or a
|
|
60
|
+
* `{{name:format}}` placeholder may declare: the foundation's list (the
|
|
61
|
+
* eight legacy words plus `usd` and `auto`), re-exported. */
|
|
62
|
+
export { WRUN_VALUE_FORMATS };
|
|
63
|
+
/** The magnitude from which a wrun lower pane reads K/M/B: the app's own
|
|
64
|
+
* volume-axis threshold (`partiallyFormatNumbers(..., isRoundFromThousand)`). */
|
|
65
|
+
export const WRUN_PANE_COMPACT_FROM = 1_000;
|
|
66
|
+
/** Decimals a wrun pane prints when its own scale is not known yet (titan's
|
|
67
|
+
* default digit count for a fresh scale, and the natives' `digits`). */
|
|
68
|
+
export const WRUN_PANE_DEFAULT_DIGITS = 2;
|
|
69
|
+
/** A negative zero ("-0", "-0.00", "-0.00%", "-0.0 bp": a value that rounds
|
|
70
|
+
* to zero at the printed decimals) without its sign; any other text as is. */
|
|
71
|
+
function unsignedZero(text) {
|
|
72
|
+
return /^-0(?:\.0+)?(?![\d.])/.test(text) ? text.slice(1) : text;
|
|
73
|
+
}
|
|
74
|
+
/** A lower-pane number: K/M/B from 1K through the app's formatter (the
|
|
75
|
+
* volume-based technical scripts' own axis path), else `digits` decimals
|
|
76
|
+
* (a value rounding to zero prints unsigned). */
|
|
77
|
+
export function formatWrunPaneNumber(value, digits) {
|
|
78
|
+
if (!Number.isFinite(value))
|
|
79
|
+
return '';
|
|
80
|
+
if (Math.abs(value) >= WRUN_PANE_COMPACT_FROM) {
|
|
81
|
+
return String(partiallyFormatNumbers(value, WRUN_PANE_DEFAULT_DIGITS, undefined, true));
|
|
82
|
+
}
|
|
83
|
+
return unsignedZero(value.toFixed(clampDigits(digits)));
|
|
84
|
+
}
|
|
85
|
+
/** The pane's own step precision: titan's `digits` on the price scale that
|
|
86
|
+
* scales `overlayId`, the default when the scale is not built yet. */
|
|
87
|
+
export function wrunPaneDigits(chart, overlayId) {
|
|
88
|
+
const controller = chart?.priceScaleControllers?.find((candidate) => candidate.id === overlayId);
|
|
89
|
+
const digits = controller?.digits;
|
|
90
|
+
return typeof digits === 'number' && Number.isFinite(digits) ? clampDigits(digits) : WRUN_PANE_DEFAULT_DIGITS;
|
|
91
|
+
}
|
|
92
|
+
/** The axis format a mounted wrun pane declares (OT19): the `paneAxis` of
|
|
93
|
+
* the run result applied to the overlay `overlayId` (`meta.runResult.define
|
|
94
|
+
* .paneAxis`, stamped by the adapter from a declared `pane(name, {
|
|
95
|
+
* format, ... })`); undefined when the pane declares none or the overlay
|
|
96
|
+
* is not mounted yet. Read per call: a rerun that drops the words drops
|
|
97
|
+
* the format with the next tick. */
|
|
98
|
+
export function wrunPaneAxisOf(chart, overlayId) {
|
|
99
|
+
const meta = chart?.metadata?.find((candidate) => candidate.id === overlayId);
|
|
100
|
+
const runResult = meta?.runResult;
|
|
101
|
+
const axis = runResult?.define?.paneAxis;
|
|
102
|
+
if (axis === null || typeof axis !== 'object')
|
|
103
|
+
return undefined;
|
|
104
|
+
const { format, decimals, signed, unit } = axis;
|
|
105
|
+
if (typeof format !== 'string' || format === '')
|
|
106
|
+
return undefined;
|
|
107
|
+
return {
|
|
108
|
+
format,
|
|
109
|
+
...(typeof decimals === 'number' ? { decimals } : {}),
|
|
110
|
+
...(typeof signed === 'boolean' ? { signed } : {}),
|
|
111
|
+
...(typeof unit === 'string' ? { unit } : {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** The meta-level `getYLabel` a wrun lower pane installs (the parent of an
|
|
115
|
+
* offchart package, the series child of an on-price one). The chart is
|
|
116
|
+
* resolved per call: the hook outlives chart rebuilds and the scale is
|
|
117
|
+
* built after the overlay is added. A pane that declares an axis format
|
|
118
|
+
* (OT19, `define.paneAxis`) prints its ticks through `formatWrunValue`
|
|
119
|
+
* with the declared companions, "price" at the pane's own step digits;
|
|
120
|
+
* without one, today's rule (K/M/B from 1K, the step digits below). */
|
|
121
|
+
export function wrunPaneYLabel(chart, overlayId) {
|
|
122
|
+
return (price) => {
|
|
123
|
+
const current = chart();
|
|
124
|
+
const digits = wrunPaneDigits(current, overlayId);
|
|
125
|
+
const axis = wrunPaneAxisOf(current, overlayId);
|
|
126
|
+
if (axis === undefined)
|
|
127
|
+
return formatWrunPaneNumber(price, digits);
|
|
128
|
+
if (!Number.isFinite(price))
|
|
129
|
+
return '';
|
|
130
|
+
return formatWrunValue(price, axis.format, { priceDigits: digits }, axis);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/** The built-in an overlay's settings stand in for (its `builtinTwinOf`
|
|
134
|
+
* stamp beside a registry identity), or undefined: not a template's twin. */
|
|
135
|
+
export function wrunBuiltinTwin(settings) {
|
|
136
|
+
const builtIn = builtinTwinOf(settings);
|
|
137
|
+
if (builtIn === undefined || !TECHNICAL_INDICATOR_SCRIPT_KEY_SET.has(builtIn))
|
|
138
|
+
return undefined;
|
|
139
|
+
return { volumeBased: VOLUME_BASED_INDICATORS.includes(builtIn) };
|
|
140
|
+
}
|
|
141
|
+
/** The `digits` the technical-script control gives a volume-based built-in
|
|
142
|
+
* (initializeOverlay), which its kept axis label prints with. */
|
|
143
|
+
const WRUN_TWIN_VOLUME_AXIS_DIGITS = 2;
|
|
144
|
+
/** The meta-level `getYLabel` a proven twin's pane installs: the one its
|
|
145
|
+
* built-in keeps (chart.add-indicator). A volume-based built-in keeps its
|
|
146
|
+
* template's digits label (K/M/B from 1K); every other built-in deletes it
|
|
147
|
+
* so titan's own formatting applies (ticks by step, pills with decimals),
|
|
148
|
+
* and the twin installs none (undefined). */
|
|
149
|
+
export function wrunBuiltinTwinYLabel(twin) {
|
|
150
|
+
if (!twin.volumeBased)
|
|
151
|
+
return undefined;
|
|
152
|
+
return (price) => String(partiallyFormatNumbers(price, WRUN_TWIN_VOLUME_AXIS_DIGITS, undefined, true));
|
|
153
|
+
}
|
|
154
|
+
export function isWrunValueFormat(value) {
|
|
155
|
+
return typeof value === 'string' && WRUN_VALUE_FORMATS.includes(value);
|
|
156
|
+
}
|
|
157
|
+
/** The decimals a fixed-point word prints. */
|
|
158
|
+
const WRUN_FIXED_DIGITS = { int: 0, '0': 0, '0.0': 1, '0.00': 2, '0.000': 3 };
|
|
159
|
+
/** The decimals the undeclared default prints below the K/M/B threshold
|
|
160
|
+
* (the TechnicalScript legend precision). */
|
|
161
|
+
const WRUN_DEFAULT_VALUE_DIGITS = 2;
|
|
162
|
+
/** The words the shared formatter prints (X1, X2): the eight legacy words
|
|
163
|
+
* keep their text here unless a companion is declared. */
|
|
164
|
+
const WRUN_SHARED_FORMAT_WORDS = new Set(['usd', 'auto']);
|
|
165
|
+
/** A companion that changes the text: `decimals`, `signed` or a non-empty `unit`. */
|
|
166
|
+
export function hasWrunValueFormatOptions(options) {
|
|
167
|
+
return (options !== undefined &&
|
|
168
|
+
(options.decimals !== undefined ||
|
|
169
|
+
options.signed !== undefined ||
|
|
170
|
+
(options.unit !== undefined && options.unit !== '')));
|
|
171
|
+
}
|
|
172
|
+
/** One value through one declared format word: `price` at the chart's price
|
|
173
|
+
* precision (`priceDigits`, the default decimals when the caller has no
|
|
174
|
+
* chart), `%` as a percent with two decimals (the value already IS a
|
|
175
|
+
* percent), `si` as K/M/B from 1K (the lower-pane axis rule), `int` and
|
|
176
|
+
* the fixed-point words at their decimals. No word: the app's own
|
|
177
|
+
* partial formatter (two decimals, K/M/B from 1M). A hole reads '-'.
|
|
178
|
+
* `usd`, `auto` and any word beside a companion (`decimals`, `signed`,
|
|
179
|
+
* `unit`) print through the shared `formatWrunNumber` (OT32, DW23: "$1.2M",
|
|
180
|
+
* "65,432.1", "+5.0x"); a companion without a word prints the "auto" rule.
|
|
181
|
+
* A value rounding to zero prints unsigned ("0", never "-0"). */
|
|
182
|
+
export function formatWrunValue(value, format, placement, options) {
|
|
183
|
+
return unsignedZero(wrunValueText(value, format, placement, options));
|
|
184
|
+
}
|
|
185
|
+
function wrunValueText(value, format, placement, options) {
|
|
186
|
+
if (!Number.isFinite(value))
|
|
187
|
+
return '-';
|
|
188
|
+
if ((format !== undefined && WRUN_SHARED_FORMAT_WORDS.has(format)) || hasWrunValueFormatOptions(options)) {
|
|
189
|
+
return formatWrunNumber(value, {
|
|
190
|
+
format,
|
|
191
|
+
decimals: options?.decimals,
|
|
192
|
+
signed: options?.signed,
|
|
193
|
+
unit: options?.unit,
|
|
194
|
+
priceDigits: placement?.priceDigits,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
switch (format) {
|
|
198
|
+
case 'price': {
|
|
199
|
+
const digits = clampDigits(placement?.priceDigits ?? WRUN_DEFAULT_VALUE_DIGITS);
|
|
200
|
+
// partiallyFormatNumbers hands the raw number back for 0 decimals and for 0.
|
|
201
|
+
return digits === 0 || value === 0 ? value.toFixed(digits) : String(partiallyFormatNumbers(value, digits));
|
|
202
|
+
}
|
|
203
|
+
case '%':
|
|
204
|
+
return `${value.toFixed(2)}%`;
|
|
205
|
+
case 'si':
|
|
206
|
+
return formatWrunPaneNumber(value, WRUN_DEFAULT_VALUE_DIGITS);
|
|
207
|
+
default: {
|
|
208
|
+
const digits = format === undefined ? undefined : WRUN_FIXED_DIGITS[format];
|
|
209
|
+
if (digits !== undefined)
|
|
210
|
+
return value.toFixed(digits);
|
|
211
|
+
return value === 0
|
|
212
|
+
? value.toFixed(WRUN_DEFAULT_VALUE_DIGITS)
|
|
213
|
+
: String(partiallyFormatNumbers(value, WRUN_DEFAULT_VALUE_DIGITS));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/** A signed value (a delta): the formatted magnitude behind an explicit
|
|
218
|
+
* sign, `+0.00` for zero (a negative value rounding to zero included); a
|
|
219
|
+
* hole reads '-'. The companions print the magnitude (`signed` is this
|
|
220
|
+
* function's own sign). */
|
|
221
|
+
export function formatWrunSignedValue(value, format, placement, options) {
|
|
222
|
+
if (!Number.isFinite(value))
|
|
223
|
+
return '-';
|
|
224
|
+
const magnitude = formatWrunValue(Math.abs(value), format, placement, options === undefined ? undefined : { ...options, signed: undefined });
|
|
225
|
+
// The number itself, not a unit after it, decides whether anything is left to sign.
|
|
226
|
+
const printed = /[\d.,]+/.exec(magnitude)?.[0] ?? '';
|
|
227
|
+
return `${value < 0 && /[1-9]/.test(printed) ? '-' : '+'}${magnitude}`;
|
|
228
|
+
}
|
|
229
|
+
/** A lower-pane legend value without a declared word: K/M/B from 1K like the
|
|
230
|
+
* pane's axis, below that the built-in legend rule (at least 2 decimals, two
|
|
231
|
+
* significant digits below 1: "0.87", "-0.12", "0.050"), whatever the pane's
|
|
232
|
+
* height (see the module note). */
|
|
233
|
+
function formatWrunPaneLegendNumber(value) {
|
|
234
|
+
return Math.abs(value) >= WRUN_PANE_COMPACT_FROM
|
|
235
|
+
? formatWrunPaneNumber(value, WRUN_PANE_DEFAULT_DIGITS)
|
|
236
|
+
: formatTechnicalScriptLegendValue(value);
|
|
237
|
+
}
|
|
238
|
+
/** A wrun legend value: the output's declared format word when it carries
|
|
239
|
+
* one (`price` at the chart's precision), else a price at the chart's
|
|
240
|
+
* price precision on the price pane, the lower-pane legend rule otherwise
|
|
241
|
+
* (formatWrunPaneLegendNumber); a hole reads '-'. A proven twin
|
|
242
|
+
* (`builtinTwin`) prints by its built-in's legend rule instead, ahead of
|
|
243
|
+
* any declared word (the built-in has none).
|
|
244
|
+
* `projectPrice` is how a price prints while the pane's labels are
|
|
245
|
+
* projected (a memecoin pane reading in market cap, pulse-value-mode.util):
|
|
246
|
+
* it takes over exactly where the value is a price on the price pane (a
|
|
247
|
+
* twin's price line, a `price` word, the undeclared price-pane default), so
|
|
248
|
+
* the lower pane, a volume-scaled twin and every other declared word keep
|
|
249
|
+
* their rule. `options` are the output's declared companions (OT32,
|
|
250
|
+
* `formatOptions` on the mounted output): `decimals` or `signed` print the
|
|
251
|
+
* value through the shared formatter even without a word. A `unit` alone
|
|
252
|
+
* (an output's unit declared without a `format`, B15) keeps the placement's
|
|
253
|
+
* digits (the built-in legend decimals on a lower pane), grouped instead of
|
|
254
|
+
* K/M/B (a magnitude letter would land between the number and the unit),
|
|
255
|
+
* the unit after: "1.07%", "1,250.00M". Never a negative zero. */
|
|
256
|
+
export function formatWrunLegendValue(value, placement, format, options) {
|
|
257
|
+
if (!Number.isFinite(value))
|
|
258
|
+
return '-';
|
|
259
|
+
return unsignedZero(wrunLegendValueText(value, placement, format, options));
|
|
260
|
+
}
|
|
261
|
+
function wrunLegendValueText(value, placement, format, options) {
|
|
262
|
+
const { builtinTwin, projectPrice } = placement;
|
|
263
|
+
// A price on the price pane sits on the instrument tick first (roundLegendValueToTick).
|
|
264
|
+
const onTick = (price) => (placement.onPrice ? roundLegendValueToTick(price, placement.priceTick) : price);
|
|
265
|
+
if (builtinTwin !== undefined) {
|
|
266
|
+
const priceLine = placement.onPrice && !builtinTwin.volumeBased;
|
|
267
|
+
if (priceLine && projectPrice)
|
|
268
|
+
return projectPrice(value);
|
|
269
|
+
return formatTechnicalScriptLegendValue(value, priceLine ? placement.priceDigits : undefined, priceLine ? placement.priceTick : null);
|
|
270
|
+
}
|
|
271
|
+
const word = isWrunValueFormat(format) ? format : undefined;
|
|
272
|
+
if (word !== undefined || options?.decimals !== undefined || options?.signed !== undefined) {
|
|
273
|
+
if (word === 'price' && placement.onPrice && projectPrice)
|
|
274
|
+
return projectPrice(value);
|
|
275
|
+
return formatWrunValue(word === 'price' ? onTick(value) : value, word, { priceDigits: placement.priceDigits }, options);
|
|
276
|
+
}
|
|
277
|
+
if (options?.unit !== undefined && options.unit !== '') {
|
|
278
|
+
const digits = placement.onPrice ? clampDigits(placement.priceDigits) : technicalScriptLegendDecimals(value);
|
|
279
|
+
return formatWrunNumber(value, {
|
|
280
|
+
format: 'auto',
|
|
281
|
+
decimals: Math.min(digits, WRUN_MAX_VALUE_DECIMALS),
|
|
282
|
+
unit: options.unit,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
if (placement.onPrice) {
|
|
286
|
+
if (projectPrice)
|
|
287
|
+
return projectPrice(value);
|
|
288
|
+
const digits = clampDigits(placement.priceDigits);
|
|
289
|
+
const shown = onTick(value);
|
|
290
|
+
// partiallyFormatNumbers hands the raw number back for 0 decimals.
|
|
291
|
+
return digits === 0 ? shown.toFixed(0) : String(partiallyFormatNumbers(shown, digits));
|
|
292
|
+
}
|
|
293
|
+
return formatWrunPaneLegendNumber(value);
|
|
294
|
+
}
|
|
295
|
+
function clampDigits(digits) {
|
|
296
|
+
if (!Number.isFinite(digits))
|
|
297
|
+
return WRUN_PANE_DEFAULT_DIGITS;
|
|
298
|
+
return Math.min(14, Math.max(0, Math.round(digits)));
|
|
299
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The panel translator's door to the wrun style words (`wrun-panel-style.util`: the pane, axis,
|
|
3
|
+
* legend and per-kind style mappers both panel lanes run): `translatePanelToEngine` and
|
|
4
|
+
* `engineTableCell` (om-panel.util) read the mappers here, so the panel parse every boot path
|
|
5
|
+
* holds (the collab and push-panel stores, the window geometry, the frame worker) no longer
|
|
6
|
+
* carries them (docs/features/kscript/wrun/wrun-browser-runtime.md, "Boot doors").
|
|
7
|
+
*
|
|
8
|
+
* The door's contract:
|
|
9
|
+
* - Bound: the style module binds itself as it evaluates (`bindWrunPanelStyle`), so the wrun lane
|
|
10
|
+
* (the child mount imports it statically) translates in its own turn, as before.
|
|
11
|
+
* - The push lane (an agent's panel, useOmPanelOverlay) has no "not mine": its panels ride the same
|
|
12
|
+
* mappers, so its mount, already async (it awaits the panel's plot packs), loads the style module
|
|
13
|
+
* before it translates, once.
|
|
14
|
+
* - A translate before the bind is a caller that skipped that load: it throws, named.
|
|
15
|
+
*
|
|
16
|
+
* Pure on purpose (no import, no dynamic import): the frame worker's graph holds the panel parse.
|
|
17
|
+
*/
|
|
18
|
+
import type * as WrunPanelStyle from './wrun-panel-style.util.js';
|
|
19
|
+
export type WrunPanelStyleRuntime = Pick<typeof WrunPanelStyle, 'wrunBarsStyle' | 'wrunHeatmapStyle' | 'wrunHistogramStyle' | 'wrunLineStyle' | 'wrunPanelChrome' | 'wrunPanelCommonStyle' | 'wrunPanelFormatter' | 'wrunPaneColor' | 'wrunPieStyle' | 'wrunScatterStyle' | 'wrunTableStyle' | 'wrunTilesStyle'>;
|
|
20
|
+
/** Hand the style mappers over: the style module calls this as it evaluates. */
|
|
21
|
+
export declare function bindWrunPanelStyle(loaded: WrunPanelStyleRuntime): void;
|
|
22
|
+
/** The style mappers when bound, else undefined (a lane loads the style module first). */
|
|
23
|
+
export declare function wrunPanelStyleRuntime(): WrunPanelStyleRuntime | undefined;
|
|
24
|
+
/** The style mappers for a translate; a caller that skipped the load gets a named error. */
|
|
25
|
+
export declare function boundWrunPanelStyle(): WrunPanelStyleRuntime;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
let runtime;
|
|
2
|
+
/** Hand the style mappers over: the style module calls this as it evaluates. */
|
|
3
|
+
export function bindWrunPanelStyle(loaded) {
|
|
4
|
+
runtime = loaded;
|
|
5
|
+
}
|
|
6
|
+
/** The style mappers when bound, else undefined (a lane loads the style module first). */
|
|
7
|
+
export function wrunPanelStyleRuntime() {
|
|
8
|
+
return runtime;
|
|
9
|
+
}
|
|
10
|
+
/** The style mappers for a translate; a caller that skipped the load gets a named error. */
|
|
11
|
+
export function boundWrunPanelStyle() {
|
|
12
|
+
if (!runtime)
|
|
13
|
+
throw new Error('wrun panel style words are not loaded: import wrun-panel-style.util first');
|
|
14
|
+
return runtime;
|
|
15
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WRUN-STYLE g1 (SC02 SC03 SC04 SC06 SC07 SC08 SC16 SC18 SC19 SC20 SC21 SC22
|
|
3
|
+
* SC23 SC24 SC25 SC26 SC28 SC29 SC30 SC32 SC33 SC34 SC39): the style words of
|
|
4
|
+
* a wrun panel (`panels[i]`, `panels[i].series[j]` and the per-run frame
|
|
5
|
+
* chrome beside `rows`) mapped onto the engine's pane settings. One mapper per
|
|
6
|
+
* pane kind plus the words every kind shares; each returns a PATCH that
|
|
7
|
+
* `translatePanelToEngine` (om-panel.util, F-PANELS) merges shallowly into the
|
|
8
|
+
* settings it built from the structural words, a `series` array patch merging
|
|
9
|
+
* per index. A frame field overrides the declared word of the same name for
|
|
10
|
+
* that run; `markers` replaces the declared list. Absent words add no key, so
|
|
11
|
+
* today's drawing stays the default (conventions 10).
|
|
12
|
+
*
|
|
13
|
+
* Pure and worker safe (om-panel.util rides the frame worker): it imports the
|
|
14
|
+
* style foundation only. Colour words resolve here against `ctx.theme`
|
|
15
|
+
* (`wrunPaneColor`: a theme token becomes the chart's palette colour and an
|
|
16
|
+
* `#rrggbbaa` word the `rgba(r, g, b, a)` text the domain panes can read,
|
|
17
|
+
* SC16); the push lane passes no theme and its `#rrggbb` colours pass through
|
|
18
|
+
* unchanged. Font words resolve to CSS stacks (X14). Ranges are checked before
|
|
19
|
+
* a frame gets here (a wrun sheet by the kit, a push frame by the panel parse,
|
|
20
|
+
* om-panel-push-style.util), so nothing here refuses.
|
|
21
|
+
*/
|
|
22
|
+
import type { WrunPanelSeriesStyle, WrunPanelStyle } from '../../interfaces/wrun-runtime.interface.js';
|
|
23
|
+
import type { ParsedPanel } from '../chart/om-panel.util.js';
|
|
24
|
+
import { type WrunColorTheme } from './wrun-style-words.util.js';
|
|
25
|
+
import type { WrunPanelFrameChrome } from './wrun-frames.js';
|
|
26
|
+
/** A panel declaration as the mappers read it: a parsed frame's panel
|
|
27
|
+
* (`ParsedPanel['panel']`) or a sheet declaration (`WrunPanel`, which has no
|
|
28
|
+
* payload id). */
|
|
29
|
+
export type WrunStyledPanel = Omit<ParsedPanel['panel'], 'id'>;
|
|
30
|
+
export type WrunStyledPanelRows = ParsedPanel['rows'];
|
|
31
|
+
export type WrunStyledPanelSeries = NonNullable<WrunStyledPanel['series']>[number];
|
|
32
|
+
/** The pane chrome words (SC02 SC23). */
|
|
33
|
+
export type WrunPanelChromeWord = 'box' | 'grid' | 'none';
|
|
34
|
+
/** What a printed number stands for (titan `IMetaData.formatDomainValue`):
|
|
35
|
+
* 'x' = numeric x ticks, the hover title x, marker show_value, the stats row
|
|
36
|
+
* x; 'axis' = value-axis ticks; 'value' = every other value (hover rows, bar
|
|
37
|
+
* and end labels, legend latest, cells, tile values, the pie hover). `index`
|
|
38
|
+
* is the series index for curve and bars values, the tile index for tiles,
|
|
39
|
+
* the column index for tables, -1 otherwise. */
|
|
40
|
+
export type WrunPanelValueRole = 'x' | 'axis' | 'value';
|
|
41
|
+
export type WrunPanelValueFormatter = (value: number, role: WrunPanelValueRole, index: number) => string;
|
|
42
|
+
/** What the wrun lane hands the mappers: the chart's palette (tokens resolve
|
|
43
|
+
* against it), its price digits (the "price" format) and the display
|
|
44
|
+
* timezone shift (time-keyed panels). The push lane passes none. */
|
|
45
|
+
export interface WrunPanelTranslateContext {
|
|
46
|
+
theme?: WrunColorTheme;
|
|
47
|
+
priceDigits?: number;
|
|
48
|
+
timezoneOffsetMs?: number;
|
|
49
|
+
}
|
|
50
|
+
/** A settings patch: every key present is written, a `series` array merges
|
|
51
|
+
* per index. */
|
|
52
|
+
export type WrunPanelSettingsPatch = Record<string, unknown>;
|
|
53
|
+
/** The line mapper's answer: the pane settings patch plus one patch per
|
|
54
|
+
* declared series (index-aligned with `panel.series`). */
|
|
55
|
+
export interface WrunLineStylePatch {
|
|
56
|
+
settings: WrunPanelSettingsPatch;
|
|
57
|
+
series: WrunPanelSettingsPatch[];
|
|
58
|
+
}
|
|
59
|
+
/** The heatmap's key indices as the engine's matrix rows were numbered:
|
|
60
|
+
* column keys (`rows[i][0]`) and row keys (`rows[i][1]`) by `String(key)` in
|
|
61
|
+
* first-seen order, and the column count. */
|
|
62
|
+
export interface WrunHeatmapIndices {
|
|
63
|
+
x: Map<string, number>;
|
|
64
|
+
y: Map<string, number>;
|
|
65
|
+
columns: number;
|
|
66
|
+
}
|
|
67
|
+
/** Every `panels[i]` style word a wrun declaration may carry (g1 section 2
|
|
68
|
+
* plus the g6 side-strip sizes), in the contract's order. */
|
|
69
|
+
export declare const WRUN_PANEL_STYLE_KEYS: ReadonlyArray<keyof WrunPanelStyle>;
|
|
70
|
+
/** Every `panels[i].series[j]` style word. */
|
|
71
|
+
export declare const WRUN_PANEL_SERIES_STYLE_KEYS: ReadonlyArray<keyof WrunPanelSeriesStyle>;
|
|
72
|
+
/** Today's heatmap palette (the engine's three-stop default), used under
|
|
73
|
+
* scale "palette" when the panel declares none (SC06). */
|
|
74
|
+
export declare const WRUN_PANEL_HEATMAP_PALETTE: readonly string[];
|
|
75
|
+
/** The default `stroke_fade.edge_opacity` (SC03; the engine's own default). */
|
|
76
|
+
export declare const WRUN_PANEL_STROKE_FADE_EDGE_OPACITY = 0.35;
|
|
77
|
+
/** The badge chip's defaults (C2): the fill when `color` is absent, and the
|
|
78
|
+
* two inks `text_color` falls back to, picked by the fill's luminance. */
|
|
79
|
+
export declare const WRUN_PANEL_BADGE_DEFAULT_COLOR = "theme.accent";
|
|
80
|
+
export declare const WRUN_PANEL_BADGE_LIGHT_INK = "#f4f4f4";
|
|
81
|
+
export declare const WRUN_PANEL_BADGE_DARK_INK = "#0b0d12";
|
|
82
|
+
/** A table anchored at a top_* position starts under the pane's legend pill
|
|
83
|
+
* row (SC22): the same 24 px om-panel.util's `PANEL_TABLE_TOP_OFFSET_PX`
|
|
84
|
+
* gives the default anchor (pinned equal by the spec; restated here so this
|
|
85
|
+
* module never imports its own caller). */
|
|
86
|
+
export declare const WRUN_PANEL_TABLE_TOP_OFFSET_PX = 24;
|
|
87
|
+
/** Resolves a panel colour word for the domain panes (SC16): a theme token
|
|
88
|
+
* becomes the palette colour (alpha = palette alpha x token alpha), then an
|
|
89
|
+
* `#rrggbbaa` word becomes `rgba(r, g, b, a)` because the panes parse
|
|
90
|
+
* rgba() but not 8-digit hex. Without a theme (the push lane) a token and a
|
|
91
|
+
* 6-digit hex pass through unchanged. */
|
|
92
|
+
export declare function wrunPaneColor(word: string, theme?: WrunColorTheme): string;
|
|
93
|
+
/** A panel's effective chrome (SC02): the declared word, else "grid" for an
|
|
94
|
+
* unstacked line with x "index" or "number" (today's rich curve), else
|
|
95
|
+
* "box" (today's panel look). */
|
|
96
|
+
export declare function wrunPanelChrome(panel: WrunStyledPanel): WrunPanelChromeWord;
|
|
97
|
+
/** The ink a badge chip prints in when `text_color` is absent (C2): the
|
|
98
|
+
* WCAG relative luminance of the resolved fill, the dark ink above the cut,
|
|
99
|
+
* the light ink below it or on a fill the panes could not read. */
|
|
100
|
+
export declare function wrunPanelBadgeInk(fill: string): string;
|
|
101
|
+
/** The words every kind shares (SC07 SC24 SC28): `hover_card: false` turns
|
|
102
|
+
* the hover card off (nothing is sent when true), the tone pair lands as
|
|
103
|
+
* `toneColors`, and on line and bars `legend_style` picks the legend:
|
|
104
|
+
* "none" hides every series (its chip and its value), "pane" the in-canvas
|
|
105
|
+
* legend, "chips" the chips-left style, and "title", the default, lists
|
|
106
|
+
* each series once beside the title (titleLegendStyle). */
|
|
107
|
+
export declare function wrunPanelCommonStyle(panel: WrunStyledPanel, ctx: WrunPanelTranslateContext): WrunPanelSettingsPatch;
|
|
108
|
+
/** The line words (SC03 SC04 SC24 SC25 SC29 SC30 SC39): smoothing, the
|
|
109
|
+
* signed two-tone fill, fill fade, stroke fade, markers, dots, end labels,
|
|
110
|
+
* glow, motion, latest-value chips and the axis words on the pane; fill,
|
|
111
|
+
* fill ink, style, width, dash, dots, end label and legend membership per
|
|
112
|
+
* series. `y_title` is the rich curve's caption and a box line's axis title
|
|
113
|
+
* (the effective chrome decides, SC02). */
|
|
114
|
+
export declare function wrunLineStyle(panel: WrunStyledPanel, chrome: WrunPanelFrameChrome | undefined, rows: WrunStyledPanelRows, ctx: WrunPanelTranslateContext): WrunLineStylePatch;
|
|
115
|
+
/** The bars words (SC19 SC23 SC24 SC39, C2): sign colouring (the tones
|
|
116
|
+
* come from the common words), the axis words, the bar shape, the badge
|
|
117
|
+
* chip and legend membership per series (`series[j].legend: false` keeps
|
|
118
|
+
* that series out of the legend chips, a `series` patch merged per index);
|
|
119
|
+
* per-bar colours are row data the caller maps. */
|
|
120
|
+
export declare function wrunBarsStyle(panel: WrunStyledPanel, chrome: WrunPanelFrameChrome | undefined, _rows: WrunStyledPanelRows, ctx: WrunPanelTranslateContext): WrunPanelSettingsPatch;
|
|
121
|
+
/** The histogram words beyond its colour, labels and bins (the caller's,
|
|
122
|
+
* SC38): the chrome, the axis words of its curve bars sub-plan (SC23 SC39),
|
|
123
|
+
* the bar shape and the badge chip (C2). */
|
|
124
|
+
export declare function wrunHistogramStyle(panel: WrunStyledPanel, chrome: WrunPanelFrameChrome | undefined, _rows: WrunStyledPanelRows, ctx: WrunPanelTranslateContext): WrunPanelSettingsPatch;
|
|
125
|
+
/** The scatter words (SC20 SC21 SC23 SC32 SC33 SC39): pinned ranges, guides
|
|
126
|
+
* and quadrants (frame first), trails (each row's group is the ordinal of
|
|
127
|
+
* its key in first-seen order, the index of that key's legend chip), label
|
|
128
|
+
* overlap, the axis words and the legend chips (one per distinct key in
|
|
129
|
+
* first-seen order, in the colour of that key's last row, absent when that
|
|
130
|
+
* row has none: the chip then matches the default ink the engine draws
|
|
131
|
+
* the point and its trail in). */
|
|
132
|
+
export declare function wrunScatterStyle(panel: WrunStyledPanel, chrome: WrunPanelFrameChrome | undefined, rows: WrunStyledPanelRows, ctx: WrunPanelTranslateContext): WrunPanelSettingsPatch;
|
|
133
|
+
/** The pie words (SC23 SC33 SC34): the chrome, the legend chips (one per
|
|
134
|
+
* slice), the hole text (a frame `hole_text`, else the slice total printed
|
|
135
|
+
* through the panel format, `String(sum)` without one), the hole caption
|
|
136
|
+
* (frame first), slice gaps and the slice border. */
|
|
137
|
+
export declare function wrunPieStyle(panel: WrunStyledPanel, chrome: WrunPanelFrameChrome | undefined, rows: WrunStyledPanelRows, ctx: WrunPanelTranslateContext): WrunPanelSettingsPatch;
|
|
138
|
+
/** The heatmap words (SC06 SC18): under scale "palette" the stops (the
|
|
139
|
+
* declared ones, else today's three) and the bounds (frame first); under
|
|
140
|
+
* "signed" none of them, so the engine's diverging scale draws through the
|
|
141
|
+
* common tone pair. The highlight resolves its keys to the engine's row and
|
|
142
|
+
* column indices (a key absent from the rows is dropped), the axis nouns
|
|
143
|
+
* pass through, and a frame summary is fitted to the column count. */
|
|
144
|
+
export declare function wrunHeatmapStyle(panel: WrunStyledPanel, chrome: WrunPanelFrameChrome | undefined, indices: WrunHeatmapIndices, ctx: WrunPanelTranslateContext): WrunPanelSettingsPatch;
|
|
145
|
+
/** The tiles words: none of their own. `columns`, `accent` and a tile's
|
|
146
|
+
* colour ride the structural translation (the caller's, SC26 SC15), the
|
|
147
|
+
* tone pair and the hover card are common words (SC28 SC07) and the tile
|
|
148
|
+
* formats reach the engine through {@link wrunPanelFormatter} (SC26). The
|
|
149
|
+
* seam stays so a tiles word lands here without touching the caller. */
|
|
150
|
+
export declare function wrunTilesStyle(_panel: WrunStyledPanel, _rows: WrunStyledPanelRows, _ctx: WrunPanelTranslateContext): WrunPanelSettingsPatch;
|
|
151
|
+
/** The table words onto the engine's Table payload (SC22 SC35; the
|
|
152
|
+
* WRUN-CAPS keys verbatim): the anchor and offset (`y` adds the legend
|
|
153
|
+
* clearance under a top_* anchor), widths, padding, type, alignment, inks
|
|
154
|
+
* (resolved), the background fill and gradient, the border and grid lines,
|
|
155
|
+
* and the header column. Only declared words patch the caller's defaults. */
|
|
156
|
+
export declare function wrunTableStyle(panel: WrunStyledPanel, ctx: WrunPanelTranslateContext): WrunPanelSettingsPatch;
|
|
157
|
+
/** The engine's number formatter for a panel (SC08 SC26 SC40), built only
|
|
158
|
+
* when a format word is declared somewhere on it: `format`, `decimals`,
|
|
159
|
+
* `signed`, `unit` (role 'value'; role 'axis' prints the same without the
|
|
160
|
+
* sign), `x_format`, `x_decimals`, `x_unit` (role 'x'), a tile row's own
|
|
161
|
+
* format (element 5: it replaces the panel's format and keeps its
|
|
162
|
+
* decimals, sign and unit, by tile index) or a table column's words
|
|
163
|
+
* (`series[j]`, in place of the table's, by column index). Every spec
|
|
164
|
+
* carries the chart's price digits for "price".
|
|
165
|
+
*
|
|
166
|
+
* A number whose words are not declared keeps the engine's own text
|
|
167
|
+
* (FREEZE 2.2: formatWrunNumber runs only where a surface declares a
|
|
168
|
+
* word): the hook answers a non-string, which every engine surface reads as
|
|
169
|
+
* "print your own" (see WRUN_ENGINE_FORMATTING). One exception: role
|
|
170
|
+
* 'axis' on a curve pane (line, histogram) always prints, because the
|
|
171
|
+
* caller also hands it to the pane's price scale as `getYLabel`, which has
|
|
172
|
+
* no fallback (a non-string prints as an empty label); without value words
|
|
173
|
+
* it prints the foundation's undeclared text. */
|
|
174
|
+
export declare function wrunPanelFormatter(panel: WrunStyledPanel, rows: WrunStyledPanelRows, ctx: WrunPanelTranslateContext): WrunPanelValueFormatter | undefined;
|