@milaboratories/miplots4 1.0.179 → 1.2.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/MiPlots.d.ts.map +1 -1
- package/dist/MiPlots.js +16 -14
- package/dist/MiPlots.js.map +1 -1
- package/dist/common/ContinuousAxis.d.ts +3 -1
- package/dist/common/ContinuousAxis.d.ts.map +1 -1
- package/dist/common/ContinuousAxis.js +8 -8
- package/dist/common/ContinuousAxis.js.map +1 -1
- package/dist/common/Legend.d.ts +12 -1
- package/dist/common/Legend.d.ts.map +1 -1
- package/dist/common/Legend.js +14 -6
- package/dist/common/Legend.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/scatterplot/ChartRenderer.d.ts +2 -2
- package/dist/scatterplot/ChartRenderer.d.ts.map +1 -1
- package/dist/scatterplot/ChartRenderer.js +155 -115
- package/dist/scatterplot/ChartRenderer.js.map +1 -1
- package/dist/scatterplot/ScatterplotSettingsImpl.d.ts +11 -1
- package/dist/scatterplot/ScatterplotSettingsImpl.d.ts.map +1 -1
- package/dist/scatterplot/ScatterplotSettingsImpl.js +20 -0
- package/dist/scatterplot/ScatterplotSettingsImpl.js.map +1 -1
- package/dist/scatterplot/components/ChartLayersData.d.ts +5 -0
- package/dist/scatterplot/components/ChartLayersData.d.ts.map +1 -1
- package/dist/scatterplot/components/ChartLayersData.js +115 -35
- package/dist/scatterplot/components/ChartLayersData.js.map +1 -1
- package/dist/scatterplot/components/types.d.ts +2 -0
- package/dist/scatterplot/components/types.d.ts.map +1 -1
- package/dist/scatterplot/getLayersData.d.ts +11 -2
- package/dist/scatterplot/getLayersData.d.ts.map +1 -1
- package/dist/scatterplot/getLayersData.js +36 -19
- package/dist/scatterplot/getLayersData.js.map +1 -1
- package/dist/scatterplot/index.d.ts.map +1 -1
- package/dist/scatterplot/index.js +51 -33
- package/dist/scatterplot/index.js.map +1 -1
- package/dist/scatterplot/linearRegression.js +1 -1
- package/dist/scatterplot/utils/createAesGetter.d.ts.map +1 -1
- package/dist/scatterplot/utils/createAesGetter.js +5 -3
- package/dist/scatterplot/utils/createAesGetter.js.map +1 -1
- package/dist/scatterplot/utils/createLegendInfo.d.ts +11 -2
- package/dist/scatterplot/utils/createLegendInfo.d.ts.map +1 -1
- package/dist/scatterplot/utils/createLegendInfo.js +21 -16
- package/dist/scatterplot/utils/createLegendInfo.js.map +1 -1
- package/dist/scatterplot-umap/ChartRenderer.d.ts +6 -6
- package/dist/scatterplot-umap/ChartRenderer.d.ts.map +1 -1
- package/dist/scatterplot-umap/ChartRenderer.js +99 -57
- package/dist/scatterplot-umap/ChartRenderer.js.map +1 -1
- package/dist/scatterplot-umap/SettingsImpl.d.ts +11 -1
- package/dist/scatterplot-umap/SettingsImpl.d.ts.map +1 -1
- package/dist/scatterplot-umap/SettingsImpl.js +21 -1
- package/dist/scatterplot-umap/SettingsImpl.js.map +1 -1
- package/dist/scatterplot-umap/components/LowerSVG.d.ts +3 -2
- package/dist/scatterplot-umap/components/LowerSVG.d.ts.map +1 -1
- package/dist/scatterplot-umap/components/LowerSVG.js +159 -108
- package/dist/scatterplot-umap/components/LowerSVG.js.map +1 -1
- package/dist/scatterplot-umap/components/SVGLayer.d.ts +1 -1
- package/dist/scatterplot-umap/components/SVGLayer.d.ts.map +1 -1
- package/dist/scatterplot-umap/components/SVGLayer.js +9 -8
- package/dist/scatterplot-umap/components/SVGLayer.js.map +1 -1
- package/dist/scatterplot-umap/index.d.ts +6 -1
- package/dist/scatterplot-umap/index.d.ts.map +1 -1
- package/dist/scatterplot-umap/index.js +65 -31
- package/dist/scatterplot-umap/index.js.map +1 -1
- package/dist/scatterplot-umap/types.d.ts +7 -0
- package/dist/scatterplot-umap/types.d.ts.map +1 -1
- package/dist/selection/ChartRenderer.d.ts +90 -0
- package/dist/selection/ChartRenderer.d.ts.map +1 -0
- package/dist/selection/ChartRenderer.js +254 -0
- package/dist/selection/ChartRenderer.js.map +1 -0
- package/dist/selection/SelectionSettingsImpl.d.ts +53 -0
- package/dist/selection/SelectionSettingsImpl.d.ts.map +1 -0
- package/dist/selection/SelectionSettingsImpl.js +47 -0
- package/dist/selection/SelectionSettingsImpl.js.map +1 -0
- package/dist/selection/components/Chart/Bars/GroupSelectedBars.d.ts +8 -0
- package/dist/selection/components/Chart/Bars/GroupSelectedBars.d.ts.map +1 -0
- package/dist/selection/components/Chart/Bars/GroupSelectedBars.js +57 -0
- package/dist/selection/components/Chart/Bars/GroupSelectedBars.js.map +1 -0
- package/dist/selection/components/Chart/Bars/StackedBars.d.ts +12 -0
- package/dist/selection/components/Chart/Bars/StackedBars.d.ts.map +1 -0
- package/dist/selection/components/Chart/Bars/StackedBars.js +58 -0
- package/dist/selection/components/Chart/Bars/StackedBars.js.map +1 -0
- package/dist/selection/components/Chart/Bars/UngroupedBars.d.ts +6 -0
- package/dist/selection/components/Chart/Bars/UngroupedBars.d.ts.map +1 -0
- package/dist/selection/components/Chart/Bars/UngroupedBars.js +38 -0
- package/dist/selection/components/Chart/Bars/UngroupedBars.js.map +1 -0
- package/dist/selection/components/Chart/Bars.d.ts +10 -0
- package/dist/selection/components/Chart/Bars.d.ts.map +1 -0
- package/dist/selection/components/Chart/Bars.js +48 -0
- package/dist/selection/components/Chart/Bars.js.map +1 -0
- package/dist/selection/components/Chart/ChartAxes.d.ts +7 -0
- package/dist/selection/components/Chart/ChartAxes.d.ts.map +1 -0
- package/dist/selection/components/Chart/ChartAxes.js +51 -0
- package/dist/selection/components/Chart/ChartAxes.js.map +1 -0
- package/dist/selection/components/Chart/ChartFrame.d.ts +9 -0
- package/dist/selection/components/Chart/ChartFrame.d.ts.map +1 -0
- package/dist/selection/components/Chart/ChartFrame.js +41 -0
- package/dist/selection/components/Chart/ChartFrame.js.map +1 -0
- package/dist/selection/components/Chart/Dividers.d.ts +8 -0
- package/dist/selection/components/Chart/Dividers.d.ts.map +1 -0
- package/dist/selection/components/Chart/Dividers.js +27 -0
- package/dist/selection/components/Chart/Dividers.js.map +1 -0
- package/dist/selection/components/Chart/Gridlines.d.ts +10 -0
- package/dist/selection/components/Chart/Gridlines.d.ts.map +1 -0
- package/dist/selection/components/Chart/Gridlines.js +32 -0
- package/dist/selection/components/Chart/Gridlines.js.map +1 -0
- package/dist/selection/components/Chart/Ribbons/GroupFlowRibbon.d.ts +9 -0
- package/dist/selection/components/Chart/Ribbons/GroupFlowRibbon.d.ts.map +1 -0
- package/dist/selection/components/Chart/Ribbons/GroupFlowRibbon.js +36 -0
- package/dist/selection/components/Chart/Ribbons/GroupFlowRibbon.js.map +1 -0
- package/dist/selection/components/Chart/Ribbons/MultiGroupRibbon.d.ts +6 -0
- package/dist/selection/components/Chart/Ribbons/MultiGroupRibbon.d.ts.map +1 -0
- package/dist/selection/components/Chart/Ribbons/MultiGroupRibbon.js +22 -0
- package/dist/selection/components/Chart/Ribbons/MultiGroupRibbon.js.map +1 -0
- package/dist/selection/components/Chart/Ribbons/SimpleRibbon.d.ts +10 -0
- package/dist/selection/components/Chart/Ribbons/SimpleRibbon.d.ts.map +1 -0
- package/dist/selection/components/Chart/Ribbons/SimpleRibbon.js +33 -0
- package/dist/selection/components/Chart/Ribbons/SimpleRibbon.js.map +1 -0
- package/dist/selection/components/Chart/Ribbons/StackedGroupFlowRibbon.d.ts +10 -0
- package/dist/selection/components/Chart/Ribbons/StackedGroupFlowRibbon.d.ts.map +1 -0
- package/dist/selection/components/Chart/Ribbons/StackedGroupFlowRibbon.js +65 -0
- package/dist/selection/components/Chart/Ribbons/StackedGroupFlowRibbon.js.map +1 -0
- package/dist/selection/components/Chart/Ribbons/ribbonPath.d.ts +10 -0
- package/dist/selection/components/Chart/Ribbons/ribbonPath.d.ts.map +1 -0
- package/dist/selection/components/Chart/Ribbons/ribbonPath.js +13 -0
- package/dist/selection/components/Chart/Ribbons/ribbonPath.js.map +1 -0
- package/dist/selection/components/Chart/Ribbons.d.ts +9 -0
- package/dist/selection/components/Chart/Ribbons.d.ts.map +1 -0
- package/dist/selection/components/Chart/Ribbons.js +58 -0
- package/dist/selection/components/Chart/Ribbons.js.map +1 -0
- package/dist/selection/components/Chart/StageCounts.d.ts +7 -0
- package/dist/selection/components/Chart/StageCounts.d.ts.map +1 -0
- package/dist/selection/components/Chart/StageCounts.js +20 -0
- package/dist/selection/components/Chart/StageCounts.js.map +1 -0
- package/dist/selection/components/Chart/types.d.ts +132 -0
- package/dist/selection/components/Chart/types.d.ts.map +1 -0
- package/dist/selection/components/Chart.d.ts +22 -0
- package/dist/selection/components/Chart.d.ts.map +1 -0
- package/dist/selection/components/Chart.js +97 -0
- package/dist/selection/components/Chart.js.map +1 -0
- package/dist/selection/components/ChartsGroup.d.ts +18 -0
- package/dist/selection/components/ChartsGroup.d.ts.map +1 -0
- package/dist/selection/components/ChartsGroup.js +181 -0
- package/dist/selection/components/ChartsGroup.js.map +1 -0
- package/dist/selection/components/FacetCell.d.ts +22 -0
- package/dist/selection/components/FacetCell.d.ts.map +1 -0
- package/dist/selection/components/FacetCell.js +18 -0
- package/dist/selection/components/FacetCell.js.map +1 -0
- package/dist/selection/components/types.d.ts +58 -0
- package/dist/selection/components/types.d.ts.map +1 -0
- package/dist/selection/constants.d.ts +25 -0
- package/dist/selection/constants.d.ts.map +1 -0
- package/dist/selection/constants.js +4 -0
- package/dist/selection/constants.js.map +1 -0
- package/dist/selection/createSelectionData.d.ts +50 -0
- package/dist/selection/createSelectionData.d.ts.map +1 -0
- package/dist/selection/createSelectionData.js +92 -0
- package/dist/selection/createSelectionData.js.map +1 -0
- package/dist/selection/index.d.ts +26 -0
- package/dist/selection/index.d.ts.map +1 -0
- package/dist/selection/index.js +96 -0
- package/dist/selection/index.js.map +1 -0
- package/dist/selection/utils.d.ts +4 -0
- package/dist/selection/utils.d.ts.map +1 -0
- package/dist/selection/utils.js +13 -0
- package/dist/selection/utils.js.map +1 -0
- package/dist/types/bubble.d.ts +42 -0
- package/dist/types/bubble.d.ts.map +1 -1
- package/dist/types/common.d.ts +38 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +1 -0
- package/dist/types/common.js.map +1 -1
- package/dist/types/dendro.d.ts +103 -0
- package/dist/types/dendro.d.ts.map +1 -1
- package/dist/types/discrete.d.ts +167 -0
- package/dist/types/discrete.d.ts.map +1 -1
- package/dist/types/heatmap.d.ts +159 -0
- package/dist/types/heatmap.d.ts.map +1 -1
- package/dist/types/histogram.d.ts +22 -0
- package/dist/types/histogram.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/scatterplot-umap.d.ts +951 -87
- package/dist/types/scatterplot-umap.d.ts.map +1 -1
- package/dist/types/scatterplot-umap.js +19 -3
- package/dist/types/scatterplot-umap.js.map +1 -1
- package/dist/types/scatterplot.d.ts +1647 -44
- package/dist/types/scatterplot.d.ts.map +1 -1
- package/dist/types/scatterplot.js +27 -3
- package/dist/types/scatterplot.js.map +1 -1
- package/dist/types/selection.d.ts +452 -0
- package/dist/types/selection.d.ts.map +1 -0
- package/dist/types/selection.js +53 -0
- package/dist/types/selection.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const DESATURATE_ALPHA = 0.4;
|
|
2
|
+
export declare const DIM_OPACITY = 0.35;
|
|
3
|
+
export declare const RIBBON_OPACITY = 0.25;
|
|
4
|
+
export declare const BAR_WIDTH_RATIO = 0.35;
|
|
5
|
+
export declare const MIN_BAR_WIDTH = 12;
|
|
6
|
+
export declare const MAX_BAR_WIDTH = 80;
|
|
7
|
+
export declare const MIN_MARGIN = 24;
|
|
8
|
+
export declare const MIN_PADDING = 12;
|
|
9
|
+
export declare const LEGEND_OFFSET = 20;
|
|
10
|
+
export declare const FACET_TITLE_LINE = 48;
|
|
11
|
+
export declare const FACET_TITLE_OFFSET = 24;
|
|
12
|
+
export declare const FACET_TITLE_LINE_HEIGHT = 24;
|
|
13
|
+
export declare const FACET_TITLE_FONT_PX = 20;
|
|
14
|
+
export declare const LABEL_ROTATION_THRESHOLD = 0.65;
|
|
15
|
+
export declare const LABEL_WRAP_WIDTH_PX = 120;
|
|
16
|
+
export declare const LABEL_LINE_HEIGHT_PX = 14;
|
|
17
|
+
export declare const AXIS_LABEL_LINE_HEIGHT = 20;
|
|
18
|
+
export declare const Y_TICK_RESERVE = 40;
|
|
19
|
+
export declare const X_LABEL_TOP_PAD = 6;
|
|
20
|
+
export declare const COUNT_LINE_HEIGHT = 16;
|
|
21
|
+
export declare const X_COUNT_BOTTOM_PAD = 4;
|
|
22
|
+
export declare const DIVIDER_STROKE = "#333";
|
|
23
|
+
export declare const AGGREGATE_RIBBON_COLOR = "#929BAD";
|
|
24
|
+
export declare const FACET_LABEL_FILL = "#1c1c1c";
|
|
25
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/selection/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,WAAW,KAAK,CAAC;AAG9B,eAAO,MAAM,aAAa,KAAK,CAAC;AAKhC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAItC,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAG7C,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAGvC,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAGpC,eAAO,MAAM,cAAc,SAAS,CAAC;AAQrC,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAGhD,eAAO,MAAM,gBAAgB,YAAY,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const e = .4, t = .35, n = .25, r = .35, i = .65, a = "#333", o = "#929BAD", s = "#1c1c1c";
|
|
2
|
+
export { o as AGGREGATE_RIBBON_COLOR, r as BAR_WIDTH_RATIO, e as DESATURATE_ALPHA, t as DIM_OPACITY, a as DIVIDER_STROKE, s as FACET_LABEL_FILL, i as LABEL_ROTATION_THRESHOLD, n as RIBBON_OPACITY };
|
|
3
|
+
|
|
4
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/selection/constants.ts"],"sourcesContent":["export const DESATURATE_ALPHA = 0.4;\nexport const DIM_OPACITY = 0.35;\nexport const RIBBON_OPACITY = 0.25;\nexport const BAR_WIDTH_RATIO = 0.35;\n\nexport const MIN_BAR_WIDTH = 12;\nexport const MAX_BAR_WIDTH = 80;\n\nexport const MIN_MARGIN = 24;\nexport const MIN_PADDING = 12;\n\n// Horizontal gap between the chart's right edge and the legend column.\nexport const LEGEND_OFFSET = 20;\n\n// Facet header strip mirrors heatmap's: 48px tall, 24px between title baseline\n// and plot frame top. Multi-line titles add `FACET_TITLE_LINE_HEIGHT` per\n// extra line.\nexport const FACET_TITLE_LINE = 48;\nexport const FACET_TITLE_OFFSET = 24;\nexport const FACET_TITLE_LINE_HEIGHT = 24;\nexport const FACET_TITLE_FONT_PX = 20;\n\n// Auto-rotate stage labels to 90° when their measured width exceeds this\n// fraction of the band width (centered labels still fit below the threshold).\nexport const LABEL_ROTATION_THRESHOLD = 0.65;\n// Wrap centered (non-rotated) stage labels at this pixel width before\n// `splitTextByWidth` breaks them onto a second line.\nexport const LABEL_WRAP_WIDTH_PX = 120;\n// Line height used when measuring wrapped stage labels.\nexport const LABEL_LINE_HEIGHT_PX = 14;\n\n// Y-axis label line height (used when measuring tick label clearance).\nexport const AXIS_LABEL_LINE_HEIGHT = 20;\n// Reserved width for Y-axis tick text (matches the widest tick label budget).\nexport const Y_TICK_RESERVE = 40;\n// Vertical gap between the X-axis tick line and the top of the X label.\nexport const X_LABEL_TOP_PAD = 6;\n// Line height of the per-bar count label that floats above each bar.\nexport const COUNT_LINE_HEIGHT = 16;\n// Space between count label (above bar) and the top of the plot area.\nexport const X_COUNT_BOTTOM_PAD = 4;\n\n// Dashed-divider stroke between a group's preserved and discarded segments.\nexport const DIVIDER_STROKE = '#333';\n\n// Medium grey (\"Grey\" in graph-maker's FIXED_COLORS), kept readable at the\n// 0.25 RIBBON_OPACITY used here. Drives both the unified ribbon (when bars\n// are grouped but no group is click-selected) and the rare colorMap-miss\n// fallback in the active-group branch. Local because per-chart neutral\n// colors aren't a concern of consumers — see scatterplot's UNKNOWN_COLOR\n// (kept in graph-maker, never threaded through ScatterplotSettings).\nexport const AGGREGATE_RIBBON_COLOR = '#929BAD';\n// Text fill for facet titles and stage count labels — slightly lighter than\n// the chart's BLACK so secondary text doesn't compete with axis labels.\nexport const FACET_LABEL_FILL = '#1c1c1c';\n"],"mappings":"AAAA,MAAa,IAAmB,IACnB,IAAc,KACd,IAAiB,KACjB,IAAkB,KAqBlB,IAA2B,KAmB3B,IAAiB,QAQjB,IAAyB,WAGzB,IAAmB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DataFrame, GroupKey, RowIndex } from '../DataFrame';
|
|
2
|
+
export type StageInfo = {
|
|
3
|
+
index: number;
|
|
4
|
+
label: string;
|
|
5
|
+
total: number;
|
|
6
|
+
surviving: number;
|
|
7
|
+
discarded: number;
|
|
8
|
+
groups: GroupStageData[];
|
|
9
|
+
};
|
|
10
|
+
export type GroupStageData = {
|
|
11
|
+
name: string;
|
|
12
|
+
surviving: number;
|
|
13
|
+
discarded: number;
|
|
14
|
+
};
|
|
15
|
+
export type AggregatedSelectionData = {
|
|
16
|
+
stages: StageInfo[];
|
|
17
|
+
groupNames: string[];
|
|
18
|
+
maxTotal: number;
|
|
19
|
+
};
|
|
20
|
+
export type FacetedSelectionData = {
|
|
21
|
+
facetKeys: string[];
|
|
22
|
+
byFacet: Record<string, AggregatedSelectionData>;
|
|
23
|
+
/** Union of group names across all facets, for a shared legend. */
|
|
24
|
+
groupNames: string[];
|
|
25
|
+
};
|
|
26
|
+
export type SelectionDataParams = {
|
|
27
|
+
data: DataFrame;
|
|
28
|
+
rowIndexes: ArrayLike<RowIndex>;
|
|
29
|
+
stageColumnKey: string;
|
|
30
|
+
weightColumnKey: string | undefined;
|
|
31
|
+
groupColumnKey: string | undefined;
|
|
32
|
+
valueLabelsMap: Record<string, string> | undefined;
|
|
33
|
+
};
|
|
34
|
+
export declare function createSelectionData({ data, rowIndexes, stageColumnKey, weightColumnKey, groupColumnKey, valueLabelsMap, }: SelectionDataParams): AggregatedSelectionData;
|
|
35
|
+
/**
|
|
36
|
+
* Build per-facet selection data from pre-computed facet-key combinations.
|
|
37
|
+
* The caller is responsible for computing combinations via `getKeysCombinations`
|
|
38
|
+
* and seeding `data.setGrouping(...)` so `getRowsByGrouping` returns the
|
|
39
|
+
* matching row indexes — same contract as histogram's `createHistogramDataByFacets`.
|
|
40
|
+
*/
|
|
41
|
+
export type SelectionDataByFacetsParams = {
|
|
42
|
+
data: DataFrame;
|
|
43
|
+
facetKeysCombinations: GroupKey[][];
|
|
44
|
+
stageColumnKey: string;
|
|
45
|
+
weightColumnKey: string | undefined;
|
|
46
|
+
groupColumnKey: string | undefined;
|
|
47
|
+
valueLabelsMap: Record<string, string> | undefined;
|
|
48
|
+
};
|
|
49
|
+
export declare function createSelectionDataByFacets({ data, facetKeysCombinations, stageColumnKey, weightColumnKey, groupColumnKey, valueLabelsMap, }: SelectionDataByFacetsParams): FacetedSelectionData;
|
|
50
|
+
//# sourceMappingURL=createSelectionData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSelectionData.d.ts","sourceRoot":"","sources":["../../src/selection/createSelectionData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGlE,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACjD,mEAAmE;IACnE,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACpD,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,UAAU,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,GACf,EAAE,mBAAmB,GAAG,uBAAuB,CAqH/C;AAED;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,SAAS,CAAC;IAChB,qBAAqB,EAAE,QAAQ,EAAE,EAAE,CAAC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACpD,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EACJ,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,GACf,EAAE,2BAA2B,GAAG,oBAAoB,CA0BpD"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { getFacetStringKey as e } from "../discrete/utils/getFacetStringKey.js";
|
|
2
|
+
function t({ data: e, rowIndexes: t, stageColumnKey: n, weightColumnKey: r, groupColumnKey: i, valueLabelsMap: a }) {
|
|
3
|
+
let o = a ?? {}, s = Array.from(t), c = /* @__PURE__ */ new Set();
|
|
4
|
+
for (let e of Object.keys(o)) {
|
|
5
|
+
let t = Number(e);
|
|
6
|
+
Number.isFinite(t) && c.add(t);
|
|
7
|
+
}
|
|
8
|
+
if (c.size === 0) for (let t of s) {
|
|
9
|
+
let r = e.getColumnValue(n, t);
|
|
10
|
+
r !== null && typeof r == "number" && c.add(r);
|
|
11
|
+
}
|
|
12
|
+
let l = [...c].sort((e, t) => e - t);
|
|
13
|
+
if (l.length === 0 || s.length === 0) return {
|
|
14
|
+
stages: [],
|
|
15
|
+
groupNames: [],
|
|
16
|
+
maxTotal: 0
|
|
17
|
+
};
|
|
18
|
+
let u = /* @__PURE__ */ new Set();
|
|
19
|
+
if (i) for (let t of s) {
|
|
20
|
+
let n = e.getColumnValue(i, t);
|
|
21
|
+
u.add(n === null ? "null" : String(n));
|
|
22
|
+
}
|
|
23
|
+
let d = [...u].sort(), f = (t) => {
|
|
24
|
+
if (!r) return 1;
|
|
25
|
+
let n = e.getColumnValue(r, t);
|
|
26
|
+
return typeof n == "number" && !Number.isNaN(n) ? n : 0;
|
|
27
|
+
}, p = (t) => {
|
|
28
|
+
if (!i) return "All";
|
|
29
|
+
let n = e.getColumnValue(i, t);
|
|
30
|
+
return n === null ? "null" : String(n);
|
|
31
|
+
}, m = l.map((t, r) => {
|
|
32
|
+
let i = r === l.length - 1 ? t : l[r + 1], a = 0, c = 0, u = 0, m = /* @__PURE__ */ new Map();
|
|
33
|
+
if (d.length > 0) for (let e of d) m.set(e, {
|
|
34
|
+
surviving: 0,
|
|
35
|
+
discarded: 0
|
|
36
|
+
});
|
|
37
|
+
for (let r of s) {
|
|
38
|
+
let o = e.getColumnValue(n, r);
|
|
39
|
+
if (!(o === null || typeof o != "number") && o >= t) {
|
|
40
|
+
let e = f(r);
|
|
41
|
+
if (a += e, o >= i ? c += e : u += e, d.length > 0) {
|
|
42
|
+
let t = p(r), n = m.get(t);
|
|
43
|
+
n && (o >= i ? n.surviving += e : n.discarded += e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
let h = d.map((e) => {
|
|
48
|
+
let t = m.get(e);
|
|
49
|
+
return {
|
|
50
|
+
name: e,
|
|
51
|
+
surviving: t?.surviving ?? 0,
|
|
52
|
+
discarded: t?.discarded ?? 0
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
index: t,
|
|
57
|
+
label: o[String(t)] ?? `Stage ${t}`,
|
|
58
|
+
total: a,
|
|
59
|
+
surviving: c,
|
|
60
|
+
discarded: u,
|
|
61
|
+
groups: h
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
stages: m,
|
|
66
|
+
groupNames: d,
|
|
67
|
+
maxTotal: m.length > 0 ? m[0].total : 0
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function n({ data: n, facetKeysCombinations: r, stageColumnKey: i, weightColumnKey: a, groupColumnKey: o, valueLabelsMap: s }) {
|
|
71
|
+
let c = [], l = {}, u = /* @__PURE__ */ new Set();
|
|
72
|
+
for (let d of r) {
|
|
73
|
+
let r = e(d), f = t({
|
|
74
|
+
data: n,
|
|
75
|
+
rowIndexes: n.getRowsByGrouping(d),
|
|
76
|
+
stageColumnKey: i,
|
|
77
|
+
weightColumnKey: a,
|
|
78
|
+
groupColumnKey: o,
|
|
79
|
+
valueLabelsMap: s
|
|
80
|
+
});
|
|
81
|
+
c.push(r), l[r] = f;
|
|
82
|
+
for (let e of f.groupNames) u.add(e);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
facetKeys: c,
|
|
86
|
+
byFacet: l,
|
|
87
|
+
groupNames: [...u].sort()
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export { n as createSelectionDataByFacets };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=createSelectionData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSelectionData.js","names":[],"sources":["../../src/selection/createSelectionData.ts"],"sourcesContent":["import type { DataFrame, GroupKey, RowIndex } from '../DataFrame';\nimport { getFacetStringKey } from '../discrete/utils/getFacetStringKey';\n\nexport type StageInfo = {\n index: number;\n label: string;\n total: number;\n surviving: number;\n discarded: number;\n groups: GroupStageData[];\n};\n\nexport type GroupStageData = {\n name: string;\n surviving: number;\n discarded: number;\n};\n\nexport type AggregatedSelectionData = {\n stages: StageInfo[];\n groupNames: string[];\n maxTotal: number;\n};\n\nexport type FacetedSelectionData = {\n facetKeys: string[];\n byFacet: Record<string, AggregatedSelectionData>;\n /** Union of group names across all facets, for a shared legend. */\n groupNames: string[];\n};\n\nexport type SelectionDataParams = {\n data: DataFrame;\n rowIndexes: ArrayLike<RowIndex>;\n stageColumnKey: string;\n weightColumnKey: string | undefined;\n groupColumnKey: string | undefined;\n valueLabelsMap: Record<string, string> | undefined;\n};\n\nexport function createSelectionData({\n data,\n rowIndexes,\n stageColumnKey,\n weightColumnKey,\n groupColumnKey,\n valueLabelsMap,\n}: SelectionDataParams): AggregatedSelectionData {\n const valueLabels = valueLabelsMap ?? {};\n const rows = Array.from(rowIndexes);\n\n // Stage indices come from valueLabelsMap when present (authoritative: one\n // entry per filter + survivors + optional selected stage). Falling back to\n // stages observed in the data would drop filters that eliminated zero clones,\n // since filter.py only emits rows for non-empty elimination stages.\n const stageSet = new Set<number>();\n for (const key of Object.keys(valueLabels)) {\n const n = Number(key);\n if (Number.isFinite(n)) stageSet.add(n);\n }\n if (stageSet.size === 0) {\n for (const r of rows) {\n const v = data.getColumnValue(stageColumnKey, r);\n if (v !== null && typeof v === 'number') stageSet.add(v);\n }\n }\n const sortedStageIndices = [...stageSet].sort((a, b) => a - b);\n\n if (sortedStageIndices.length === 0 || rows.length === 0) {\n return { stages: [], groupNames: [], maxTotal: 0 };\n }\n\n // Null values use the literal key \"null\" so the aesthetic mapping treats\n // the null group like any other (palette color, not the standalone fallback).\n // Display labels (\"Unknown\", etc.) are handled at the consumer.\n const groupNameSet = new Set<string>();\n if (groupColumnKey) {\n for (const r of rows) {\n const v = data.getColumnValue(groupColumnKey, r);\n groupNameSet.add(v === null ? 'null' : String(v));\n }\n }\n const groupNames = [...groupNameSet].sort();\n\n const getWeight = (i: RowIndex): number => {\n if (!weightColumnKey) return 1;\n const w = data.getColumnValue(weightColumnKey, i);\n return typeof w === 'number' && !Number.isNaN(w) ? w : 0;\n };\n\n const getGroup = (i: RowIndex): string => {\n if (!groupColumnKey) return 'All';\n const g = data.getColumnValue(groupColumnKey, i);\n return g === null ? 'null' : String(g);\n };\n\n const stages: StageInfo[] = sortedStageIndices.map((stageIdx, pos) => {\n const isLastStage = pos === sortedStageIndices.length - 1;\n const nextStageIdx = isLastStage\n ? stageIdx // last stage: all surviving entities are preserved\n : sortedStageIndices[pos + 1];\n\n let total = 0;\n let surviving = 0;\n let discarded = 0;\n const groupTotals = new Map<string, { surviving: number; discarded: number }>();\n\n if (groupNames.length > 0) {\n for (const name of groupNames) {\n groupTotals.set(name, { surviving: 0, discarded: 0 });\n }\n }\n\n for (const i of rows) {\n const sv = data.getColumnValue(stageColumnKey, i);\n if (sv === null || typeof sv !== 'number') continue;\n\n // Entity survives this stage if its selectionStage >= current stage index\n if (sv >= stageIdx) {\n const w = getWeight(i);\n total += w;\n\n if (sv >= nextStageIdx) {\n surviving += w;\n } else {\n discarded += w;\n }\n\n if (groupNames.length > 0) {\n const g = getGroup(i);\n const gt = groupTotals.get(g);\n if (gt) {\n if (sv >= nextStageIdx) {\n gt.surviving += w;\n } else {\n gt.discarded += w;\n }\n }\n }\n }\n }\n\n const groups: GroupStageData[] = groupNames.map((name) => {\n const gt = groupTotals.get(name);\n return {\n name,\n surviving: gt?.surviving ?? 0,\n discarded: gt?.discarded ?? 0,\n };\n });\n\n return {\n index: stageIdx,\n label: valueLabels[String(stageIdx)] ?? `Stage ${stageIdx}`,\n total,\n surviving,\n discarded,\n groups,\n };\n });\n\n const maxTotal = stages.length > 0 ? stages[0].total : 0;\n\n return { stages, groupNames, maxTotal };\n}\n\n/**\n * Build per-facet selection data from pre-computed facet-key combinations.\n * The caller is responsible for computing combinations via `getKeysCombinations`\n * and seeding `data.setGrouping(...)` so `getRowsByGrouping` returns the\n * matching row indexes — same contract as histogram's `createHistogramDataByFacets`.\n */\nexport type SelectionDataByFacetsParams = {\n data: DataFrame;\n facetKeysCombinations: GroupKey[][];\n stageColumnKey: string;\n weightColumnKey: string | undefined;\n groupColumnKey: string | undefined;\n valueLabelsMap: Record<string, string> | undefined;\n};\n\nexport function createSelectionDataByFacets({\n data,\n facetKeysCombinations,\n stageColumnKey,\n weightColumnKey,\n groupColumnKey,\n valueLabelsMap,\n}: SelectionDataByFacetsParams): FacetedSelectionData {\n const facetKeys: string[] = [];\n const byFacet: Record<string, AggregatedSelectionData> = {};\n const groupNamesSet = new Set<string>();\n\n for (const combo of facetKeysCombinations) {\n const facetKey = getFacetStringKey(combo);\n const indexes = data.getRowsByGrouping(combo);\n const agg = createSelectionData({\n data,\n rowIndexes: indexes,\n stageColumnKey,\n weightColumnKey,\n groupColumnKey,\n valueLabelsMap,\n });\n facetKeys.push(facetKey);\n byFacet[facetKey] = agg;\n for (const g of agg.groupNames) groupNamesSet.add(g);\n }\n\n return {\n facetKeys,\n byFacet,\n groupNames: [...groupNamesSet].sort(),\n };\n}\n"],"mappings":";AAwCA,SAAgB,EAAoB,EAClC,SACA,eACA,mBACA,oBACA,mBACA,qBAC+C;CAC/C,IAAM,IAAc,KAAkB,EAAE,EAClC,IAAO,MAAM,KAAK,EAAW,EAM7B,oBAAW,IAAI,KAAa;AAClC,MAAK,IAAM,KAAO,OAAO,KAAK,EAAY,EAAE;EAC1C,IAAM,IAAI,OAAO,EAAI;AACrB,EAAI,OAAO,SAAS,EAAE,IAAE,EAAS,IAAI,EAAE;;AAEzC,KAAI,EAAS,SAAS,EACpB,MAAK,IAAM,KAAK,GAAM;EACpB,IAAM,IAAI,EAAK,eAAe,GAAgB,EAAE;AAChD,EAAI,MAAM,QAAQ,OAAO,KAAM,YAAU,EAAS,IAAI,EAAE;;CAG5D,IAAM,IAAqB,CAAC,GAAG,EAAS,CAAC,MAAM,GAAG,MAAM,IAAI,EAAE;AAE9D,KAAI,EAAmB,WAAW,KAAK,EAAK,WAAW,EACrD,QAAO;EAAE,QAAQ,EAAE;EAAE,YAAY,EAAE;EAAE,UAAU;EAAG;CAMpD,IAAM,oBAAe,IAAI,KAAa;AACtC,KAAI,EACF,MAAK,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aAAa;IAC7B;IACD;AAEF,SAAO;GACL,OAAO;GACP,OAAO,EAAY,OAAO,EAAS,KAAK,SAAS;GACjD;GACA;GACA;GACA;GACD;GACD;AAIF,QAAO;EAAE;EAAQ;EAAY,UAFZ,EAAO,SAAS,IAAI,EAAO,GAAG,QAAQ;EAEhB;;AAkBzC,SAAgB,EAA4B,EAC1C,SACA,0BACA,mBACA,oBACA,mBACA,qBACoD;CACpD,IAAM,IAAsB,EAAE,EACxB,IAAmD,EAAE,EACrD,oBAAgB,IAAI,KAAa;AAEvC,MAAK,IAAM,KAAS,GAAuB;EACzC,IAAM,IAAW,EAAkB,EAAM,EAEnC,IAAM,EAAoB;GAC9B;GACA,YAHc,EAAK,kBAAkB,EAAM;GAI3C;GACA;GACA;GACA;GACD,CAAC;AAEF,EADA,EAAU,KAAK,EAAS,EACxB,EAAQ,KAAY;AACpB,OAAK,IAAM,KAAK,EAAI,WAAY,GAAc,IAAI,EAAE;;AAGtD,QAAO;EACL;EACA;EACA,YAAY,CAAC,GAAG,EAAc,CAAC,MAAM;EACtC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AbstractChart } from '../AbstractChart';
|
|
2
|
+
import { DataFrame } from '../DataFrame';
|
|
3
|
+
import { SelectionSettings } from '../types';
|
|
4
|
+
import { default as ChartRenderer } from './ChartRenderer';
|
|
5
|
+
import { FacetedSelectionData } from './createSelectionData';
|
|
6
|
+
import { SelectionSettingsImpl } from './SelectionSettingsImpl';
|
|
7
|
+
export type SelectionEventHandlers = [(d: boolean) => void];
|
|
8
|
+
export declare class ChartSelection extends AbstractChart {
|
|
9
|
+
settings: SelectionSettingsImpl;
|
|
10
|
+
chartRenderer: ChartRenderer;
|
|
11
|
+
calculatedData: {
|
|
12
|
+
faceted: FacetedSelectionData;
|
|
13
|
+
facetLabels: Record<string, string[]>;
|
|
14
|
+
} | null;
|
|
15
|
+
constructor(data: DataFrame, settings: SelectionSettings, _eventHandlers?: SelectionEventHandlers);
|
|
16
|
+
mount(node: HTMLElement): void;
|
|
17
|
+
unmount(): void;
|
|
18
|
+
updateSettingsAndData(data: DataFrame, settings: SelectionSettings): void;
|
|
19
|
+
_needUpdateCalculatedDataBySettings(prev: SelectionSettingsImpl, settings: SelectionSettingsImpl): boolean;
|
|
20
|
+
_needUpdateCalculatedDataByData(prevData: DataFrame, data: DataFrame): boolean;
|
|
21
|
+
updateChartState(_field: string, _value: unknown): void;
|
|
22
|
+
export(): string;
|
|
23
|
+
private _updateData;
|
|
24
|
+
private _updateChart;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/selection/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,cAAc,CAAC;AAIxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC,CAAC;AAa5D,qBAAa,cAAe,SAAQ,aAAa;IAC/C,QAAQ,EAAE,qBAAqB,CAAC;IAChC,aAAa,gBAAuB;IACpC,cAAc,EAAE;QAAE,OAAO,EAAE,oBAAoB,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;KAAE,GAAG,IAAI,CACxF;gBAGL,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,CAAC,EAAE,sBAAsB;IAMzC,KAAK,CAAC,IAAI,EAAE,WAAW;IAiBvB,OAAO;IAIP,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB;IAyBlE,mCAAmC,CACjC,IAAI,EAAE,qBAAqB,EAC3B,QAAQ,EAAE,qBAAqB;IAgBjC,+BAA+B,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS;IAUpE,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAIhD,MAAM,IAAI,MAAM;IAKhB,OAAO,CAAC,WAAW;IAmCnB,OAAO,CAAC,YAAY;CAoCrB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { AbstractChart as e } from "../AbstractChart.js";
|
|
2
|
+
import { getUnknownErrorInfo as t, isErrorInfo as n } from "../types/common.js";
|
|
3
|
+
import "../types/index.js";
|
|
4
|
+
import { NO_GROUPED as r } from "../DataFrame.js";
|
|
5
|
+
import { getFacetStringKey as i } from "../discrete/utils/getFacetStringKey.js";
|
|
6
|
+
import { arraysAreDifferent as a } from "../utils/arraysAreDifferent.js";
|
|
7
|
+
import { getFacetLabels as o } from "../discrete/utils/getFacetLabels.js";
|
|
8
|
+
import { getKeysCombinations as s } from "../utils/getKeysCombination.js";
|
|
9
|
+
import c from "./ChartRenderer.js";
|
|
10
|
+
import { createSelectionDataByFacets as l } from "./createSelectionData.js";
|
|
11
|
+
import { SelectionSettingsImpl as u } from "./SelectionSettingsImpl.js";
|
|
12
|
+
import { renderToString as d } from "react-dom/server.browser";
|
|
13
|
+
function f(e, t) {
|
|
14
|
+
let n = e ?? {}, r = t ?? {}, i = Object.keys(n);
|
|
15
|
+
return i.length === Object.keys(r).length ? i.some((e) => n[e] !== r[e]) : !0;
|
|
16
|
+
}
|
|
17
|
+
var p = class extends e {
|
|
18
|
+
settings;
|
|
19
|
+
chartRenderer = new c();
|
|
20
|
+
calculatedData = null;
|
|
21
|
+
constructor(e, t, n) {
|
|
22
|
+
super(e, t), this.settings = new u(t);
|
|
23
|
+
}
|
|
24
|
+
mount(e) {
|
|
25
|
+
try {
|
|
26
|
+
this.chartRenderer.init(e), this._updateData(), this._updateChart(), this.hasError = !1, this.errorInfo = null;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
this.hasError = !0, e instanceof Error && (this.errorInfo = n(e.cause) ? e.cause : t(e), this.chartRenderer.renderError(e.message), console.error(e));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
unmount() {
|
|
32
|
+
this.chartRenderer.clear();
|
|
33
|
+
}
|
|
34
|
+
updateSettingsAndData(e, r) {
|
|
35
|
+
try {
|
|
36
|
+
let t = this.settings, n = this.data;
|
|
37
|
+
this.settings = new u(r), this.data = e, (this._needUpdateCalculatedDataBySettings(t, this.settings) || this._needUpdateCalculatedDataByData(n, this.data)) && this._updateData(), this._updateChart(), this.hasError = !1, this.errorInfo = null;
|
|
38
|
+
} catch (e) {
|
|
39
|
+
this.hasError = !0, e instanceof Error && (this.errorInfo = n(e.cause) ? e.cause : t(e), this.chartRenderer.renderError(e.message), console.error(e));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
_needUpdateCalculatedDataBySettings(e, t) {
|
|
43
|
+
return e.selectionStage.value !== t.selectionStage.value || e.weight?.value !== t.weight?.value || e.grouping?.columnName.value !== t.grouping?.columnName.value || e.facetBy.length !== t.facetBy.length || e.facetBy.some((e, n) => e.value !== t.facetBy[n]?.value) || a(e.facetSettings.order ?? [], t.facetSettings.order ?? []) || f(e.selectionStage.valueLabelsMap, t.selectionStage.valueLabelsMap);
|
|
44
|
+
}
|
|
45
|
+
_needUpdateCalculatedDataByData(e, t) {
|
|
46
|
+
let n = Object.keys(e.data), r = Object.keys(t.data);
|
|
47
|
+
return e.id !== t.id || n.length !== r.length || n.some((n) => e.data[n].length !== t.data[n]?.length);
|
|
48
|
+
}
|
|
49
|
+
updateChartState(e, t) {
|
|
50
|
+
console.warn("no chart state for selection chart");
|
|
51
|
+
}
|
|
52
|
+
export() {
|
|
53
|
+
return this._updateChart(), d(this.chartRenderer.component);
|
|
54
|
+
}
|
|
55
|
+
_updateData() {
|
|
56
|
+
let { selectionStage: e, weight: t, grouping: n, facetBy: a } = this.settings, c = a.length ? a.map((e) => e.value) : [null], u = a.length ? s(a.map((e) => this.data.getColumnCategories(e.value, !1).map(String))) : [[r]];
|
|
57
|
+
u.length === 0 && (u = [[r]]), this.data.setGrouping(c);
|
|
58
|
+
let d = l({
|
|
59
|
+
data: this.data,
|
|
60
|
+
facetKeysCombinations: u,
|
|
61
|
+
stageColumnKey: e.value,
|
|
62
|
+
weightColumnKey: t?.value,
|
|
63
|
+
groupColumnKey: n?.columnName.value,
|
|
64
|
+
valueLabelsMap: e.valueLabelsMap
|
|
65
|
+
}), f = o(this.data, a, d.facetKeys, u);
|
|
66
|
+
this.calculatedData = {
|
|
67
|
+
faceted: d,
|
|
68
|
+
facetLabels: a.length ? f : { [i([r])]: [] }
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
_updateChart() {
|
|
72
|
+
if (!this.calculatedData) return;
|
|
73
|
+
let { title: e, size: t, grouping: n, showLegend: r, facetBy: i, facetSettings: a, xAxis: o, yAxis: s, frame: c, fillColor: l, opacity: u } = this.settings;
|
|
74
|
+
this.chartRenderer.render({
|
|
75
|
+
faceted: this.calculatedData.faceted,
|
|
76
|
+
facetLabels: this.calculatedData.facetLabels,
|
|
77
|
+
width: t.width,
|
|
78
|
+
height: t.height,
|
|
79
|
+
title: e.name,
|
|
80
|
+
showTitle: e.show,
|
|
81
|
+
grouping: n,
|
|
82
|
+
showLegend: r,
|
|
83
|
+
facetBy: i,
|
|
84
|
+
facetSettings: a,
|
|
85
|
+
xAxis: o,
|
|
86
|
+
yAxis: s,
|
|
87
|
+
frame: c,
|
|
88
|
+
titlePosition: e.position,
|
|
89
|
+
fillColor: l,
|
|
90
|
+
opacity: u
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
export { p as ChartSelection };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/selection/index.ts"],"sourcesContent":["import { renderToString } from 'react-dom/server.browser';\n\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame, GroupKey } from '../DataFrame';\nimport { NO_GROUPED } from '../DataFrame';\nimport { getFacetLabels } from '../discrete/utils/getFacetLabels';\nimport { getFacetStringKey } from '../discrete/utils/getFacetStringKey';\nimport type { SelectionSettings } from '../types';\nimport { getUnknownErrorInfo, isErrorInfo } from '../types';\nimport { arraysAreDifferent } from '../utils/arraysAreDifferent';\nimport { getKeysCombinations } from '../utils/getKeysCombination';\nimport ChartRenderer from './ChartRenderer';\nimport { createSelectionDataByFacets } from './createSelectionData';\nimport type { FacetedSelectionData } from './createSelectionData';\nimport { SelectionSettingsImpl } from './SelectionSettingsImpl';\n\nexport type SelectionEventHandlers = [(d: boolean) => void];\n\nfunction valueLabelsMapDiffers(\n prev: Record<string, string> | undefined,\n next: Record<string, string> | undefined,\n) {\n const prevMap = prev ?? {};\n const nextMap = next ?? {};\n const prevKeys = Object.keys(prevMap);\n if (prevKeys.length !== Object.keys(nextMap).length) return true;\n return prevKeys.some((k) => prevMap[k] !== nextMap[k]);\n}\n\nexport class ChartSelection extends AbstractChart {\n settings: SelectionSettingsImpl;\n chartRenderer = new ChartRenderer();\n calculatedData: { faceted: FacetedSelectionData; facetLabels: Record<string, string[]> } | null =\n null;\n\n constructor(\n data: DataFrame,\n settings: SelectionSettings,\n _eventHandlers?: SelectionEventHandlers,\n ) {\n super(data, settings);\n this.settings = new SelectionSettingsImpl(settings);\n }\n\n mount(node: HTMLElement) {\n try {\n this.chartRenderer.init(node);\n this._updateData();\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message);\n console.error(err);\n }\n }\n }\n\n unmount() {\n this.chartRenderer.clear();\n }\n\n updateSettingsAndData(data: DataFrame, settings: SelectionSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new SelectionSettingsImpl(settings);\n this.data = data;\n if (\n this._needUpdateCalculatedDataBySettings(previousSettings, this.settings) ||\n this._needUpdateCalculatedDataByData(previousData, this.data)\n ) {\n this._updateData();\n }\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message);\n console.error(err);\n }\n }\n }\n\n _needUpdateCalculatedDataBySettings(\n prev: SelectionSettingsImpl,\n settings: SelectionSettingsImpl,\n ) {\n return (\n prev.selectionStage.value !== settings.selectionStage.value ||\n prev.weight?.value !== settings.weight?.value ||\n prev.grouping?.columnName.value !== settings.grouping?.columnName.value ||\n prev.facetBy.length !== settings.facetBy.length ||\n prev.facetBy.some((el, idx) => el.value !== settings.facetBy[idx]?.value) ||\n arraysAreDifferent(prev.facetSettings.order ?? [], settings.facetSettings.order ?? []) ||\n valueLabelsMapDiffers(\n prev.selectionStage.valueLabelsMap,\n settings.selectionStage.valueLabelsMap,\n )\n );\n }\n\n _needUpdateCalculatedDataByData(prevData: DataFrame, data: DataFrame) {\n const prevKeys = Object.keys(prevData.data);\n const keys = Object.keys(data.data);\n return (\n prevData.id !== data.id ||\n prevKeys.length !== keys.length ||\n prevKeys.some((key) => prevData.data[key].length !== data.data[key]?.length)\n );\n }\n\n updateChartState(_field: string, _value: unknown) {\n console.warn('no chart state for selection chart');\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n private _updateData() {\n const { selectionStage, weight, grouping, facetBy } = this.settings;\n\n const facetGroupingValues = facetBy.length ? facetBy.map((c) => c.value) : [null];\n let facetKeyLists: GroupKey[][] = facetBy.length\n ? getKeysCombinations(\n facetBy.map((c) => this.data.getColumnCategories(c.value, false).map(String)),\n )\n : [[NO_GROUPED]];\n // Configured facetBy with no row values yields an empty combination set;\n // fall back to the no-grouped sentinel so downstream grid math always\n // sees at least one facet (matches histogram/discrete).\n if (facetKeyLists.length === 0) facetKeyLists = [[NO_GROUPED]];\n\n this.data.setGrouping(facetGroupingValues);\n\n const faceted = createSelectionDataByFacets({\n data: this.data,\n facetKeysCombinations: facetKeyLists,\n stageColumnKey: selectionStage.value,\n weightColumnKey: weight?.value,\n groupColumnKey: grouping?.columnName.value,\n valueLabelsMap: selectionStage.valueLabelsMap,\n });\n\n const labelParts = getFacetLabels(this.data, facetBy, faceted.facetKeys, facetKeyLists);\n // Drop the placeholder 'null' parts the helper emits when there's no\n // facet column, so downstream renders an empty header instead of \"null\".\n const facetLabels: Record<string, string[]> = facetBy.length\n ? labelParts\n : { [getFacetStringKey([NO_GROUPED])]: [] };\n\n this.calculatedData = { faceted, facetLabels };\n }\n\n private _updateChart() {\n if (!this.calculatedData) return;\n\n const {\n title,\n size,\n grouping,\n showLegend,\n facetBy,\n facetSettings,\n xAxis,\n yAxis,\n frame,\n fillColor,\n opacity,\n } = this.settings;\n\n this.chartRenderer.render({\n faceted: this.calculatedData.faceted,\n facetLabels: this.calculatedData.facetLabels,\n width: size.width,\n height: size.height,\n title: title.name,\n showTitle: title.show,\n grouping,\n showLegend,\n facetBy,\n facetSettings,\n xAxis,\n yAxis,\n frame,\n titlePosition: title.position,\n fillColor,\n opacity,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAS,EACP,GACA,GACA;CACA,IAAM,IAAU,KAAQ,EAAE,EACpB,IAAU,KAAQ,EAAE,EACpB,IAAW,OAAO,KAAK,EAAQ;AAErC,QADI,EAAS,WAAW,OAAO,KAAK,EAAQ,CAAC,SACtC,EAAS,MAAM,MAAM,EAAQ,OAAO,EAAQ,GAAG,GADM;;AAI9D,IAAa,IAAb,cAAoC,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uB;AACrB,MAAI,CAAC,KAAK,eAAgB;EAE1B,IAAM,EACJ,UACA,SACA,aACA,eACA,YACA,kBACA,UACA,UACA,UACA,cACA,eACE,KAAK;AAET,OAAK,cAAc,OAAO;GACxB,SAAS,KAAK,eAAe;GAC7B,aAAa,KAAK,eAAe;GACjC,OAAO,EAAK;GACZ,QAAQ,EAAK;GACb,OAAO,EAAM;GACb,WAAW,EAAM;GACjB;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAAe,EAAM;GACrB;GACA;GACD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/selection/utils.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,KAAG,MAA2B,CAAC;AAGpE,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,KAAG,MAA2B,CAAC;AAEtE,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAAoB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var e = new Intl.NumberFormat("en", {
|
|
2
|
+
notation: "compact",
|
|
3
|
+
maximumFractionDigits: 1
|
|
4
|
+
});
|
|
5
|
+
const t = (t) => e.format(t);
|
|
6
|
+
var n = new Intl.NumberFormat("en", {
|
|
7
|
+
style: "unit",
|
|
8
|
+
unit: "percent"
|
|
9
|
+
});
|
|
10
|
+
const r = (e) => n.format(e), i = (e) => e * 100;
|
|
11
|
+
export { t as formatCount, r as formatPercent, i as toPercent };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/selection/utils.ts"],"sourcesContent":["const compact = new Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 1 });\nexport const formatCount = (n: number): string => compact.format(n);\n\nconst percent = new Intl.NumberFormat('en', { style: 'unit', unit: 'percent' });\nexport const formatPercent = (n: number): string => percent.format(n);\n\nexport const toPercent = (frac: number): number => frac * 100;\n"],"mappings":"AAAA,IAAM,IAAU,IAAI,KAAK,aAAa,MAAM;CAAE,UAAU;CAAW,uBAAuB;CAAG,CAAC;AAC9F,MAAa,KAAe,MAAsB,EAAQ,OAAO,EAAE;AAEnE,IAAM,IAAU,IAAI,KAAK,aAAa,MAAM;CAAE,OAAO;CAAQ,MAAM;CAAW,CAAC;AAC/E,MAAa,KAAiB,MAAsB,EAAQ,OAAO,EAAE,EAExD,KAAa,MAAyB,IAAO"}
|