@bicharts/chart-host 0.5.72 → 0.5.74
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/{chunk-QCB6PBO5.mjs → chunk-E6P2ZMGC.mjs} +482 -182
- package/dist/index.mjs +54 -8
- package/dist/react.mjs +1 -1
- package/dist/types/host.d.ts +20 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/labelContrast.d.ts +56 -0
- package/dist/types/labelContrastDom.d.ts +33 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ANIM_PLAY_SPEED_MIN,
|
|
12
12
|
APPROXIMATE_POSITIONS_DEFAULT,
|
|
13
13
|
AXIS_FILTER_CLASS,
|
|
14
|
-
|
|
14
|
+
BACKING_MAJORITY,
|
|
15
15
|
COLOR_SCALE_SELF_CLAMP_PCT_DEFAULT,
|
|
16
16
|
COLOR_SCALE_SELF_CLAMP_PCT_MAX,
|
|
17
17
|
COLOR_SCALE_SELF_CLAMP_PCT_MIN,
|
|
@@ -19,65 +19,88 @@ import {
|
|
|
19
19
|
CONTAINER_SLOT_INITIAL_XF_MARK,
|
|
20
20
|
CONTAINER_SLOT_UI_STATE,
|
|
21
21
|
CONTAINER_SLOT_XF_CLEAR,
|
|
22
|
+
DARK_TEXT,
|
|
22
23
|
DIM_OPACITY_DEFAULT,
|
|
23
24
|
DIM_OPACITY_VAR,
|
|
24
25
|
FIT_CONTENT_SELECTOR,
|
|
25
26
|
FLIP_MODE_DEFAULT,
|
|
26
27
|
GEO_POINT_PRECISIONS,
|
|
28
|
+
GLYPH_SAMPLE_N,
|
|
27
29
|
HOST_CONTAINER_CLASS,
|
|
28
30
|
HOST_CONTRACT_VERSION,
|
|
29
31
|
L3,
|
|
32
|
+
LABEL_CONTRAST_CAP,
|
|
33
|
+
LABEL_CONTRAST_DONE_ATTR,
|
|
30
34
|
LEGEND_MARK_CLASS,
|
|
31
35
|
LIFT_SELECTED_CLASS,
|
|
36
|
+
LIGHT_TEXT,
|
|
32
37
|
MARK_CLASS,
|
|
33
38
|
MARK_SELECTED_CLASS,
|
|
34
39
|
MAX_FRAME_GROW_FACTOR,
|
|
40
|
+
MIN_CONTRAST,
|
|
35
41
|
MIN_HIT_BAND_PX,
|
|
42
|
+
PAGE_MATCH_TOLERANCE,
|
|
36
43
|
PHANTOM_FRACTION,
|
|
44
|
+
PILL_MIN_ALPHA,
|
|
45
|
+
PILL_MIN_COVERAGE,
|
|
46
|
+
PILL_OPAQUE_ALPHA,
|
|
37
47
|
ROW_IDX_ATTR,
|
|
48
|
+
Rt,
|
|
38
49
|
SCROLL_SLACK_PX,
|
|
39
50
|
SEASONAL_MARKERS_DEFAULT,
|
|
40
51
|
SELECTION_ACTIVE_CLASS,
|
|
52
|
+
Se,
|
|
41
53
|
Tt,
|
|
42
54
|
VALUE_AXIS_BASELINE_DEFAULT,
|
|
55
|
+
WHITE_TEXT_BG_LUM,
|
|
43
56
|
XFILTER_REFRESH_EVENT,
|
|
57
|
+
applyLabelContrast,
|
|
58
|
+
backingHoldsGlyph,
|
|
44
59
|
blankRenderFlag,
|
|
45
60
|
buildRenderPayload,
|
|
61
|
+
cellSuppressesNormalize,
|
|
46
62
|
censusHitBands,
|
|
47
63
|
censusMarks,
|
|
48
64
|
chartOwnsTimeline,
|
|
49
65
|
clearGeoCache,
|
|
50
66
|
compileRenderFn,
|
|
67
|
+
compositeOver,
|
|
51
68
|
contentExtentOf,
|
|
69
|
+
contrastRatio,
|
|
52
70
|
createChartHost,
|
|
53
71
|
createMarkResolver,
|
|
54
72
|
ctmScaleOf,
|
|
73
|
+
decideLabelColor,
|
|
55
74
|
ensureCrossfilterHitTargets,
|
|
56
75
|
explainRenderFailure,
|
|
57
76
|
fitReadingFor,
|
|
58
77
|
fitRenderedChart,
|
|
59
78
|
geoAssetFor,
|
|
60
79
|
geoFromCache,
|
|
61
|
-
|
|
80
|
+
glyphSampleGrid,
|
|
62
81
|
hitBandFlag,
|
|
63
82
|
isBlankRender,
|
|
64
83
|
isPhantomBox,
|
|
84
|
+
isPillBackdropAlpha,
|
|
65
85
|
loadGeo,
|
|
66
86
|
measureContainerBoxes,
|
|
67
87
|
needsScroll,
|
|
68
88
|
noopViewStateProvider,
|
|
69
89
|
periodTickSuppressesFeedback,
|
|
90
|
+
pillBacksGlyph,
|
|
70
91
|
planFrameGrow,
|
|
71
92
|
registerGeo,
|
|
72
93
|
registerGeoAsset,
|
|
94
|
+
relativeLuminance,
|
|
73
95
|
requiredD3Plugins,
|
|
74
96
|
resolveOptions,
|
|
75
97
|
scrollFitFor,
|
|
76
98
|
sessionViewStateProvider,
|
|
77
99
|
stripEsmExports,
|
|
78
100
|
svgInkReach,
|
|
101
|
+
toRGBA,
|
|
79
102
|
ye
|
|
80
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-E6P2ZMGC.mjs";
|
|
81
104
|
import "./chunk-A2GMXZP7.mjs";
|
|
82
105
|
import "./chunk-GHODWOAL.mjs";
|
|
83
106
|
|
|
@@ -823,15 +846,15 @@ function isRealColumn(col) {
|
|
|
823
846
|
return !!col && !isSynthetic(col.name);
|
|
824
847
|
}
|
|
825
848
|
function isSuppressed(col) {
|
|
826
|
-
return
|
|
849
|
+
return Tt(col).suppressed;
|
|
827
850
|
}
|
|
828
851
|
function resolveAgg(col, requested, auto) {
|
|
829
852
|
const fallback = () => {
|
|
830
|
-
const d =
|
|
853
|
+
const d = ye(col);
|
|
831
854
|
return d === "first" ? "count" : d;
|
|
832
855
|
};
|
|
833
856
|
if (auto) return fallback();
|
|
834
|
-
return
|
|
857
|
+
return Rt(col).indexOf(requested) >= 0 ? requested : fallback();
|
|
835
858
|
}
|
|
836
859
|
function toNumber(v) {
|
|
837
860
|
if (v == null || v === "") return null;
|
|
@@ -935,7 +958,7 @@ function computeSelectionCard(payload, selectedRowIdxs, opts = {}) {
|
|
|
935
958
|
}
|
|
936
959
|
const value = reduce(selVals, colAgg, selRaw);
|
|
937
960
|
let sharePct = null;
|
|
938
|
-
if (
|
|
961
|
+
if (Se(col, colAgg) && value != null) {
|
|
939
962
|
const allVals = [];
|
|
940
963
|
const allRaw = [];
|
|
941
964
|
for (let r = 0; r < rows.length; r++) {
|
|
@@ -1010,6 +1033,7 @@ export {
|
|
|
1010
1033
|
ANIM_PLAY_SPEED_MIN,
|
|
1011
1034
|
APPROXIMATE_POSITIONS_DEFAULT,
|
|
1012
1035
|
AXIS_FILTER_CLASS,
|
|
1036
|
+
BACKING_MAJORITY,
|
|
1013
1037
|
CHOOSER_MIN_HEIGHT_PX,
|
|
1014
1038
|
CHOOSER_MIN_WIDTH_PX,
|
|
1015
1039
|
COLOR_SCALE_SELF_CLAMP_PCT_DEFAULT,
|
|
@@ -1019,6 +1043,7 @@ export {
|
|
|
1019
1043
|
CONTAINER_SLOT_INITIAL_XF_MARK,
|
|
1020
1044
|
CONTAINER_SLOT_UI_STATE,
|
|
1021
1045
|
CONTAINER_SLOT_XF_CLEAR,
|
|
1046
|
+
DARK_TEXT,
|
|
1022
1047
|
DIM_OPACITY_DEFAULT,
|
|
1023
1048
|
DIM_OPACITY_VAR,
|
|
1024
1049
|
FILTER_MIN_HEIGHT_PX,
|
|
@@ -1028,30 +1053,43 @@ export {
|
|
|
1028
1053
|
FIT_CONTENT_SELECTOR,
|
|
1029
1054
|
FLIP_MODE_DEFAULT,
|
|
1030
1055
|
GEO_POINT_PRECISIONS,
|
|
1056
|
+
GLYPH_SAMPLE_N,
|
|
1031
1057
|
HOST_CONTAINER_CLASS,
|
|
1032
1058
|
HOST_CONTRACT_VERSION,
|
|
1033
1059
|
INLINE_FILTER_MIN_ROWS,
|
|
1060
|
+
LABEL_CONTRAST_CAP,
|
|
1061
|
+
LABEL_CONTRAST_DONE_ATTR,
|
|
1034
1062
|
LEGEND_MARK_CLASS,
|
|
1035
1063
|
LIFT_SELECTED_CLASS,
|
|
1064
|
+
LIGHT_TEXT,
|
|
1036
1065
|
MARK_CLASS,
|
|
1037
1066
|
MARK_SELECTED_CLASS,
|
|
1038
1067
|
MAX_FRAME_GROW_FACTOR,
|
|
1068
|
+
MIN_CONTRAST,
|
|
1039
1069
|
MIN_HIT_BAND_PX,
|
|
1070
|
+
PAGE_MATCH_TOLERANCE,
|
|
1040
1071
|
PHANTOM_FRACTION,
|
|
1072
|
+
PILL_MIN_ALPHA,
|
|
1073
|
+
PILL_MIN_COVERAGE,
|
|
1074
|
+
PILL_OPAQUE_ALPHA,
|
|
1041
1075
|
ROW_IDX_ATTR,
|
|
1042
1076
|
SCROLL_SLACK_PX,
|
|
1043
1077
|
SEASONAL_MARKERS_DEFAULT,
|
|
1044
1078
|
SELECTION_ACTIVE_CLASS,
|
|
1045
1079
|
VALUE_AXIS_BASELINE_DEFAULT,
|
|
1080
|
+
WHITE_TEXT_BG_LUM,
|
|
1046
1081
|
XFILTER_REFRESH_EVENT,
|
|
1047
1082
|
actionFor,
|
|
1083
|
+
applyLabelContrast,
|
|
1048
1084
|
askApplyImprovements,
|
|
1085
|
+
backingHoldsGlyph,
|
|
1049
1086
|
bareBase64,
|
|
1050
1087
|
blankRenderFlag,
|
|
1051
1088
|
buildRenderPayload,
|
|
1052
1089
|
buildReviewWire,
|
|
1053
1090
|
canConfirmLaunch,
|
|
1054
1091
|
captureSvgSnapshot,
|
|
1092
|
+
cellSuppressesNormalize,
|
|
1055
1093
|
censusHitBands,
|
|
1056
1094
|
censusMarks,
|
|
1057
1095
|
chartOwnsTimeline,
|
|
@@ -1059,13 +1097,16 @@ export {
|
|
|
1059
1097
|
clearGeoCache,
|
|
1060
1098
|
compileRenderFn,
|
|
1061
1099
|
compileTrivialSource,
|
|
1100
|
+
compositeOver,
|
|
1062
1101
|
computeQualifyFilterView,
|
|
1063
1102
|
computeSelectionCard,
|
|
1064
1103
|
confirmLaunch,
|
|
1065
1104
|
contentExtentOf,
|
|
1105
|
+
contrastRatio,
|
|
1066
1106
|
createChartHost,
|
|
1067
1107
|
createMarkResolver,
|
|
1068
1108
|
ctmScaleOf,
|
|
1109
|
+
decideLabelColor,
|
|
1069
1110
|
ensureCrossfilterHitTargets,
|
|
1070
1111
|
explainRenderFailure,
|
|
1071
1112
|
filterFitsChooser,
|
|
@@ -1074,11 +1115,13 @@ export {
|
|
|
1074
1115
|
fitRenderedChart,
|
|
1075
1116
|
geoAssetFor,
|
|
1076
1117
|
geoFromCache,
|
|
1118
|
+
glyphSampleGrid,
|
|
1077
1119
|
hasRefusalsToShow,
|
|
1078
1120
|
hitBandFlag,
|
|
1079
1121
|
inlineFilterGate,
|
|
1080
1122
|
isBlankRender,
|
|
1081
1123
|
isPhantomBox,
|
|
1124
|
+
isPillBackdropAlpha,
|
|
1082
1125
|
launchFavorStyle,
|
|
1083
1126
|
launchGenerates,
|
|
1084
1127
|
listNeedsFilter,
|
|
@@ -1092,6 +1135,7 @@ export {
|
|
|
1092
1135
|
normalizeFilterTerm,
|
|
1093
1136
|
orderRefusalsForDisplay,
|
|
1094
1137
|
periodTickSuppressesFeedback,
|
|
1138
|
+
pillBacksGlyph,
|
|
1095
1139
|
planFrameGrow,
|
|
1096
1140
|
planTrivialChart,
|
|
1097
1141
|
qualifyAuto,
|
|
@@ -1109,6 +1153,7 @@ export {
|
|
|
1109
1153
|
registerCityTable,
|
|
1110
1154
|
registerGeo,
|
|
1111
1155
|
registerGeoAsset,
|
|
1156
|
+
relativeLuminance,
|
|
1112
1157
|
requiredD3Plugins,
|
|
1113
1158
|
resolveOptions,
|
|
1114
1159
|
scrollFitFor,
|
|
@@ -1119,5 +1164,6 @@ export {
|
|
|
1119
1164
|
stripEsmExports,
|
|
1120
1165
|
svgInkReach,
|
|
1121
1166
|
svgNaturalSize,
|
|
1122
|
-
svgToDataUrl
|
|
1167
|
+
svgToDataUrl,
|
|
1168
|
+
toRGBA
|
|
1123
1169
|
};
|
package/dist/react.mjs
CHANGED
package/dist/types/host.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type ResolveOptionsInput } from "./defaults";
|
|
|
3
3
|
import { type MarkCensus } from "./blankRender";
|
|
4
4
|
import { type HitBandCensus } from "./hitBands";
|
|
5
5
|
import { type FitRenderedChartOptions, type FitRenderedChartResult } from "./fitDom";
|
|
6
|
+
import { type LabelContrastOptions, type LabelContrastReport } from "./labelContrastDom";
|
|
6
7
|
export type RenderFn = (container: HTMLElement, data: any, options: RenderOptions) => void;
|
|
7
8
|
/**
|
|
8
9
|
* THE SESSION PROVIDER — what every host got hard-coded before contract 1.6.0, now named.
|
|
@@ -115,6 +116,25 @@ export interface ChartHostConfig {
|
|
|
115
116
|
fit?: boolean | FitRenderedChartOptions;
|
|
116
117
|
/** The fit result after each render - what was grown, and how the chart measured. */
|
|
117
118
|
onFit?: (result: FitRenderedChartResult) => void;
|
|
119
|
+
/**
|
|
120
|
+
* CAN THE LABELS ON THE MARKS BE READ? Runs after every render, BEFORE the hit-target heal
|
|
121
|
+
* (which injects transparent rects this pass must not mistake for backdrops).
|
|
122
|
+
*
|
|
123
|
+
* Generated code picks an in-mark label's colour from the mark's NOMINAL hue; the mark's
|
|
124
|
+
* ACTUAL rendered fill - a 0.18-opacity band over white, a translucent pill over a tile, an
|
|
125
|
+
* arc whose hole is canvas - is something else, and only a post-render read of the real DOM
|
|
126
|
+
* knows it. This resolves which shapes really back each label (geometry, not bounding
|
|
127
|
+
* boxes), composites the real stack over the page, and recolours to black or white only
|
|
128
|
+
* where the label would otherwise be unreadable or a tile's labels would read as mixed.
|
|
129
|
+
*
|
|
130
|
+
* DEFAULT ON, because the alternative is text nobody can read, and the pass only ever sets a
|
|
131
|
+
* text's fill. Pass `false` for a host that owns its own label colours, or an options object
|
|
132
|
+
* to name the page background it composites onto (`pageBg`) - a themed or high-contrast
|
|
133
|
+
* canvas is not white, and every readability answer is measured against it.
|
|
134
|
+
*/
|
|
135
|
+
labelContrast?: boolean | LabelContrastOptions;
|
|
136
|
+
/** What the label-contrast pass did after each render - counts, so a host can log them. */
|
|
137
|
+
onLabelContrast?: (report: LabelContrastReport) => void;
|
|
118
138
|
}
|
|
119
139
|
export interface ChartHost {
|
|
120
140
|
render(): void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { qualifyPick, qualifyAuto, qualifyCancel, launchGenerates, launchFavorSt
|
|
|
16
16
|
export { normalizeFilterTerm, filterQualifyRows, readQualifyChartRow, readQualifyRefusalRow, filterFitsChooser, listNeedsFilter, qualifyFilterGate, inlineFilterGate, FILTER_MIN_TERM_CHARS, FILTER_ROW_PX, FILTER_MIN_WIDTH_PX, FILTER_MIN_HEIGHT_PX, INLINE_FILTER_MIN_ROWS, computeQualifyFilterView, qualifyFilterCountText, type QualifyFilterTier, type QualifyFilterResult, type QualifyFilterRead, type QualifyFilterGateReason, type QualifyFilterGateInput, type QualifyFilterRow, type QualifyFilterGroup, type QualifyFilterView, type QualifyFilterNoteKind, } from "./qualifyFilter";
|
|
17
17
|
export { computeSelectionCard, normaliseAggregation, type SelectionCardModel, type SelectionCardLine, type SelectionCardOptions, } from "./selectionCard";
|
|
18
18
|
export { ensureCrossfilterHitTargets, type HitTargetReport } from "./hitTargets";
|
|
19
|
+
export { applyLabelContrast, LABEL_CONTRAST_DONE_ATTR, LABEL_CONTRAST_CAP, type LabelContrastOptions, type LabelContrastReport, } from "./labelContrastDom";
|
|
20
|
+
export { decideLabelColor, toRGBA, compositeOver, relativeLuminance, contrastRatio, isPillBackdropAlpha, pillBacksGlyph, backingHoldsGlyph, cellSuppressesNormalize, glyphSampleGrid, DARK_TEXT, LIGHT_TEXT, MIN_CONTRAST, WHITE_TEXT_BG_LUM, PILL_MIN_ALPHA, PILL_OPAQUE_ALPHA, PILL_MIN_COVERAGE, PAGE_MATCH_TOLERANCE, BACKING_MAJORITY, GLYPH_SAMPLE_N, type LabelDecision, } from "./labelContrast";
|
|
19
21
|
export { censusMarks, isBlankRender, blankRenderFlag, type MarkCensus, type BlankVerdictInput } from "./blankRender";
|
|
20
22
|
export { censusHitBands, hitBandFlag, MIN_HIT_BAND_PX, type HitBandCensus } from "./hitBands";
|
|
21
23
|
export { SCROLL_SLACK_PX, MAX_FRAME_GROW_FACTOR, PHANTOM_FRACTION, FIT_CONTENT_SELECTOR, needsScroll, contentExtentOf, scrollFitFor, planFrameGrow, isPhantomBox, type MeasuredBox, type ContentExtent, type ScrollFit, type FrameGrowPlan, } from "./fit";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare const DARK_TEXT = "#111111";
|
|
2
|
+
export declare const LIGHT_TEXT = "#ffffff";
|
|
3
|
+
export declare const MIN_CONTRAST = 3;
|
|
4
|
+
export declare const WHITE_TEXT_BG_LUM = 0.5;
|
|
5
|
+
export declare const PILL_MIN_ALPHA = 0.05;
|
|
6
|
+
export declare const PILL_OPAQUE_ALPHA = 0.85;
|
|
7
|
+
export declare const PAGE_MATCH_TOLERANCE = 2;
|
|
8
|
+
/** True when a shape's effective alpha lets it act as a label backdrop rather than the cell. */
|
|
9
|
+
export declare function isPillBackdropAlpha(a: number): boolean;
|
|
10
|
+
export declare const PILL_MIN_COVERAGE = 0.6;
|
|
11
|
+
/** True when a candidate backdrop covers enough of the glyph box to be the thing behind it. */
|
|
12
|
+
export declare function pillBacksGlyph(overlapArea: number, glyphArea: number): boolean;
|
|
13
|
+
export declare const BACKING_MAJORITY = 0.5;
|
|
14
|
+
/** True when the painted marks under a glyph hold enough of it to count as its background. */
|
|
15
|
+
export declare function backingHoldsGlyph(backedArea: number, glyphArea: number): boolean;
|
|
16
|
+
export declare function cellSuppressesNormalize(cellClass: string | null | undefined): boolean;
|
|
17
|
+
type RGB = [number, number, number];
|
|
18
|
+
type RGBA = [number, number, number, number];
|
|
19
|
+
/** Parse a colour string to RGBA, covering hex, rgb()/rgba() and a few keywords. */
|
|
20
|
+
export declare function toRGBA(c: string | null | undefined): RGBA | null;
|
|
21
|
+
/** Alpha-composite a foreground RGBA over an opaque RGB background. */
|
|
22
|
+
export declare function compositeOver(fg: RGBA, bg: RGB): RGB;
|
|
23
|
+
/** WCAG relative luminance of an opaque sRGB colour (0..1). */
|
|
24
|
+
export declare function relativeLuminance(rgb: RGB): number;
|
|
25
|
+
/** WCAG contrast ratio (1..21) between two luminances. */
|
|
26
|
+
export declare function contrastRatio(l1: number, l2: number): number;
|
|
27
|
+
export interface LabelDecision {
|
|
28
|
+
fix: boolean;
|
|
29
|
+
color: string;
|
|
30
|
+
reason: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Decide whether an in-mark label needs recolouring for legibility.
|
|
34
|
+
*
|
|
35
|
+
* @param textColor current text colour (any CSS form the SVG carries)
|
|
36
|
+
* @param fill the backing mark's fill colour
|
|
37
|
+
* @param fillOpacity the backing mark's fill-opacity (0..1)
|
|
38
|
+
* @param pageBg the page/visual background the mark sits on (opaque; '' → white)
|
|
39
|
+
* @param minContrast trip point; defaults to MIN_CONTRAST
|
|
40
|
+
*/
|
|
41
|
+
export declare function decideLabelColor(textColor: string | null | undefined, fill: string | null | undefined, fillOpacity: number, pageBg: string | null | undefined, minContrast?: number, normalize?: boolean): LabelDecision;
|
|
42
|
+
export declare const GLYPH_SAMPLE_N = 3;
|
|
43
|
+
/**
|
|
44
|
+
* Evenly-spaced sample points over a glyph box, in the box's own coordinate space.
|
|
45
|
+
* `n` per side (n² points), each at the centre of its cell so no point lands on an edge.
|
|
46
|
+
*/
|
|
47
|
+
export declare function glyphSampleGrid(box: {
|
|
48
|
+
left: number;
|
|
49
|
+
top: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
}, n?: number): {
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
}[];
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The attribute a recoloured (or pill-backed) label carries, so a second pass in the same
|
|
2
|
+
* render leaves it alone. Generated code that rebuilds its text nodes clears it by construction. */
|
|
3
|
+
export declare const LABEL_CONTRAST_DONE_ATTR = "data-lch-contrast";
|
|
4
|
+
/** How many shapes / texts the pass will consider before declining. Layout reads in a loop, so
|
|
5
|
+
* it is a real ceiling: a 5,000-cell heatmap is the size of thing this exists for, a 50,000-node
|
|
6
|
+
* scatter is not, and on the latter the pass costs more than the defect it would fix. */
|
|
7
|
+
export declare const LABEL_CONTRAST_CAP = 2000;
|
|
8
|
+
export interface LabelContrastOptions {
|
|
9
|
+
/** The opaque canvas the marks sit on. Default white; a host with a themed or high-contrast
|
|
10
|
+
* background passes it, or every "is this label readable" answer is measured against the
|
|
11
|
+
* wrong page. */
|
|
12
|
+
pageBg?: string;
|
|
13
|
+
/** Override the DOM ceiling. */
|
|
14
|
+
cap?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface LabelContrastReport {
|
|
17
|
+
/** Filled shapes harvested as candidate backings. */
|
|
18
|
+
rects: number;
|
|
19
|
+
/** Labels that resolved a backing and were judged. */
|
|
20
|
+
scanned: number;
|
|
21
|
+
/** Labels recoloured. `fixed === scanned` is the module's own tell for a pass that is not
|
|
22
|
+
* measuring anything - see the incident notes in labelContrast.ts. */
|
|
23
|
+
fixed: number;
|
|
24
|
+
/** Translucent backdrops boosted to opaque so they actually back their label. */
|
|
25
|
+
pillsBoosted: number;
|
|
26
|
+
/** Labels whose candidates' BOXES contained them but whose FILLS did not - a ring's hole. */
|
|
27
|
+
offFill: number;
|
|
28
|
+
/** Labels mostly over the page with one end clipping a mark - handed back to the chart. */
|
|
29
|
+
pageMajority: number;
|
|
30
|
+
/** Why the pass did nothing, when it did nothing. */
|
|
31
|
+
skipped?: "no-container" | "no-shapes" | "too-many-shapes" | "too-many-texts" | "error";
|
|
32
|
+
}
|
|
33
|
+
export declare function applyLabelContrast(container: HTMLElement | null | undefined, opts?: LabelContrastOptions): LabelContrastReport;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/chart-host",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.74",
|
|
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",
|