@orangecharts/wrun-chart-host 0.14.0 → 0.15.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/constants/feature-flags.constants.d.ts +1 -0
- package/dist/constants/feature-flags.constants.js +4 -0
- package/dist/host-env.d.ts +14 -0
- package/dist/host-env.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +44 -1
- package/dist/market-data/venues/index.d.ts +2 -2
- package/dist/market-data/venues/opra.js +3 -3
- package/dist/market-data/venues/stocks.contract.copy.json +3 -2
- package/dist/market-data/venues/stocks.d.ts +2 -2
- package/dist/market-data/venues/stocks.js +10 -9
- package/dist/settings-templates/indicator-fields.js +15 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +23 -0
- package/dist/utility/chart/cache-alignment.util.js +36 -6
- package/dist/utility/chart/footprint-band.util.d.ts +21 -5
- package/dist/utility/chart/footprint-band.util.js +53 -14
- package/dist/utility/chart/wrun-run-result.util.d.ts +9 -1
- package/dist/utility/chart/wrun-run-result.util.js +8 -2
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +6 -2
- package/dist/utility/wrun/wrun-batched-marks.util.js +5 -3
- package/dist/utility/wrun/wrun-canvases.util.d.ts +24 -7
- package/dist/utility/wrun/wrun-canvases.util.js +92 -27
- package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
- package/dist/utility/wrun/wrun-hover.util.js +24 -13
- package/dist/utility/wrun/wrun-live-tick.util.js +22 -15
- package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-output-words.util.js +51 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +32 -0
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +8 -2
- package/dist/utility/wrun/wrun-overlay-run.util.js +31 -4
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -1
- package/dist/utility/wrun/wrun-panel-mount.util.js +102 -5
- package/dist/utility/wrun/wrun-run-health.util.d.ts +6 -3
- package/dist/utility/wrun/wrun-run-health.util.js +5 -2
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +25 -8
- package/dist/utility/wrun/wrun-script-inputs.util.js +145 -45
- package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-style-names.util.js +74 -0
- package/package.json +3 -3
|
@@ -83,7 +83,16 @@
|
|
|
83
83
|
* and wrun-style-patch.util; a `colors` row and a prefixed target's rows
|
|
84
84
|
* repaint through a rerun). A cloud record mounts the same rows (the registry
|
|
85
85
|
* loader builds both lanes' records here, over the full sheet): the one pass
|
|
86
|
-
* paints either row source's batch through the chart's own builders.
|
|
86
|
+
* paints either row source's batch through the chart's own builders. The
|
|
87
|
+
* page's words for a batched section or a renderer come first from the
|
|
88
|
+
* sheet's `style_names` table (wrun-style-names.util, the one reader): its
|
|
89
|
+
* label titles the line (styleTargetTitle) and its colour names name each
|
|
90
|
+
* swatch of the line's colours row (`swatchNames`). Its entry for an output
|
|
91
|
+
* or a heatmap names colours alone (the title stays their own `label`): a
|
|
92
|
+
* heatmap's palette stops, an output's two-tone pair, and a `color_by` ladder
|
|
93
|
+
* whose every rung it names, which gains a colours row even where an unnamed
|
|
94
|
+
* ladder has none (three or more rungs, a line's, an inset strip's:
|
|
95
|
+
* outputColorList). A sheet without the table reads as before.
|
|
87
96
|
*
|
|
88
97
|
* The layout (buildWrunScriptLayout) groups the flat rows into pages and
|
|
89
98
|
* sections: from the sheet's `layout` when it declares one (params before
|
|
@@ -108,6 +117,7 @@ import { isWrunColorWord, wrunThemeTokenOfPacked, wrunThemeTokenWord } from './w
|
|
|
108
117
|
import { isWrunColorParam, isWrunStyleParam, wrunColorArrayKey, wrunColorPalette, wrunColorParamDefault, wrunColorSettingString, wrunLineStyles, wrunParamChoices, wrunSelectOptionValue, wrunStyleBinding, parseWrunStyleTarget, wrunVisibilityOwnedOutputs, wrunVisibilityOwners, } from './wrun-color-settings.util.js';
|
|
109
118
|
import { findWrunVisibilityTarget, WRUN_HANDLE_KIND_RULES, WRUN_VISIBILITY_RULES, wrunVisibilityEntryTarget, wrunVisibilityTargetAt, } from './wrun-visibility-table.js';
|
|
110
119
|
import { isTruthySetting, wrunCodedWords } from './wrun-setting-words.util.js';
|
|
120
|
+
import { wrunStyleNameOf, wrunStyleSlotNames, wrunStyleTitle } from './wrun-style-names.util.js';
|
|
111
121
|
import { wrunRowVisibleHere, wrunVisibleBySettingKeys } from './wrun-market-facts.util.js';
|
|
112
122
|
import { bitmaskValue, finiteNumber, nonEmptyString, numericValue, toggleValue, wrunMultiLabels, wrunTimeValue, } from './wrun-param-values.util.js';
|
|
113
123
|
import { wrunLegendLiteral, wrunTextParamCap, wrunTextParamDefault, wrunTextValueWithinCap, } from './wrun-text-params.util.js';
|
|
@@ -431,6 +441,40 @@ function twoTonePair(output, kind) {
|
|
|
431
441
|
return colors.length === 2 ? [...colors] : undefined;
|
|
432
442
|
return colors.length >= 2 ? colors.slice(0, 2) : undefined;
|
|
433
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* The colour list an output's `colors` Style row recolours (contract C1), as declared:
|
|
446
|
+
* - a bar's two-tone pair (twoTonePair), named or not: its sign palette's up and down swatches, or its two-rung
|
|
447
|
+
* ladder's rungs;
|
|
448
|
+
* - any other list the run-result adapter paints from the output's own `colors`, only where the sheet's
|
|
449
|
+
* `style_names` table names every one of its slots: a `color_by` ladder of any length on an output that styles (a
|
|
450
|
+
* bar's of three or more rungs, a line's, a mark's: the adapter's ladder reads it whole) or on an inset strip
|
|
451
|
+
* (wrunInsetLook: its ladder's palette, else its sign pair, up then down). Unnamed, its swatches could say only
|
|
452
|
+
* "Color n", so the page offers no row for it, as before the table.
|
|
453
|
+
* Undefined for anything else: a packed per-bar colour, a list holding a word that is no colour, a candle tint.
|
|
454
|
+
*/
|
|
455
|
+
function outputColorList(metadata, output, kind) {
|
|
456
|
+
const namesOf = (colors) => wrunStyleSlotNames(wrunStyleNameOf(metadata, output.name), colors.length);
|
|
457
|
+
const ladder = output.color_by !== undefined;
|
|
458
|
+
const pair = kind === undefined ? undefined : twoTonePair(output, kind);
|
|
459
|
+
if (pair !== undefined) {
|
|
460
|
+
const names = namesOf(pair);
|
|
461
|
+
const swatches = ladder ? ['stop', 'stop'] : ['up', 'down'];
|
|
462
|
+
return { colors: pair, swatches, ...(names !== undefined ? { names } : {}) };
|
|
463
|
+
}
|
|
464
|
+
const inset = output.plot === 'inset';
|
|
465
|
+
if (kind === undefined && !inset)
|
|
466
|
+
return undefined;
|
|
467
|
+
if (output.color_packed_by !== undefined || !Array.isArray(output.colors))
|
|
468
|
+
return undefined;
|
|
469
|
+
const declared = output.colors;
|
|
470
|
+
if (!declared.every((color) => nonEmptyString(color) !== undefined))
|
|
471
|
+
return undefined;
|
|
472
|
+
const colors = ladder ? [...declared] : inset && declared.length >= 2 ? declared.slice(0, 2) : [];
|
|
473
|
+
const names = colors.length === 0 ? undefined : namesOf(colors);
|
|
474
|
+
if (names === undefined)
|
|
475
|
+
return undefined;
|
|
476
|
+
return { colors, swatches: ladder ? colors.map(() => 'stop') : ['up', 'down'], names };
|
|
477
|
+
}
|
|
434
478
|
/** True when a line strokes colours of its own and never reads its static
|
|
435
479
|
* `color` (style-rows audit item 3): two or more OT13 `gradient` stops (the
|
|
436
480
|
* look patch lays them as `gradientColors`, wrun-output-style.util) or an
|
|
@@ -457,16 +501,17 @@ function strokesOwnColors(output) {
|
|
|
457
501
|
* stops, an OT14 split's up / down pair; style-rows audit item 3), whose
|
|
458
502
|
* width, lineStyle and opacity rows stay; never on a candle group (its
|
|
459
503
|
* colours are a pair).
|
|
460
|
-
* - `colors
|
|
461
|
-
*
|
|
462
|
-
* ladder
|
|
504
|
+
* - `colors` (`hasColors`, outputColorList): a bar's two-tone pair
|
|
505
|
+
* (twoTonePair) in place of `color`: the up and down swatches of its sign
|
|
506
|
+
* palette, or the two rungs of its ladder; and a `color_by` ladder of any
|
|
507
|
+
* other length or kind whose every rung the sheet's `style_names` names.
|
|
463
508
|
* - `opacity`: it folds into the static colour (a gradient's stops and a
|
|
464
509
|
* split's pair alike) and an area's fill tint, so an area always carries
|
|
465
510
|
* it, a bar when its static colour paints, and a line or mark only when
|
|
466
511
|
* the sheet declares one (a declared opacity REPLACES the picked colour's
|
|
467
512
|
* alpha, so it needs its own control).
|
|
468
513
|
*/
|
|
469
|
-
function stylePropertiesOf(output, kind) {
|
|
514
|
+
function stylePropertiesOf(output, kind, hasColors) {
|
|
470
515
|
const staticColor = kind !== 'candle' &&
|
|
471
516
|
output.color_by === undefined &&
|
|
472
517
|
output.color_packed_by === undefined &&
|
|
@@ -478,7 +523,7 @@ function stylePropertiesOf(output, kind) {
|
|
|
478
523
|
...(staticWidth ? ['width'] : []),
|
|
479
524
|
...(kind === 'line' || kind === 'area' ? ['lineStyle'] : []),
|
|
480
525
|
...(staticColor && !strokesOwnColors(output) ? ['color'] : []),
|
|
481
|
-
...(
|
|
526
|
+
...(hasColors ? ['colors'] : []),
|
|
482
527
|
...(opacity ? ['opacity'] : []),
|
|
483
528
|
];
|
|
484
529
|
}
|
|
@@ -541,6 +586,10 @@ const WRUN_STYLE_KEYS = {
|
|
|
541
586
|
['width', 'width'],
|
|
542
587
|
['line_style', 'lineStyle'],
|
|
543
588
|
]),
|
|
589
|
+
// A flags section's colours by part (fill, edge, text): a colour param bound to them is that row.
|
|
590
|
+
flags: new Map([['colors', 'colors']]),
|
|
591
|
+
// Every batched kind is listed (the type below): each offers a colours row, so a param bound to its keys must take
|
|
592
|
+
// that row's place, or the page shows two controls over one colour (flags missed it until the dark pool round).
|
|
544
593
|
};
|
|
545
594
|
const WRUN_OUTPUT_STYLE_KEYS = WRUN_STYLE_KEYS.outputs;
|
|
546
595
|
/** An output style property word in either spelling: the om binding's
|
|
@@ -673,7 +722,7 @@ function declaredStyleKnobs(metadata) {
|
|
|
673
722
|
function undeclaredWidthOf(kind) {
|
|
674
723
|
return kind === 'mark' ? 2 : 1;
|
|
675
724
|
}
|
|
676
|
-
function styleRowDefault(output, paletteAt, property, kind) {
|
|
725
|
+
function styleRowDefault(output, paletteAt, property, kind, colors) {
|
|
677
726
|
switch (property) {
|
|
678
727
|
case 'visible':
|
|
679
728
|
return output.visible !== false;
|
|
@@ -688,7 +737,7 @@ function styleRowDefault(output, paletteAt, property, kind) {
|
|
|
688
737
|
nonEmptyString(output.colors?.[0]) ??
|
|
689
738
|
WRUN_OUTPUT_DEFAULT_PALETTE[paletteAt % WRUN_OUTPUT_DEFAULT_PALETTE.length]);
|
|
690
739
|
case 'colors':
|
|
691
|
-
return
|
|
740
|
+
return colors?.colors ?? [];
|
|
692
741
|
default: {
|
|
693
742
|
const opacity = finiteNumber(output.opacity);
|
|
694
743
|
return opacity !== undefined && opacity >= 0 && opacity <= 1 ? opacity : 1;
|
|
@@ -699,7 +748,7 @@ function styleRowDefault(output, paletteAt, property, kind) {
|
|
|
699
748
|
* construction: no init slot, it writes only its target's colour(s) /
|
|
700
749
|
* width / line_style / opacity through the paint seam, or its visibility
|
|
701
750
|
* after integration. */
|
|
702
|
-
function styleRowOf(target, property, defaultValue, swatches) {
|
|
751
|
+
function styleRowOf(target, property, defaultValue, swatches, swatchNames) {
|
|
703
752
|
return {
|
|
704
753
|
name: wrunStyleRowName(target, property),
|
|
705
754
|
// The property key: the dialog draws the frozen localized word for it.
|
|
@@ -710,14 +759,18 @@ function styleRowOf(target, property, defaultValue, swatches) {
|
|
|
710
759
|
...(property === 'width' ? { constraints: { min: 0, max: 20, step: 0.5 } } : {}),
|
|
711
760
|
...(property === 'opacity' ? { constraints: { min: 0, max: 1, step: 0.05 } } : {}),
|
|
712
761
|
...(swatches !== undefined ? { swatches } : {}),
|
|
762
|
+
...(swatchNames !== undefined ? { swatchNames } : {}),
|
|
713
763
|
settingsTier: 'redraw',
|
|
714
764
|
affectsCompute: false,
|
|
715
765
|
styleOf: { output: target, property },
|
|
716
766
|
};
|
|
717
767
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
768
|
+
/** One Style row of a drawn output; a `colors` row recolours its colour list (outputColorList), each swatch saying
|
|
769
|
+
* what it paints and carrying the sheet's name for it when the table names them. */
|
|
770
|
+
function styleRow(output, paletteAt, property, kind, colors) {
|
|
771
|
+
const list = property === 'colors' ? colors : undefined;
|
|
772
|
+
const defaultValue = styleRowDefault(output, paletteAt, property, kind, colors);
|
|
773
|
+
return styleRowOf(output.name, property, defaultValue, list?.swatches, list?.names);
|
|
721
774
|
}
|
|
722
775
|
/** A declared colour word, as written: a hex or rgb colour, or a theme
|
|
723
776
|
* token (`theme.up`); anything else (a number, an `@param` the extractor
|
|
@@ -788,7 +841,9 @@ function undeclaredTextColorOf(renderer) {
|
|
|
788
841
|
* records only feed another's tooltips (`tooltip_from`) never draws and is
|
|
789
842
|
* no target; every other renderer kind (shape, bgcolor, barcolor, table,
|
|
790
843
|
* stats_row, inset) offers Visible only;
|
|
791
|
-
* - a heatmap (`heatmap:<name>`): its declared palette
|
|
844
|
+
* - a heatmap (`heatmap:<name>`): its declared palette, each stop carrying
|
|
845
|
+
* the sheet's name for it when the `style_names` table names every one
|
|
846
|
+
* (`swatchNames`);
|
|
792
847
|
* - a price profile (`profile:<name>`): its colours: a footprint's buy /
|
|
793
848
|
* sell pair (theme up / down when undeclared, the canvas mount's rule)
|
|
794
849
|
* wherever it paints: never on a cluster, ladder or imbalance_only grid of
|
|
@@ -809,17 +864,22 @@ function undeclaredTextColorOf(renderer) {
|
|
|
809
864
|
* LOOK_DEFAULTS); a ray its width (default 1) and line style (default
|
|
810
865
|
* solid) too. A flags section (`flags:<name>`) takes its colours alone (it
|
|
811
866
|
* declares no opacity). Its look, size, caption and position take no row: a
|
|
812
|
-
* param binds them (`style_targets`)
|
|
867
|
+
* param binds them (`style_targets`). Its colours row carries the sheet's
|
|
868
|
+
* name for each slot when the `style_names` table names every one
|
|
869
|
+
* (`swatchNames`, wrun-style-names.util wrunStyleSlotNames);
|
|
813
870
|
* - a band (`range:<upper>/<lower>#<n>`, `fill:<first>/<second>#<n>`), a box,
|
|
814
871
|
* a segment, a sheet drawing, a draw-API handle kind, a matrix and a panel:
|
|
815
872
|
* Visible only (their colours ride params or the declaration).
|
|
816
873
|
*/
|
|
817
|
-
function childStyleRows(targets, declared) {
|
|
874
|
+
function childStyleRows(metadata, targets, declared) {
|
|
818
875
|
const rows = [];
|
|
819
|
-
const add = (target, property, defaultValue, swatches) => {
|
|
820
|
-
if (!declared.has(`${target}.${property}`))
|
|
821
|
-
rows.push(styleRowOf(target, property, defaultValue, swatches));
|
|
876
|
+
const add = (target, property, defaultValue, swatches, swatchNames) => {
|
|
877
|
+
if (!declared.has(`${target}.${property}`)) {
|
|
878
|
+
rows.push(styleRowOf(target, property, defaultValue, swatches, swatchNames));
|
|
879
|
+
}
|
|
822
880
|
};
|
|
881
|
+
// A batched or heatmap colours row's slot names: the table's, when it names every slot of the list (else none).
|
|
882
|
+
const slotNames = (target, colors) => wrunStyleSlotNames(wrunStyleNameOf(metadata, target), colors.length);
|
|
823
883
|
const stops = (palette) => palette.map(() => 'stop');
|
|
824
884
|
for (const { target, section, kind, entry } of targets) {
|
|
825
885
|
if (section === 'outputs')
|
|
@@ -836,7 +896,7 @@ function childStyleRows(targets, declared) {
|
|
|
836
896
|
case 'heatmaps': {
|
|
837
897
|
const palette = paletteOf(entry.palette);
|
|
838
898
|
if (palette !== undefined)
|
|
839
|
-
add(target, 'colors', palette, stops(palette));
|
|
899
|
+
add(target, 'colors', palette, stops(palette), slotNames(target, palette));
|
|
840
900
|
break;
|
|
841
901
|
}
|
|
842
902
|
case 'profiles': {
|
|
@@ -867,7 +927,7 @@ function childStyleRows(targets, declared) {
|
|
|
867
927
|
const colors = batchedColorsOf(entry.colors);
|
|
868
928
|
if (colors !== undefined) {
|
|
869
929
|
const swatches = colors.map((_color, at) => section === 'marks' && at < 2 ? (at === 0 ? 'sell' : 'buy') : 'stop');
|
|
870
|
-
add(target, 'colors', colors, swatches);
|
|
930
|
+
add(target, 'colors', colors, swatches, slotNames(target, colors));
|
|
871
931
|
}
|
|
872
932
|
const opacity = section === 'marks'
|
|
873
933
|
? (finiteNumber(entry.opacity_pct) ?? 30) / 100
|
|
@@ -883,7 +943,7 @@ function childStyleRows(targets, declared) {
|
|
|
883
943
|
case 'flags': {
|
|
884
944
|
const colors = batchedColorsOf(entry.colors);
|
|
885
945
|
if (colors !== undefined)
|
|
886
|
-
add(target, 'colors', colors, stops(colors));
|
|
946
|
+
add(target, 'colors', colors, stops(colors), slotNames(target, colors));
|
|
887
947
|
break;
|
|
888
948
|
}
|
|
889
949
|
default:
|
|
@@ -975,8 +1035,9 @@ function drawnStyleOutputs(metadata, targets = wrunVisibilityTargets(metadata))
|
|
|
975
1035
|
: []);
|
|
976
1036
|
}
|
|
977
1037
|
/** The style rows of a sheet's drawn targets (wrun-visibility-table.ts, in
|
|
978
|
-
* its order): the outputs' rows, by how each draws (a candle tint
|
|
979
|
-
* inset strip
|
|
1038
|
+
* its order): the outputs' rows, by how each draws (a candle tint offers
|
|
1039
|
+
* Visible only, an inset strip Visible and the colours the sheet's
|
|
1040
|
+
* `style_names` names: outputColorList), then every other drawn target's
|
|
980
1041
|
* (childStyleRows). */
|
|
981
1042
|
function styleRows(metadata) {
|
|
982
1043
|
const targets = wrunVisibilityTargets(metadata);
|
|
@@ -984,17 +1045,27 @@ function styleRows(metadata) {
|
|
|
984
1045
|
const rows = [];
|
|
985
1046
|
for (const { output, paletteAt, draw } of drawnStyleOutputs(metadata, targets)) {
|
|
986
1047
|
const kind = draw.style;
|
|
987
|
-
|
|
1048
|
+
const colors = outputColorList(metadata, output, kind);
|
|
1049
|
+
const properties = kind !== undefined
|
|
1050
|
+
? stylePropertiesOf(output, kind, colors !== undefined)
|
|
1051
|
+
: colors !== undefined
|
|
1052
|
+
? ['visible', 'colors']
|
|
1053
|
+
: ['visible'];
|
|
1054
|
+
for (const property of properties) {
|
|
988
1055
|
if (declared.has(`${output.name}.${property}`))
|
|
989
1056
|
continue;
|
|
990
1057
|
// The output's `visible_by` rides its Style rows: where it mounts nothing, they hide.
|
|
991
|
-
|
|
1058
|
+
const row = styleRow(output, paletteAt, property, kind ?? 'line', colors);
|
|
1059
|
+
rows.push({ ...row, ...wrunRowVisibleBy(output.visible_by) });
|
|
992
1060
|
}
|
|
993
1061
|
}
|
|
994
|
-
rows.push(...childStyleRows(targets, declared));
|
|
1062
|
+
rows.push(...childStyleRows(metadata, targets, declared));
|
|
995
1063
|
return rows;
|
|
996
1064
|
}
|
|
997
|
-
/** The sections whose readout `label` titles their Style line
|
|
1065
|
+
/** The sections whose own readout `label` titles their Style line where the sheet's `style_names` table gives none
|
|
1066
|
+
* (wrunStyleTitle's order; a heatmap's entry in the table names its colours alone, so a heatmap always reads its
|
|
1067
|
+
* own). A renderer's line takes the table's label or its name: a renderer key named `label` says something else and
|
|
1068
|
+
* titles nothing. */
|
|
998
1069
|
const LABELLED_STYLE_SECTIONS = new Set(['heatmaps', 'marks', 'spans', 'rays', 'flags']);
|
|
999
1070
|
/** A draw-API handle kind's Style line title, the dialog's English fallback
|
|
1000
1071
|
* (WrunLayoutPanel localizes a handles section by its id). */
|
|
@@ -1011,12 +1082,16 @@ export function isWrunLocalizedStyleTarget(target) {
|
|
|
1011
1082
|
}
|
|
1012
1083
|
/** A style target as the Style page names it, the legend's rule
|
|
1013
1084
|
* (wrunLegendName: a declared label, else the name read as words, `oi_change`
|
|
1014
|
-
* -> "OI change"): an output by its `label
|
|
1015
|
-
* its
|
|
1016
|
-
* by its own `label` when it declares one; a second
|
|
1017
|
-
* numbered), a sheet drawing by its name, a handle
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1085
|
+
* -> "OI change"): an output by its own `label` (the sheet's `style_names`
|
|
1086
|
+
* names an output's colours, never its line), a band by its sides' names
|
|
1087
|
+
* (`Upper / Lower`; a range by its own `label` when it declares one; a second
|
|
1088
|
+
* band over the same pair numbered), a sheet drawing by its name, a handle
|
|
1089
|
+
* kind by its kind's word; anything else in the one order every surface
|
|
1090
|
+
* titles a drawn target by (wrun-style-names.util wrunStyleTitle): the
|
|
1091
|
+
* sheet's `style_names` label (a batched section, a renderer; a heatmap's
|
|
1092
|
+
* entry gives none), else a heatmap's or a batched section's readout
|
|
1093
|
+
* `label`, else the name (a renderer, a profile, a docked level, a box, a
|
|
1094
|
+
* segment, a matrix, a panel). */
|
|
1020
1095
|
function styleTargetTitle(metadata, target) {
|
|
1021
1096
|
const { kind, name } = parseWrunStyleTarget(target);
|
|
1022
1097
|
const outputTitle = (output) => {
|
|
@@ -1041,7 +1116,7 @@ function styleTargetTitle(metadata, target) {
|
|
|
1041
1116
|
return wrunLegendName(name.slice(name.indexOf(':') + 1));
|
|
1042
1117
|
const found = findWrunVisibilityTarget(metadata, target);
|
|
1043
1118
|
const labelled = found !== undefined && LABELLED_STYLE_SECTIONS.has(found.section) ? found.entry.label : undefined;
|
|
1044
|
-
return
|
|
1119
|
+
return wrunStyleTitle(metadata, target, name, labelled);
|
|
1045
1120
|
}
|
|
1046
1121
|
// ---------------------------------------------------------------------------
|
|
1047
1122
|
// The flat list (the persistence whitelist).
|
|
@@ -1227,30 +1302,55 @@ function paramInput(param, base) {
|
|
|
1227
1302
|
* its label and hint from that build, matched by name (a unit composite and
|
|
1228
1303
|
* its value member, which share a name, each from its own kind). An older
|
|
1229
1304
|
* build stamped a param's description as its label and no hint; the saved
|
|
1230
|
-
* indicator reads the same as a fresh add without a rerun.
|
|
1231
|
-
*
|
|
1232
|
-
*
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1305
|
+
* indicator reads the same as a fresh add without a rerun. A style row keeps
|
|
1306
|
+
* its label (its property key) and takes the swatch names the sheet's
|
|
1307
|
+
* `style_names` table gives its colours now (`swatchNames`, or none), so a
|
|
1308
|
+
* row persisted before the table names its swatches as a fresh add does.
|
|
1309
|
+
* Values, types and every other key stay as persisted; a row the sheet no
|
|
1310
|
+
* longer builds keeps its own; a row whose words already match is returned
|
|
1311
|
+
* as is. `options` builds the words as the mount did (a port's hint rule,
|
|
1312
|
+
* WrunRowBuildOptions), so a row persisted before the rule reads without its
|
|
1313
|
+
* encoding legend.
|
|
1236
1314
|
*/
|
|
1237
1315
|
export function wrunRowsWithSheetWords(rows, sheet, options) {
|
|
1238
|
-
if (sheet === undefined
|
|
1316
|
+
if (sheet === undefined)
|
|
1239
1317
|
return [...rows];
|
|
1240
1318
|
const keyOf = (row) => `${row.virtual === true ? 'virtual' : 'value'}:${row.name}`;
|
|
1241
1319
|
const fresh = new Map();
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
fresh.
|
|
1320
|
+
if (Array.isArray(sheet.params) && sheet.params.length > 0) {
|
|
1321
|
+
for (const row of buildWrunScriptInputs({ params: sheet.params }, options)) {
|
|
1322
|
+
if (row.styleOf === undefined && !fresh.has(keyOf(row)))
|
|
1323
|
+
fresh.set(keyOf(row), row);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
// The swatch names the sheet gives its Style rows now, by row name (none to build without a table).
|
|
1327
|
+
const swatchNames = new Map();
|
|
1328
|
+
if (Array.isArray(sheet.style_names)) {
|
|
1329
|
+
for (const row of styleRows(sheet))
|
|
1330
|
+
if (row.swatchNames !== undefined)
|
|
1331
|
+
swatchNames.set(row.name, row.swatchNames);
|
|
1245
1332
|
}
|
|
1246
1333
|
return rows.map((row) => {
|
|
1247
|
-
|
|
1334
|
+
if (row.styleOf !== undefined) {
|
|
1335
|
+
const names = swatchNames.get(row.name);
|
|
1336
|
+
if (sameWords(row.swatchNames, names))
|
|
1337
|
+
return row;
|
|
1338
|
+
const { swatchNames: _persistedNames, ...rest } = row;
|
|
1339
|
+
return names === undefined ? rest : { ...rest, swatchNames: names };
|
|
1340
|
+
}
|
|
1341
|
+
const built = fresh.get(keyOf(row));
|
|
1248
1342
|
if (built === undefined || (row.label === built.label && row.hint === built.hint))
|
|
1249
1343
|
return row;
|
|
1250
1344
|
const { hint: _persistedHint, ...rest } = row;
|
|
1251
1345
|
return { ...rest, label: built.label, ...(built.hint !== undefined ? { hint: built.hint } : {}) };
|
|
1252
1346
|
});
|
|
1253
1347
|
}
|
|
1348
|
+
/** Two word lists alike (both absent, or the same words in the same order). */
|
|
1349
|
+
function sameWords(a, b) {
|
|
1350
|
+
if (a === undefined || b === undefined)
|
|
1351
|
+
return a === b;
|
|
1352
|
+
return a.length === b.length && a.every((word, at) => word === b[at]);
|
|
1353
|
+
}
|
|
1254
1354
|
/**
|
|
1255
1355
|
* The rows an overlay persisted, with every Style row its sheet offers now
|
|
1256
1356
|
* that they lack appended in the builder's order: an overlay added before a
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** What the table says about one Style target: the words its line is titled by and one name per colour slot, each
|
|
2
|
+
* trimmed. A part the entry leaves out, or writes as no words, is absent (a colour list with one slot that has no
|
|
3
|
+
* words names none of its slots), and an output's or a heatmap's entry never carries a title. */
|
|
4
|
+
export interface WrunStyleNameWords {
|
|
5
|
+
label?: string;
|
|
6
|
+
colors?: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
/** The table's words for one Style target (`marks:<name>`, `text:<name>`, an output's name, `heatmap:<name>`), from
|
|
9
|
+
* the first entry that names it (a later one is never read); undefined when the sheet has no table or no entry
|
|
10
|
+
* names the target. An output's or a heatmap's entry gives no label, whatever it writes there. */
|
|
11
|
+
export declare function wrunStyleNameOf(sheet: {
|
|
12
|
+
style_names?: unknown;
|
|
13
|
+
} | null | undefined, target: string): WrunStyleNameWords | undefined;
|
|
14
|
+
/** One name per slot of a colour list of `count` colours: the target's names when the table names exactly that many,
|
|
15
|
+
* else undefined, so a swatch never takes another slot's name (a list naming fewer or more slots names none). */
|
|
16
|
+
export declare function wrunStyleSlotNames(names: WrunStyleNameWords | undefined, count: number): string[] | undefined;
|
|
17
|
+
/** A named target's title, the one order every surface titles it in: the table's label, else the target's own label
|
|
18
|
+
* (`ownLabel`: a batched section's or a heatmap's readout title, as its declaration carries it), else its name read as
|
|
19
|
+
* words (the legend's rule, wrunLegendName: `served_in_part` reads "Served in part"). A heatmap's entry gives no
|
|
20
|
+
* label, so a heatmap reads its own. */
|
|
21
|
+
export declare function wrunStyleTitle(sheet: {
|
|
22
|
+
style_names?: unknown;
|
|
23
|
+
} | null | undefined, target: string, name: string, ownLabel?: unknown): string;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { wrunLegendName } from '../chart/wrun-legend-name.util.js';
|
|
2
|
+
/** Each kind the table names: its Style target prefix, the visibility table's own (a renderer is `text:<name>`, an
|
|
3
|
+
* output its bare name), and whether its entry titles the line (`titles`: a batched section's and a renderer's; an
|
|
4
|
+
* output's and a heatmap's name colours only). A prefix the visibility table changes, a kind the table gains, or a
|
|
5
|
+
* kind's title rule the sheet type disagrees with, fails typecheck here. */
|
|
6
|
+
const STYLE_NAME_KINDS = Object.freeze({
|
|
7
|
+
marks: { prefix: 'marks', titles: true },
|
|
8
|
+
spans: { prefix: 'spans', titles: true },
|
|
9
|
+
rays: { prefix: 'rays', titles: true },
|
|
10
|
+
flags: { prefix: 'flags', titles: true },
|
|
11
|
+
renderer: { prefix: 'text', titles: true },
|
|
12
|
+
output: { prefix: '', titles: false },
|
|
13
|
+
heatmap: { prefix: 'heatmap', titles: false },
|
|
14
|
+
});
|
|
15
|
+
function isRecord(value) {
|
|
16
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
/** Plain words, trimmed; undefined for anything else (a number, an empty or blank string). */
|
|
19
|
+
function wordsOf(value) {
|
|
20
|
+
if (typeof value !== 'string')
|
|
21
|
+
return undefined;
|
|
22
|
+
const words = value.trim();
|
|
23
|
+
return words === '' ? undefined : words;
|
|
24
|
+
}
|
|
25
|
+
/** An entry's kind, when the table knows it. */
|
|
26
|
+
function kindOf(entry) {
|
|
27
|
+
const { kind } = entry;
|
|
28
|
+
return typeof kind === 'string' && Object.hasOwn(STYLE_NAME_KINDS, kind) ? kind : undefined;
|
|
29
|
+
}
|
|
30
|
+
/** An entry's Style target: undefined for a kind the table does not know, or an entry without a name. The name is
|
|
31
|
+
* the section's identity, compared as written (the visibility table's rule: a blank name is none). An output's
|
|
32
|
+
* target is its bare name, so an output entry whose name holds a colon names nothing: it would read as another
|
|
33
|
+
* kind's target (`marks:prints`), and no output target holds one. */
|
|
34
|
+
function targetOf(entry) {
|
|
35
|
+
if (!isRecord(entry))
|
|
36
|
+
return undefined;
|
|
37
|
+
const kind = kindOf(entry);
|
|
38
|
+
const { name } = entry;
|
|
39
|
+
if (kind === undefined || typeof name !== 'string' || name.trim() === '')
|
|
40
|
+
return undefined;
|
|
41
|
+
const { prefix } = STYLE_NAME_KINDS[kind];
|
|
42
|
+
if (prefix === '')
|
|
43
|
+
return name.includes(':') ? undefined : name;
|
|
44
|
+
return `${prefix}:${name}`;
|
|
45
|
+
}
|
|
46
|
+
/** The table's words for one Style target (`marks:<name>`, `text:<name>`, an output's name, `heatmap:<name>`), from
|
|
47
|
+
* the first entry that names it (a later one is never read); undefined when the sheet has no table or no entry
|
|
48
|
+
* names the target. An output's or a heatmap's entry gives no label, whatever it writes there. */
|
|
49
|
+
export function wrunStyleNameOf(sheet, target) {
|
|
50
|
+
const table = sheet?.style_names;
|
|
51
|
+
if (!Array.isArray(table))
|
|
52
|
+
return undefined;
|
|
53
|
+
const entry = table.find((candidate) => targetOf(candidate) === target);
|
|
54
|
+
if (!isRecord(entry))
|
|
55
|
+
return undefined;
|
|
56
|
+
const kind = kindOf(entry);
|
|
57
|
+
const label = kind !== undefined && STYLE_NAME_KINDS[kind].titles ? wordsOf(entry.label) : undefined;
|
|
58
|
+
const colors = Array.isArray(entry.colors) ? entry.colors.map(wordsOf) : [];
|
|
59
|
+
const named = colors.length > 0 && colors.every((name) => name !== undefined);
|
|
60
|
+
return { ...(label !== undefined ? { label } : {}), ...(named ? { colors: colors } : {}) };
|
|
61
|
+
}
|
|
62
|
+
/** One name per slot of a colour list of `count` colours: the target's names when the table names exactly that many,
|
|
63
|
+
* else undefined, so a swatch never takes another slot's name (a list naming fewer or more slots names none). */
|
|
64
|
+
export function wrunStyleSlotNames(names, count) {
|
|
65
|
+
return names?.colors !== undefined && names.colors.length === count ? [...names.colors] : undefined;
|
|
66
|
+
}
|
|
67
|
+
/** A named target's title, the one order every surface titles it in: the table's label, else the target's own label
|
|
68
|
+
* (`ownLabel`: a batched section's or a heatmap's readout title, as its declaration carries it), else its name read as
|
|
69
|
+
* words (the legend's rule, wrunLegendName: `served_in_part` reads "Served in part"). A heatmap's entry gives no
|
|
70
|
+
* label, so a heatmap reads its own. */
|
|
71
|
+
export function wrunStyleTitle(sheet, target, name, ownLabel) {
|
|
72
|
+
const named = wrunStyleNameOf(sheet, target)?.label;
|
|
73
|
+
return wrunLegendName(name, named ?? (typeof ownLabel === 'string' ? ownLabel : undefined));
|
|
74
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orangecharts/wrun-chart-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "The wrun chart-host layer shared by the kiyotaka web app and the mobile app: the wrun result reader and painter model, cut from the web app (its reference implementation).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@orangecharts/indicator-kit": "0.116.1",
|
|
32
|
-
"@orangecharts/orange-v2-pb-common": "12.
|
|
32
|
+
"@orangecharts/orange-v2-pb-common": "12.82.0",
|
|
33
33
|
"dayjs": "1.11.23",
|
|
34
34
|
"lodash-es": "4.18.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@orangecharts/indicator-kit": "0.116.1",
|
|
38
|
-
"@orangecharts/orange-v2-pb-common": "12.
|
|
38
|
+
"@orangecharts/orange-v2-pb-common": "12.82.0",
|
|
39
39
|
"@types/lodash-es": "4.17.12",
|
|
40
40
|
"dayjs": "1.11.23",
|
|
41
41
|
"lodash-es": "4.18.1",
|