@bicharts/chart-host 0.6.56 → 0.6.58
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-CMHGGW3Y.mjs → chunk-5NSU3MYW.mjs} +41 -110
- package/dist/chunk-WNGJUPEI.mjs +114 -0
- package/dist/chunk-ZEZXNAFL.mjs +467 -0
- package/dist/dax.mjs +60 -0
- package/dist/geo.mjs +3 -3
- package/dist/index.mjs +49 -47
- package/dist/page.mjs +28 -0
- package/dist/react.mjs +207 -8
- package/dist/testing.mjs +46 -1
- package/dist/types/controls.d.ts +50 -0
- package/dist/types/dax.d.ts +22 -0
- package/dist/types/filterScope.d.ts +133 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/markNotes.d.ts +30 -0
- package/dist/types/page.d.ts +3 -0
- package/dist/types/react.d.ts +73 -2
- package/dist/types/testing/index.d.ts +1 -0
- package/dist/types/testing/interact.d.ts +17 -0
- package/package.json +11 -1
package/dist/types/react.d.ts
CHANGED
|
@@ -2,7 +2,12 @@ import type { ReactNode, RefObject } from "react";
|
|
|
2
2
|
import { type ChartHostConfig } from "./host";
|
|
3
3
|
import type { ResolveOptionsInput } from "./defaults";
|
|
4
4
|
import type { GeoPointBinding } from "./payload";
|
|
5
|
+
import { type Filter, type FilterOptions } from "./filterScope";
|
|
5
6
|
export { assembleD3 } from "./host";
|
|
7
|
+
import { type Controls } from "./controls";
|
|
8
|
+
export { createControls, type Controls, type ControlInfo } from "./controls";
|
|
9
|
+
export { noteBadges, badgeKey, notesFor, type MarkNoteLike, type NoteBadgeOptions } from "./markNotes";
|
|
10
|
+
export { createFilter, createFilterScope, fromVegaInteraction, type Filter, type FilterOptions, type FilterScope, type FilterChangeReason } from "./filterScope";
|
|
6
11
|
export interface BicChartProps {
|
|
7
12
|
/** Generated render() source (an ES module's `code` export, or the raw string). */
|
|
8
13
|
code?: string;
|
|
@@ -59,11 +64,34 @@ export interface BicChartProps {
|
|
|
59
64
|
* now two props rather than a DOM workaround.
|
|
60
65
|
*/
|
|
61
66
|
respondsWith?: "filter" | "highlight";
|
|
62
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* THE PAGE FILTER THIS CHART SELECTS - from useBicFilter("RegionCode"). A click sets it, the
|
|
69
|
+
* same click or a click on empty canvas clears it, and the filter's state is painted onto the
|
|
70
|
+
* marks whoever changed it: `filter.clear()` from a page button clears the marks too. New data
|
|
71
|
+
* keeps a selection whose key is still drawn and clears (reason "data") one whose key is gone.
|
|
72
|
+
* The page reads `filter.value` / `filter.row` and never writes a select handler. With
|
|
73
|
+
* `selects`, the filter owns what this chart shows as selected.
|
|
74
|
+
*/
|
|
75
|
+
selects?: Filter;
|
|
76
|
+
/**
|
|
77
|
+
* THE CHART'S OWN CONTROLS AS PAGE STATE - from useBicControls(). For a chart that draws
|
|
78
|
+
* sliders (the What-if projection's rate and horizon): `controls.values` holds every
|
|
79
|
+
* knob's value from the first draw (no slider has to move first), `controls.info` / `summary`
|
|
80
|
+
* the chart's own label and readout for each ("growth per year +5.5%"), `controls.set(saved)`
|
|
81
|
+
* applies a saved scenario and `controls.reset()` returns to the defaults. It owns the chart's
|
|
82
|
+
* uiState / setUiState.
|
|
83
|
+
*/
|
|
84
|
+
controls?: Controls;
|
|
85
|
+
/**
|
|
86
|
+
* Selection callback in SOURCE row indices (group) or payload indices (standalone). An empty
|
|
87
|
+
* list means the selection was CLEARED: the same mark clicked again, a click on empty canvas,
|
|
88
|
+
* or new data that no longer draws what was selected. The chart toggles for you - set your
|
|
89
|
+
* state from exactly what this gives you, never toggle it again. Prefer `selects`.
|
|
90
|
+
*/
|
|
63
91
|
onSelect?: (rowIdxs: number[]) => void;
|
|
64
92
|
/**
|
|
65
93
|
* Notes on marks: a badge on each key's mark, redrawn after every render - e.g.
|
|
66
|
-
* `[{ column: "
|
|
94
|
+
* `[{ column: "RegionCode", value: "JPN", label: "2", title: "..." }]`. Keyed by a value in a column,
|
|
67
95
|
* never a row position, so a filter or a re-query never moves one.
|
|
68
96
|
*/
|
|
69
97
|
annotations?: ChartHostConfig["annotations"];
|
|
@@ -71,6 +99,8 @@ export interface BicChartProps {
|
|
|
71
99
|
onAnnotationClick?: ChartHostConfig["onAnnotationClick"];
|
|
72
100
|
className?: string;
|
|
73
101
|
style?: React.CSSProperties;
|
|
102
|
+
/** What a screen reader announces for the chart ("Occupancy vs average daily rate, by country"). */
|
|
103
|
+
ariaLabel?: string;
|
|
74
104
|
}
|
|
75
105
|
/** Read the group's selection from a page — for a "clear" button or a count. */
|
|
76
106
|
export declare function useBicSelection(): {
|
|
@@ -100,6 +130,47 @@ export interface BicChartGroupProps {
|
|
|
100
130
|
*/
|
|
101
131
|
export declare function BicChartGroup({ rows, columns, geo, point, destination, children }: BicChartGroupProps): import("react").JSX.Element;
|
|
102
132
|
export declare function BicChart(props: BicChartProps): import("react").JSX.Element;
|
|
133
|
+
/**
|
|
134
|
+
* A SEPARATE filter scope, for an app with several independent pages or panels mounted at once.
|
|
135
|
+
* Not needed otherwise: every filter joins the app's one default scope. Call useBicFilter in a
|
|
136
|
+
* component INSIDE it - a hook can't see a provider its own component renders.
|
|
137
|
+
*/
|
|
138
|
+
export declare function BicPage({ children }: {
|
|
139
|
+
children: ReactNode;
|
|
140
|
+
}): import("react").JSX.Element;
|
|
141
|
+
/**
|
|
142
|
+
* A page filter keyed by one model column ("RegionCode") or several (a route:
|
|
143
|
+
* ["OriginCode", "DestinationCode"]). Pass it to a chart's `selects` and read
|
|
144
|
+
* `value` / `values` / `row` / `active` for the rest of the page; `clear()` clears it and the
|
|
145
|
+
* chart's marks. Re-renders the component on every change. The key columns are read once.
|
|
146
|
+
*/
|
|
147
|
+
export declare function useBicFilter(columns: string | readonly string[], opts?: FilterOptions): Filter;
|
|
148
|
+
/**
|
|
149
|
+
* A chart's in-chart controls as page state: pass to the chart's `controls`, read `values`, `info`
|
|
150
|
+
* and `summary`, `set(saved)` to apply a saved scenario, `reset()` for the defaults. Re-renders the
|
|
151
|
+
* component on every change. `initial` seeds the values the chart first draws with.
|
|
152
|
+
*/
|
|
153
|
+
export declare function useBicControls(initial?: Readonly<Record<string, unknown>>): Controls;
|
|
154
|
+
/** Every filter on the page (or the enclosing <BicPage>), and its clear-all - for a page's own chip bar or count. */
|
|
155
|
+
export declare function useBicFilters(): {
|
|
156
|
+
filters: readonly Filter[];
|
|
157
|
+
active: readonly Filter[];
|
|
158
|
+
clearAll: () => void;
|
|
159
|
+
};
|
|
160
|
+
export interface BicFilterChipsProps {
|
|
161
|
+
className?: string;
|
|
162
|
+
/** Each chip's class (the label, the value and its × are inside). */
|
|
163
|
+
chipClassName?: string;
|
|
164
|
+
/** The words on the clear-all button, shown when two or more filters are active. Default "Clear all". */
|
|
165
|
+
clearAllText?: string;
|
|
166
|
+
style?: React.CSSProperties;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* What the page is filtered by: one chip per active filter ("Country: Japan ×"), a × that
|
|
170
|
+
* clears it (and its chart's marks), and "Clear all" when two or more are active. Renders nothing
|
|
171
|
+
* while nothing is filtered. Plain markup with class names to style.
|
|
172
|
+
*/
|
|
173
|
+
export declare function BicFilterChips({ className, chipClassName, clearAllText, style }: BicFilterChipsProps): import("react").JSX.Element;
|
|
103
174
|
/**
|
|
104
175
|
* THE SIZE A CHART SHOULD DRAW AT: the element's measured box, kept current as it resizes.
|
|
105
176
|
*
|
|
@@ -12,3 +12,4 @@ export declare class ConformanceError extends Error {
|
|
|
12
12
|
* before returning, whether or not the check passed.
|
|
13
13
|
*/
|
|
14
14
|
export declare function assertMarkerStoreConformance(store: MarkerStore): Promise<void>;
|
|
15
|
+
export { chartContainers, marksOf, findMark, clickMark, clickEmpty, selectedRows } from "./interact";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Every hosted chart container under `root` (a page, a component's element). */
|
|
2
|
+
export declare function chartContainers(root: ParentNode): HTMLElement[];
|
|
3
|
+
/** The chart's data marks, in DOM order. */
|
|
4
|
+
export declare function marksOf(chart: ParentNode): Element[];
|
|
5
|
+
/**
|
|
6
|
+
* The mark drawing payload row `rowIdx` - or, given a predicate, the first mark it accepts (e.g.
|
|
7
|
+
* `m => m.getAttribute("data-code") === "JPN"` for a chart that labels its marks).
|
|
8
|
+
*/
|
|
9
|
+
export declare function findMark(chart: ParentNode, which: number | ((mark: Element) => boolean)): Element | null;
|
|
10
|
+
/** Click a mark as a reader does; `add` holds Ctrl to add it to the selection. */
|
|
11
|
+
export declare function clickMark(mark: Element, opts?: {
|
|
12
|
+
add?: boolean;
|
|
13
|
+
}): void;
|
|
14
|
+
/** Click the chart's empty canvas (no mark): clears its selection. */
|
|
15
|
+
export declare function clickEmpty(chart: Element): void;
|
|
16
|
+
/** The payload rows the chart shows as selected now. */
|
|
17
|
+
export declare function selectedRows(chart: ParentNode): number[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/chart-host",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.58",
|
|
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",
|
|
@@ -39,6 +39,16 @@
|
|
|
39
39
|
"import": "./dist/geo-us-zip3.mjs",
|
|
40
40
|
"default": "./dist/geo-us-zip3.mjs"
|
|
41
41
|
},
|
|
42
|
+
"./page": {
|
|
43
|
+
"types": "./dist/types/page.d.ts",
|
|
44
|
+
"import": "./dist/page.mjs",
|
|
45
|
+
"default": "./dist/page.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./dax": {
|
|
48
|
+
"types": "./dist/types/dax.d.ts",
|
|
49
|
+
"import": "./dist/dax.mjs",
|
|
50
|
+
"default": "./dist/dax.mjs"
|
|
51
|
+
},
|
|
42
52
|
"./testing": {
|
|
43
53
|
"types": "./dist/types/testing/index.d.ts",
|
|
44
54
|
"import": "./dist/testing.mjs",
|