@bicharts/chart-host 0.5.94 → 0.5.96
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.
|
@@ -474,6 +474,7 @@ var FLIP_MODE_DEFAULT = "both";
|
|
|
474
474
|
var APPROXIMATE_POSITIONS_DEFAULT = "mark";
|
|
475
475
|
var VALUE_AXIS_BASELINE_DEFAULT = "fit";
|
|
476
476
|
var SEASONAL_MARKERS_DEFAULT = "auto";
|
|
477
|
+
var MAX_MAP_POINTS_DEFAULT = 2e3;
|
|
477
478
|
|
|
478
479
|
// src/defaults.ts
|
|
479
480
|
var clamp = (n, lo, hi) => Math.max(lo, Math.min(hi, n));
|
|
@@ -498,7 +499,15 @@ function resolveOptions(p2) {
|
|
|
498
499
|
// tests/defaults.test.ts now compares the two lists, because four instances of one
|
|
499
500
|
// omission is a missing check, not four mistakes.
|
|
500
501
|
geoPointDest: p2.geoPointDest,
|
|
501
|
-
|
|
502
|
+
// NO LONGER A PASS-THROUGH. A host without a Max Map Points setting used to leave this
|
|
503
|
+
// undefined, and every map chart then fell back to whatever number its own code carried -
|
|
504
|
+
// 1000 in every archetype written so far - while the offer gate used the server's. One
|
|
505
|
+
// default here makes the chart and the gate agree in every host. A positive value from
|
|
506
|
+
// the host wins; absent, blank, zero or junk means the shared default.
|
|
507
|
+
maxMapPoints: (() => {
|
|
508
|
+
const n = numberOr(p2.maxMapPoints, 0);
|
|
509
|
+
return n > 0 ? Math.round(n) : MAX_MAP_POINTS_DEFAULT;
|
|
510
|
+
})(),
|
|
502
511
|
// FIFTH AND SIXTH OCCURRENCES, and the two that argue hardest for the guard test: both
|
|
503
512
|
// were passed by the visual AND read by the charts, and neither was ever declared here or
|
|
504
513
|
// in the contract - so the contract-vs-whitelist check could not see them either. What
|
|
@@ -3204,6 +3213,7 @@ export {
|
|
|
3204
3213
|
APPROXIMATE_POSITIONS_DEFAULT,
|
|
3205
3214
|
VALUE_AXIS_BASELINE_DEFAULT,
|
|
3206
3215
|
SEASONAL_MARKERS_DEFAULT,
|
|
3216
|
+
MAX_MAP_POINTS_DEFAULT,
|
|
3207
3217
|
resolveOptions,
|
|
3208
3218
|
geoAssetFor,
|
|
3209
3219
|
loadGeo,
|
package/dist/index.mjs
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
MARK_CLASS,
|
|
45
45
|
MARK_SELECTED_CLASS,
|
|
46
46
|
MAX_FRAME_GROW_FACTOR,
|
|
47
|
+
MAX_MAP_POINTS_DEFAULT,
|
|
47
48
|
MIN_CONTRAST,
|
|
48
49
|
MIN_HIT_BAND_PX,
|
|
49
50
|
MIN_RAMP_FILLS,
|
|
@@ -117,7 +118,7 @@ import {
|
|
|
117
118
|
toRGBA,
|
|
118
119
|
u,
|
|
119
120
|
unpinScrolledAxis
|
|
120
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-RM26QUBN.mjs";
|
|
121
122
|
import "./chunk-A2GMXZP7.mjs";
|
|
122
123
|
import "./chunk-GHODWOAL.mjs";
|
|
123
124
|
|
|
@@ -1941,9 +1942,16 @@ Mt.config = function(t2) {
|
|
|
1941
1942
|
|
|
1942
1943
|
// src/palette.ts
|
|
1943
1944
|
var MIN_DELTA_E = 10;
|
|
1944
|
-
|
|
1945
|
+
var LEGIBLE_LIGHTNESS = [15, 85];
|
|
1946
|
+
function pickDistinctColorFromSeed(seedHex, existing, minDistance = MIN_DELTA_E, options = {}) {
|
|
1945
1947
|
const existingCs = [...existing].map((c2) => Mt(c2));
|
|
1946
1948
|
const seed = Mt(seedHex);
|
|
1949
|
+
const band = options.lightnessBand === void 0 ? LEGIBLE_LIGHTNESS : options.lightnessBand;
|
|
1950
|
+
const legible = (c2) => {
|
|
1951
|
+
if (!band) return true;
|
|
1952
|
+
const l2 = c2.hsl()[2];
|
|
1953
|
+
return l2 > band[0] && l2 < band[1];
|
|
1954
|
+
};
|
|
1947
1955
|
const minDeltaE = (c2) => existingCs.length === 0 ? Number.POSITIVE_INFINITY : Math.min(...existingCs.map((c22) => c2.deltaE(c22, "CIE2000")));
|
|
1948
1956
|
if (minDeltaE(seed) >= minDistance) {
|
|
1949
1957
|
const hex = seed.hex();
|
|
@@ -1952,6 +1960,7 @@ function pickDistinctColorFromSeed(seedHex, existing, minDistance = MIN_DELTA_E)
|
|
|
1952
1960
|
let bestCandidate = seed;
|
|
1953
1961
|
let bestMinDist = minDeltaE(seed);
|
|
1954
1962
|
const tryVariant = (c2) => {
|
|
1963
|
+
if (!legible(c2)) return null;
|
|
1955
1964
|
const d2 = minDeltaE(c2);
|
|
1956
1965
|
if (d2 >= minDistance) {
|
|
1957
1966
|
const hex = c2.hex();
|
|
@@ -1977,10 +1986,10 @@ function pickDistinctColorFromSeed(seedHex, existing, minDistance = MIN_DELTA_E)
|
|
|
1977
1986
|
}
|
|
1978
1987
|
return { hex: seed.hex(), registerHex: bestCandidate.hex() };
|
|
1979
1988
|
}
|
|
1980
|
-
function buildPaletteFromSeed(seedHex, count, minDistance = MIN_DELTA_E) {
|
|
1981
|
-
return buildPalette(() => seedHex, count, minDistance);
|
|
1989
|
+
function buildPaletteFromSeed(seedHex, count, minDistance = MIN_DELTA_E, options = {}) {
|
|
1990
|
+
return buildPalette(() => seedHex, count, minDistance, options);
|
|
1982
1991
|
}
|
|
1983
|
-
function buildPalette(seedFor, count, minDistance = MIN_DELTA_E) {
|
|
1992
|
+
function buildPalette(seedFor, count, minDistance = MIN_DELTA_E, options = {}) {
|
|
1984
1993
|
const out = [];
|
|
1985
1994
|
if (!(count > 0)) return out;
|
|
1986
1995
|
const issued = /* @__PURE__ */ new Set();
|
|
@@ -1999,7 +2008,7 @@ function buildPalette(seedFor, count, minDistance = MIN_DELTA_E) {
|
|
|
1999
2008
|
if (!seedHex) seedHex = lastSeed;
|
|
2000
2009
|
if (!seedHex) break;
|
|
2001
2010
|
lastSeed = seedHex;
|
|
2002
|
-
const { hex, registerHex } = pickDistinctColorFromSeed(seedHex, issued, minDistance);
|
|
2011
|
+
const { hex, registerHex } = pickDistinctColorFromSeed(seedHex, issued, minDistance, options);
|
|
2003
2012
|
let chosen = hex;
|
|
2004
2013
|
let register = registerHex;
|
|
2005
2014
|
if (distance(chosen) < minDistance) {
|
|
@@ -2120,11 +2129,13 @@ export {
|
|
|
2120
2129
|
LABEL_CONTRAST_CAP,
|
|
2121
2130
|
LABEL_CONTRAST_DONE_ATTR,
|
|
2122
2131
|
LEGEND_MARK_CLASS,
|
|
2132
|
+
LEGIBLE_LIGHTNESS,
|
|
2123
2133
|
LIFT_SELECTED_CLASS,
|
|
2124
2134
|
LIGHT_TEXT,
|
|
2125
2135
|
MARK_CLASS,
|
|
2126
2136
|
MARK_SELECTED_CLASS,
|
|
2127
2137
|
MAX_FRAME_GROW_FACTOR,
|
|
2138
|
+
MAX_MAP_POINTS_DEFAULT,
|
|
2128
2139
|
MIN_CONTRAST,
|
|
2129
2140
|
MIN_DELTA_E,
|
|
2130
2141
|
MIN_HIT_BAND_PX,
|
package/dist/react.mjs
CHANGED
package/dist/types/contract.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export type ValueAxisBaseline = "zero" | "fit" | "auto";
|
|
|
71
71
|
export declare const VALUE_AXIS_BASELINE_DEFAULT: ValueAxisBaseline;
|
|
72
72
|
export type SeasonalMarkers = "auto" | "always" | "never";
|
|
73
73
|
export declare const SEASONAL_MARKERS_DEFAULT: SeasonalMarkers;
|
|
74
|
+
export declare const MAX_MAP_POINTS_DEFAULT = 2000;
|
|
74
75
|
export type ColorScaleScope = "" | "frame" | "self";
|
|
75
76
|
export interface RenderOptions {
|
|
76
77
|
width: number;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { HOST_CONTRACT_VERSION, GEO_POINT_PRECISIONS, MARK_CLASS, LEGEND_MARK_CLASS, AXIS_FILTER_CLASS, ROW_IDX_ATTR, LIFT_SELECTED_CLASS, XFILTER_REFRESH_EVENT, CONTAINER_SLOT_ANIM_STOP, CONTAINER_SLOT_XF_CLEAR, CONTAINER_SLOT_INITIAL_XF_MARK, CONTAINER_SLOT_UI_STATE, HOST_CONTAINER_CLASS, SELECTION_ACTIVE_CLASS, MARK_SELECTED_CLASS, ACTIVE_TICK_CLASS, DIM_OPACITY_VAR, DIM_OPACITY_DEFAULT, chartOwnsTimeline, periodTickSuppressesFeedback, ANIM_PLAY_SPEED_DEFAULT, ANIM_PLAY_SPEED_MIN, ANIM_PLAY_SPEED_MAX, ANIM_LOOP_DELAY_DEFAULT, ANIM_LOOP_DELAY_MIN, ANIM_MAX_IDEAL_FRAMES_DEFAULT, ANIM_MAX_IDEAL_FRAMES_MIN, ANIM_MAX_IDEAL_FRAMES_MAX, COLOR_SCALE_SELF_CLAMP_PCT_DEFAULT, COLOR_SCALE_SELF_CLAMP_PCT_MIN, COLOR_SCALE_SELF_CLAMP_PCT_MAX, FLIP_MODE_DEFAULT, APPROXIMATE_POSITIONS_DEFAULT, VALUE_AXIS_BASELINE_DEFAULT, SEASONAL_MARKERS_DEFAULT, type GeoPointPrecision, type GeoMapKind, type TimelineStyle, type FlipMode, type ApproximatePositions, type ValueAxisBaseline, type SeasonalMarkers, type ColorScaleScope, type RenderOptions, type ViewStateProvider, } from "./contract";
|
|
1
|
+
export { HOST_CONTRACT_VERSION, GEO_POINT_PRECISIONS, MARK_CLASS, LEGEND_MARK_CLASS, AXIS_FILTER_CLASS, ROW_IDX_ATTR, LIFT_SELECTED_CLASS, XFILTER_REFRESH_EVENT, CONTAINER_SLOT_ANIM_STOP, CONTAINER_SLOT_XF_CLEAR, CONTAINER_SLOT_INITIAL_XF_MARK, CONTAINER_SLOT_UI_STATE, HOST_CONTAINER_CLASS, SELECTION_ACTIVE_CLASS, MARK_SELECTED_CLASS, ACTIVE_TICK_CLASS, DIM_OPACITY_VAR, DIM_OPACITY_DEFAULT, chartOwnsTimeline, periodTickSuppressesFeedback, ANIM_PLAY_SPEED_DEFAULT, ANIM_PLAY_SPEED_MIN, ANIM_PLAY_SPEED_MAX, ANIM_LOOP_DELAY_DEFAULT, ANIM_LOOP_DELAY_MIN, ANIM_MAX_IDEAL_FRAMES_DEFAULT, ANIM_MAX_IDEAL_FRAMES_MIN, ANIM_MAX_IDEAL_FRAMES_MAX, COLOR_SCALE_SELF_CLAMP_PCT_DEFAULT, COLOR_SCALE_SELF_CLAMP_PCT_MIN, COLOR_SCALE_SELF_CLAMP_PCT_MAX, FLIP_MODE_DEFAULT, APPROXIMATE_POSITIONS_DEFAULT, VALUE_AXIS_BASELINE_DEFAULT, SEASONAL_MARKERS_DEFAULT, MAX_MAP_POINTS_DEFAULT, type GeoPointPrecision, type GeoMapKind, type TimelineStyle, type FlipMode, type ApproximatePositions, type ValueAxisBaseline, type SeasonalMarkers, type ColorScaleScope, type RenderOptions, type ViewStateProvider, } from "./contract";
|
|
2
2
|
export { resolveOptions, type ResolveOptionsInput } from "./defaults";
|
|
3
3
|
export { loadGeo, geoFromCache, registerGeo, registerGeoAsset, geoAssetFor, clearGeoCache, type GeoAssetName, } from "./geoLazy";
|
|
4
4
|
/** REPLACE the bundled city gazetteer with another packed table. Rarely needed — see the
|
|
@@ -27,5 +27,5 @@ export { SCROLL_SLACK_PX, MAX_FRAME_GROW_FACTOR, PHANTOM_FRACTION, FIT_CONTENT_S
|
|
|
27
27
|
export { fitRenderedChart, fitReadingFor, measureContainerBoxes, svgInkReach, ctmScaleOf, type FitReading, type InkReach, type FitRenderedChartOptions, type FitRenderedChartResult, } from "./fitDom";
|
|
28
28
|
export { AXIS_PIN_MIN_LABELS, AXIS_PIN_BAND_PAD_PX, AXIS_PIN_MAX_BAND_FRACTION, AXIS_PIN_TRACK_REACH_PX, isHorizontalLabelRow, labelBand, planAxisPin, axisPinPlacement, type LabelRowBox, type AxisBand, type AxisPinCandidate, type AxisPinPlan, type AxisPinEdge, } from "./fit";
|
|
29
29
|
export { pinScrolledAxis, unpinScrolledAxis, type AxisPinReport } from "./fitDom";
|
|
30
|
-
export { MIN_DELTA_E, pickDistinctColorFromSeed, buildPalette, buildPaletteFromSeed, orderMostDistinct, type PaletteResult, type SeedForSlot, } from "./palette";
|
|
30
|
+
export { MIN_DELTA_E, pickDistinctColorFromSeed, buildPalette, buildPaletteFromSeed, orderMostDistinct, LEGIBLE_LIGHTNESS, type PaletteResult, type SeedForSlot, type PaletteOptions, } from "./palette";
|
|
31
31
|
export { deltaEHex } from "./deltaE";
|
package/dist/types/palette.d.ts
CHANGED
|
@@ -4,6 +4,30 @@
|
|
|
4
4
|
* swatches; JND (just-noticeable-difference) at this scale is ≈5.
|
|
5
5
|
*/
|
|
6
6
|
export declare const MIN_DELTA_E = 10;
|
|
7
|
+
/**
|
|
8
|
+
* THE LIGHTNESS A COLOUR THE WALK INVENTS MUST FALL INSIDE (HSL lightness, 0-100, exclusive).
|
|
9
|
+
*
|
|
10
|
+
* The walk's lightness step moves the seed up to 45 points, so from a light seed it could land on
|
|
11
|
+
* a near-white - and a categorical mark that is near-white on a white page, or near-black on a dark
|
|
12
|
+
* one, is not a colour a reader can find. Measured before this band existed: a green seed's
|
|
13
|
+
* twenty-slot palette put `#ebf4e5` (lightness 93) in slot 7, and a pool of Office theme colours led
|
|
14
|
+
* by a red put `#d5e5f4` (90) in slot 17.
|
|
15
|
+
*
|
|
16
|
+
* INVENTED COLOURS ONLY. A seed the host supplied comes back as supplied, however light or dark -
|
|
17
|
+
* that is a report author's decision - and the spare-colour sweep keeps its own, narrower band.
|
|
18
|
+
*/
|
|
19
|
+
export declare const LEGIBLE_LIGHTNESS: readonly [number, number];
|
|
20
|
+
export interface PaletteOptions {
|
|
21
|
+
/**
|
|
22
|
+
* The lightness band invented colours must sit in. Defaults to `LEGIBLE_LIGHTNESS`.
|
|
23
|
+
*
|
|
24
|
+
* `null` walks as the package did before the band existed, colour for colour. It exists for a
|
|
25
|
+
* host that STORED palettes the older walk produced and has to recognise one again by
|
|
26
|
+
* re-deriving it: change the walk under such a host and every stored palette silently stops
|
|
27
|
+
* matching. Nothing should draw with it.
|
|
28
|
+
*/
|
|
29
|
+
lightnessBand?: readonly [number, number] | null;
|
|
30
|
+
}
|
|
7
31
|
/**
|
|
8
32
|
* Pick a hex color for a palette slot.
|
|
9
33
|
*
|
|
@@ -30,7 +54,7 @@ export interface PaletteResult {
|
|
|
30
54
|
/** Hex color to register in the palette-issued set (may differ from `hex` on the give-up fallback). */
|
|
31
55
|
readonly registerHex: string;
|
|
32
56
|
}
|
|
33
|
-
export declare function pickDistinctColorFromSeed(seedHex: string, existing: ReadonlySet<string>, minDistance?: number): PaletteResult;
|
|
57
|
+
export declare function pickDistinctColorFromSeed(seedHex: string, existing: ReadonlySet<string>, minDistance?: number, options?: PaletteOptions): PaletteResult;
|
|
34
58
|
/**
|
|
35
59
|
* A whole categorical palette from ONE seed colour.
|
|
36
60
|
*
|
|
@@ -49,7 +73,7 @@ export declare function pickDistinctColorFromSeed(seedHex: string, existing: Rea
|
|
|
49
73
|
* Deterministic: same seed and count in, same array out, which is what lets a host PERSIST the
|
|
50
74
|
* result and re-derive it later without the colours shifting under a saved chart.
|
|
51
75
|
*/
|
|
52
|
-
export declare function buildPaletteFromSeed(seedHex: string, count: number, minDistance?: number): string[];
|
|
76
|
+
export declare function buildPaletteFromSeed(seedHex: string, count: number, minDistance?: number, options?: PaletteOptions): string[];
|
|
53
77
|
/**
|
|
54
78
|
* WHERE EACH SLOT'S BASE COLOUR COMES FROM. Called with the slot index, 0-based.
|
|
55
79
|
*
|
|
@@ -75,7 +99,7 @@ export type SeedForSlot = (slot: number) => string | null | undefined;
|
|
|
75
99
|
* A host with no such API - an Excel workbook offers exactly one resolvable accent - passes a
|
|
76
100
|
* constant provider and the walk does the spreading. That is a fallback, not the design.
|
|
77
101
|
*/
|
|
78
|
-
export declare function buildPalette(seedFor: SeedForSlot, count: number, minDistance?: number): string[];
|
|
102
|
+
export declare function buildPalette(seedFor: SeedForSlot, count: number, minDistance?: number, options?: PaletteOptions): string[];
|
|
79
103
|
/**
|
|
80
104
|
* A POOL OF ACCEPTABLE COLOURS, ORDERED SO THE MOST DISTINCT COME FIRST.
|
|
81
105
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/chart-host",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.96",
|
|
4
4
|
"description": "Run a BIC-generated D3 chart in any web host: compiles the generated render() function, applies the shared option defaults, resolves mark clicks (through tooltip overlays), owns the selection affordance, and translates row indices between cross-filtered charts. The same contract the BIC Power BI visual implements, minus Power BI. React bindings at @bicharts/chart-host/react.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|