@milaboratories/miplots4 1.0.174 → 1.0.176
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/DataFrame.d.ts +1 -1
- package/dist/DataFrame.d.ts.map +1 -1
- package/dist/DataFrame.js +52 -51
- package/dist/DataFrame.js.map +1 -1
- package/dist/bubble/BubbleSettingsImpl.d.ts +3 -0
- package/dist/bubble/BubbleSettingsImpl.d.ts.map +1 -1
- package/dist/bubble/BubbleSettingsImpl.js +16 -16
- package/dist/bubble/BubbleSettingsImpl.js.map +1 -1
- package/dist/bubble/getGroupedCellsData.d.ts +1 -1
- package/dist/bubble/getGroupedCellsData.d.ts.map +1 -1
- package/dist/bubble/getGroupedCellsData.js +12 -11
- package/dist/bubble/getGroupedCellsData.js.map +1 -1
- package/dist/bubble/index.d.ts.map +1 -1
- package/dist/bubble/index.js +61 -69
- package/dist/bubble/index.js.map +1 -1
- package/dist/constants.js +9 -11
- package/dist/constants.js.map +1 -1
- package/dist/discrete/DiscreteSettingsImpl.d.ts +2 -1
- package/dist/discrete/DiscreteSettingsImpl.d.ts.map +1 -1
- package/dist/discrete/DiscreteSettingsImpl.js.map +1 -1
- package/dist/discrete/components/layers/StackedAreaElement.js +33 -33
- package/dist/discrete/components/layers/StackedAreaElement.js.map +1 -1
- package/dist/discrete/index.d.ts.map +1 -1
- package/dist/discrete/index.js +137 -157
- package/dist/discrete/index.js.map +1 -1
- package/dist/heatmap/HeatmapSettingsImpl.d.ts +1 -0
- package/dist/heatmap/HeatmapSettingsImpl.d.ts.map +1 -1
- package/dist/heatmap/HeatmapSettingsImpl.js +29 -28
- package/dist/heatmap/HeatmapSettingsImpl.js.map +1 -1
- package/dist/heatmap/fillCellsData.d.ts +1 -1
- package/dist/heatmap/fillCellsData.d.ts.map +1 -1
- package/dist/heatmap/fillCellsData.js +172 -160
- package/dist/heatmap/fillCellsData.js.map +1 -1
- package/dist/heatmap/getCells.d.ts +1 -1
- package/dist/heatmap/getCells.d.ts.map +1 -1
- package/dist/heatmap/getCells.js +10 -9
- package/dist/heatmap/getCells.js.map +1 -1
- package/dist/heatmap/index.d.ts.map +1 -1
- package/dist/heatmap/index.js +95 -102
- package/dist/heatmap/index.js.map +1 -1
- package/dist/histogram/HistogramSettingsImpl.d.ts +1 -0
- package/dist/histogram/HistogramSettingsImpl.d.ts.map +1 -1
- package/dist/histogram/HistogramSettingsImpl.js +43 -43
- package/dist/histogram/HistogramSettingsImpl.js.map +1 -1
- package/dist/histogram/getHistogramData.d.ts +2 -2
- package/dist/histogram/getHistogramData.d.ts.map +1 -1
- package/dist/histogram/getHistogramData.js +47 -46
- package/dist/histogram/getHistogramData.js.map +1 -1
- package/dist/histogram/index.d.ts +0 -1
- package/dist/histogram/index.d.ts.map +1 -1
- package/dist/histogram/index.js +88 -89
- package/dist/histogram/index.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/scatterplot/ScatterplotSettingsImpl.d.ts +2 -0
- package/dist/scatterplot/ScatterplotSettingsImpl.d.ts.map +1 -1
- package/dist/scatterplot/ScatterplotSettingsImpl.js.map +1 -1
- package/dist/scatterplot/dots.d.ts +2 -2
- package/dist/scatterplot/dots.d.ts.map +1 -1
- package/dist/scatterplot/dots.js +17 -16
- package/dist/scatterplot/dots.js.map +1 -1
- package/dist/scatterplot/index.d.ts +0 -1
- package/dist/scatterplot/index.d.ts.map +1 -1
- package/dist/scatterplot/index.js +92 -101
- package/dist/scatterplot/index.js.map +1 -1
- package/dist/scatterplot/utils/createLegendInfo.d.ts.map +1 -1
- package/dist/scatterplot/utils/createLegendInfo.js +1 -1
- package/dist/scatterplot/utils/createLegendInfo.js.map +1 -1
- package/dist/types/bubble.d.ts +5 -0
- package/dist/types/bubble.d.ts.map +1 -1
- package/dist/types/bubble.js +19 -18
- package/dist/types/bubble.js.map +1 -1
- package/dist/types/dendro.d.ts +5 -0
- package/dist/types/dendro.d.ts.map +1 -1
- package/dist/types/dendro.js +10 -9
- package/dist/types/dendro.js.map +1 -1
- package/dist/types/discrete.d.ts +8 -5
- package/dist/types/discrete.d.ts.map +1 -1
- package/dist/types/discrete.js +12 -11
- package/dist/types/discrete.js.map +1 -1
- package/dist/types/heatmap.d.ts +5 -0
- package/dist/types/heatmap.d.ts.map +1 -1
- package/dist/types/heatmap.js +2 -1
- package/dist/types/heatmap.js.map +1 -1
- package/dist/types/histogram.d.ts +5 -0
- package/dist/types/histogram.d.ts.map +1 -1
- package/dist/types/histogram.js +43 -42
- package/dist/types/histogram.js.map +1 -1
- package/dist/types/scatterplot.d.ts +6 -0
- package/dist/types/scatterplot.d.ts.map +1 -1
- package/dist/types/scatterplot.js +21 -19
- package/dist/types/scatterplot.js.map +1 -1
- package/dist/utils/getFacetKeysFromValueLists.d.ts +6 -0
- package/dist/utils/getFacetKeysFromValueLists.d.ts.map +1 -0
- package/dist/utils/getFacetKeysFromValueLists.js +9 -0
- package/dist/utils/getFacetKeysFromValueLists.js.map +1 -0
- package/dist/utils/getPointShape.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6,34 +6,34 @@ import { bumpX as G, bumpY as B } from "../../../node_modules/.pnpm/d3-shape@3.2
|
|
|
6
6
|
function C(t) {
|
|
7
7
|
return t && typeof t == "object" && "type" in t && t.type === "secondaryGrouping";
|
|
8
8
|
}
|
|
9
|
-
function P(t, n, e, r,
|
|
9
|
+
function P(t, n, e, r, h) {
|
|
10
10
|
if (e && typeof e == "object" && "type" in e) {
|
|
11
11
|
if (e.type === "primaryGrouping")
|
|
12
12
|
return t.xPrimaryAes(r)[n];
|
|
13
13
|
if (e.type === "secondaryGrouping")
|
|
14
|
-
return t.xSecondaryAes(
|
|
14
|
+
return t.xSecondaryAes(h)[n];
|
|
15
15
|
}
|
|
16
16
|
return e;
|
|
17
17
|
}
|
|
18
|
-
function W(t, n, e, r,
|
|
19
|
-
const y = (e - n) / 2, a =
|
|
20
|
-
const
|
|
18
|
+
function W(t, n, e, r, h, d, j) {
|
|
19
|
+
const y = (e - n) / 2, a = j.reduce((p, i) => {
|
|
20
|
+
const c = {};
|
|
21
21
|
let o = 0;
|
|
22
|
-
return
|
|
23
|
-
var
|
|
24
|
-
const
|
|
25
|
-
|
|
22
|
+
return h.forEach((m) => {
|
|
23
|
+
var s;
|
|
24
|
+
const u = ((s = i.valuesMap[m]) == null ? void 0 : s.height) ?? 0;
|
|
25
|
+
c[m] = {
|
|
26
26
|
y1: o,
|
|
27
|
-
y2: o +
|
|
28
|
-
}, o +=
|
|
29
|
-
}),
|
|
27
|
+
y2: o + u
|
|
28
|
+
}, o += u;
|
|
29
|
+
}), p[i.primaryGrouping] = c, p;
|
|
30
30
|
}, {});
|
|
31
|
-
return
|
|
31
|
+
return h.map((p) => {
|
|
32
32
|
const i = r.flatMap((o) => {
|
|
33
|
-
const
|
|
34
|
-
return d ? [
|
|
35
|
-
}),
|
|
36
|
-
return { secondaryKey:
|
|
33
|
+
const m = a[o], u = t.xPrimary(o) ?? 0, s = t.y(m[p].y1), l = t.y(m[p].y2), x = [u + y, s, l], A = [u + e - y, s, l];
|
|
34
|
+
return d ? [x, A] : [A, x];
|
|
35
|
+
}), c = (d ? S().curve(G).x((o) => o[0]).y0((o) => o[1]).y1((o) => o[2])(i) : S().curve(B).y((o) => o[0]).x0((o) => o[1]).x1((o) => o[2])(i)) ?? "";
|
|
36
|
+
return { secondaryKey: p, pathD: c };
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
function k(t, n) {
|
|
@@ -44,31 +44,31 @@ function X({
|
|
|
44
44
|
scales: n,
|
|
45
45
|
orientation: e,
|
|
46
46
|
layerData: r,
|
|
47
|
-
sideDistances:
|
|
47
|
+
sideDistances: h,
|
|
48
48
|
showTooltips: d,
|
|
49
|
-
secondaryGrouping:
|
|
49
|
+
secondaryGrouping: j,
|
|
50
50
|
activeElementContainer: y,
|
|
51
51
|
tooltipsContainer: a,
|
|
52
|
-
tooltipsData:
|
|
52
|
+
tooltipsData: p
|
|
53
53
|
}) {
|
|
54
|
-
const [i,
|
|
54
|
+
const [i, c] = E.useState(null), o = e === "vertical", m = n.xPrimary.bandwidth(), u = k(r, m), s = n.xPrimary.domain(), l = n.xSecondary.domain().reverse(), x = s.length > 1 && (C(r.aes.fillColor) || typeof r.aes.fillColor == "string"), A = x ? W(
|
|
55
55
|
n,
|
|
56
|
-
m,
|
|
57
|
-
c,
|
|
58
56
|
u,
|
|
59
|
-
|
|
57
|
+
m,
|
|
58
|
+
s,
|
|
59
|
+
l,
|
|
60
60
|
o,
|
|
61
61
|
r.geoms[t]
|
|
62
62
|
) : [];
|
|
63
63
|
return /* @__PURE__ */ g.jsxs("g", { children: [
|
|
64
|
-
/* @__PURE__ */ g.jsx("g", { children:
|
|
64
|
+
/* @__PURE__ */ g.jsx("g", { children: x && A.map(({ secondaryKey: f, pathD: b }) => /* @__PURE__ */ g.jsx(
|
|
65
65
|
"path",
|
|
66
66
|
{
|
|
67
67
|
d: b,
|
|
68
|
-
fill: P(n, "fillColor", r.aes.fillColor,
|
|
68
|
+
fill: P(n, "fillColor", r.aes.fillColor, s[0], f),
|
|
69
69
|
opacity: r.aes.areaOpacity * (i !== null && f !== i ? 0.5 : 1),
|
|
70
|
-
onMouseEnter: () =>
|
|
71
|
-
onMouseLeave: () =>
|
|
70
|
+
onMouseEnter: () => c(f),
|
|
71
|
+
onMouseLeave: () => c(null)
|
|
72
72
|
},
|
|
73
73
|
f
|
|
74
74
|
)) }),
|
|
@@ -82,18 +82,18 @@ function X({
|
|
|
82
82
|
orientation: e,
|
|
83
83
|
aes: {
|
|
84
84
|
...r.aes,
|
|
85
|
-
width:
|
|
85
|
+
width: u,
|
|
86
86
|
opacity: r.aes.barsOpacity
|
|
87
87
|
},
|
|
88
88
|
normalize: r.meta.normalize,
|
|
89
|
-
sideDistances:
|
|
89
|
+
sideDistances: h,
|
|
90
90
|
showTooltips: d,
|
|
91
|
-
secondaryGrouping:
|
|
92
|
-
tooltipsData:
|
|
91
|
+
secondaryGrouping: j,
|
|
92
|
+
tooltipsData: p,
|
|
93
93
|
activeElementContainer: y,
|
|
94
94
|
tooltipsContainer: a,
|
|
95
95
|
activeKey: i,
|
|
96
|
-
onSectionHover:
|
|
96
|
+
onSectionHover: c
|
|
97
97
|
},
|
|
98
98
|
f.key
|
|
99
99
|
)) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackedAreaElement.js","sources":["../../../../src/discrete/components/layers/StackedAreaElement.tsx"],"sourcesContent":["import {area, curveBumpX, curveBumpY} from 'd3-shape';\nimport React, { useState } from 'react';\nimport type {TooltipsData} from '../../../common/Tooltip';\nimport type {AesItem, GroupingData, InheritAesDiscrete, Orientation} from '../../../types';\nimport type {StackedBar} from '../../layers';\nimport type {StackedAreaData} from '../../layers/types';\nimport type {ChartScales} from '../types';\nimport {StackedBarElement} from './StackedBarElement';\n\ninterface StackedAreaProps {\n facetKey: string;\n scales: ChartScales;\n layerData: StackedAreaData;\n orientation: Orientation;\n sideDistances: {\n left: number;\n right: number;\n top: number;\n bottom: number;\n };\n showTooltips: boolean;\n secondaryGrouping: GroupingData;\n tooltipsData: TooltipsData<unknown>;\n activeElementContainer?: Element;\n tooltipsContainer?: Element;\n}\n\nfunction isSecondaryGroupedAes (value: string | InheritAesDiscrete) {\n return value && typeof value === 'object' && 'type' in value && value.type === 'secondaryGrouping';\n}\n\nfunction getAesValue<ValueType>(\n scales: ChartScales,\n field: keyof AesItem,\n value: ValueType | InheritAesDiscrete,\n primaryGrouping: string,\n secondaryGrouping: string\n): ValueType {\n if (value && typeof value === 'object' && 'type' in value) {\n if (value.type === 'primaryGrouping') {\n return scales.xPrimaryAes(primaryGrouping)[field] as ValueType;\n }\n if (value.type === 'secondaryGrouping') {\n return scales.xSecondaryAes(secondaryGrouping)[field] as ValueType;\n }\n }\n return value as ValueType;\n}\n\nfunction getAreas(\n scales: ChartScales,\n barWidth: number,\n bandWidth: number,\n primaryKeys: string[],\n secondaryKeys: string[],\n isVertical: boolean,\n bars: StackedBar[],\n) {\n const offsetX = (bandWidth - barWidth) / 2;\n const ys = bars.reduce((res, bar) => {\n const yValues: Record<string, {y1: number, y2: number}> = {};\n let currentHeight = 0;\n secondaryKeys.forEach(secondaryKey => {\n const height = bar.valuesMap[secondaryKey]?.height ?? 0;\n yValues[secondaryKey] = {\n y1: currentHeight,\n y2: currentHeight + height,\n };\n currentHeight += height;\n });\n res[bar.primaryGrouping] = yValues;\n return res;\n }, {} as Record<string, Record<string, {y1: number, y2: number}>>);\n\n return secondaryKeys.map((secondaryKey) => {\n const points:[number, number, number][] = primaryKeys.flatMap((primaryKey) => {\n const yMap = ys[primaryKey];\n const x = scales.xPrimary(primaryKey) ?? 0;\n const y1 = scales.y(yMap[secondaryKey].y1);\n const y2 = scales.y(yMap[secondaryKey].y2);\n const p1:[number, number, number] = [x + offsetX, y1, y2];\n const p2:[number, number, number] = [x + bandWidth - offsetX, y1, y2];\n return isVertical ? [p1, p2] : [p2, p1];\n });\n\n const pathD = (isVertical ? (\n area<[number, number, number]>()\n .curve(curveBumpX)\n .x(d => d[0])\n .y0(d => d[1])\n .y1(d => d[2])(points)\n ) :\n area<[number, number, number]>()\n .curve(curveBumpY)\n .y(d => d[0])\n .x0(d => d[1])\n .x1(d => d[2])(points)) ?? '';\n return {secondaryKey, pathD};\n });\n}\n\nfunction calculateBarWidth (\n layerData: StackedAreaData,\n bandwidth: number\n) {\n if (!layerData.meta.showBars) {\n return 0;\n }\n return layerData.aes.barWidth === 'auto' ? bandwidth * 0.2 : Math.min(bandwidth, layerData.aes.barWidth);\n}\n\nexport function StackedAreaElement({\n facetKey,\n scales,\n orientation,\n layerData,\n sideDistances,\n showTooltips,\n secondaryGrouping,\n activeElementContainer,\n tooltipsContainer,\n tooltipsData,\n}: StackedAreaProps) {\n const [selectedAreaKey, setSelectedAreaKey] = useState<string | null>(null);\n const isVertical = orientation === 'vertical';\n const boxOuterWidth = scales.xPrimary.bandwidth();\n const boxWidth = calculateBarWidth(layerData, boxOuterWidth);\n const primaryKeys = scales.xPrimary.domain();\n const secondaryKeys = scales.xSecondary.domain().reverse();\n\n const needsAreas = isSecondaryGroupedAes(layerData.aes.fillColor) || typeof layerData.aes.fillColor === 'string';\n const areas = needsAreas ? getAreas(\n scales,\n boxWidth,\n boxOuterWidth,\n primaryKeys,\n secondaryKeys,\n isVertical,\n layerData.geoms[facetKey]\n ) : [];\n\n return (\n <g>\n <g>\n {needsAreas && areas.map(({secondaryKey, pathD}) => (\n <path\n key={secondaryKey}\n d={pathD}\n fill={getAesValue(scales, 'fillColor', layerData.aes.fillColor, primaryKeys[0], secondaryKey)}\n opacity={layerData.aes.areaOpacity * (selectedAreaKey !== null && secondaryKey !== selectedAreaKey ? 0.5 : 1)}\n onMouseEnter={() => setSelectedAreaKey(secondaryKey)}\n onMouseLeave={() => setSelectedAreaKey(null)}\n />\n ))}\n </g>\n <g>\n {layerData.meta.showBars && (layerData as StackedAreaData).geoms[facetKey].map(geom => (\n <StackedBarElement\n key={geom.key}\n facetKey={facetKey}\n geom={geom}\n elementsAmount={layerData.geoms[facetKey].length}\n scales={scales}\n orientation={orientation}\n aes={{\n ...layerData.aes,\n width: boxWidth,\n opacity: layerData.aes.barsOpacity\n }}\n normalize={layerData.meta.normalize}\n sideDistances={sideDistances}\n showTooltips={showTooltips}\n secondaryGrouping={secondaryGrouping}\n tooltipsData={tooltipsData}\n activeElementContainer={activeElementContainer}\n tooltipsContainer={tooltipsContainer}\n activeKey={selectedAreaKey}\n onSectionHover={setSelectedAreaKey}\n />\n ))}\n </g>\n </g>\n );\n}\n"],"names":["isSecondaryGroupedAes","value","getAesValue","scales","field","primaryGrouping","secondaryGrouping","getAreas","barWidth","bandWidth","primaryKeys","secondaryKeys","isVertical","bars","offsetX","ys","res","bar","yValues","currentHeight","secondaryKey","height","_a","points","primaryKey","yMap","x","y1","y2","p1","p2","pathD","area","curveBumpX","d","curveBumpY","calculateBarWidth","layerData","bandwidth","StackedAreaElement","facetKey","orientation","sideDistances","showTooltips","activeElementContainer","tooltipsContainer","tooltipsData","selectedAreaKey","setSelectedAreaKey","useState","boxOuterWidth","boxWidth","needsAreas","areas","jsx","geom","StackedBarElement"],"mappings":";;;;;AA2BA,SAASA,EAAuBC,GAAoC;AAChE,SAAOA,KAAS,OAAOA,KAAU,YAAY,UAAUA,KAASA,EAAM,SAAS;AACnF;AAEA,SAASC,EACLC,GACAC,GACAH,GACAI,GACAC,GACS;AACT,MAAIL,KAAS,OAAOA,KAAU,YAAY,UAAUA,GAAO;AACvD,QAAIA,EAAM,SAAS;AACf,aAAOE,EAAO,YAAYE,CAAe,EAAED,CAAK;AAEpD,QAAIH,EAAM,SAAS;AACf,aAAOE,EAAO,cAAcG,CAAiB,EAAEF,CAAK;AAAA,EAE5D;AACA,SAAOH;AACX;AAEA,SAASM,EACLJ,GACAK,GACAC,GACAC,GACAC,GACAC,GACAC,GACF;AACE,QAAMC,KAAWL,IAAYD,KAAY,GACnCO,IAAKF,EAAK,OAAO,CAACG,GAAKC,MAAQ;AACjC,UAAMC,IAAoD,CAAA;AAC1D,QAAIC,IAAgB;AACpB,WAAAR,EAAc,QAAQ,CAAAS,MAAgB;;AAClC,YAAMC,MAASC,IAAAL,EAAI,UAAUG,CAAY,MAA1B,gBAAAE,EAA6B,WAAU;AACtD,MAAAJ,EAAQE,CAAY,IAAI;AAAA,QACpB,IAAID;AAAA,QACJ,IAAIA,IAAgBE;AAAA,MAAA,GAExBF,KAAiBE;AAAA,IACrB,CAAC,GACDL,EAAIC,EAAI,eAAe,IAAIC,GACpBF;AAAA,EACX,GAAG,CAAA,CAA8D;AAEjE,SAAOL,EAAc,IAAI,CAACS,MAAiB;AACvC,UAAMG,IAAoCb,EAAY,QAAQ,CAACc,MAAe;AAC1E,YAAMC,IAAOV,EAAGS,CAAU,GACpBE,IAAIvB,EAAO,SAASqB,CAAU,KAAK,GACnCG,IAAKxB,EAAO,EAAEsB,E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K;AAAA,QAC1B,eAAAK;AAAA,QACA,cAAAC;AAAA,QACA,mBAAArC;AAAA,QACA,cAAAwC;AAAA,QACA,wBAAAF;AAAA,QACA,mBAAAC;AAAA,QACA,WAAWE;AAAA,QACX,gBAAgBC;AAAA,MAAA;AAAA,MAnBXO,EAAK;AAAA,IAAA,CAqBjB,EAAA,CACD;AAAA,EAAA,GACJ;AAER;"}
|
|
1
|
+
{"version":3,"file":"StackedAreaElement.js","sources":["../../../../src/discrete/components/layers/StackedAreaElement.tsx"],"sourcesContent":["import {area, curveBumpX, curveBumpY} from 'd3-shape';\nimport React, { useState } from 'react';\nimport type {TooltipsData} from '../../../common/Tooltip';\nimport type {AesItem, GroupingData, InheritAesDiscrete, Orientation} from '../../../types';\nimport type {StackedBar} from '../../layers';\nimport type {StackedAreaData} from '../../layers/types';\nimport type {ChartScales} from '../types';\nimport {StackedBarElement} from './StackedBarElement';\n\ninterface StackedAreaProps {\n facetKey: string;\n scales: ChartScales;\n layerData: StackedAreaData;\n orientation: Orientation;\n sideDistances: {\n left: number;\n right: number;\n top: number;\n bottom: number;\n };\n showTooltips: boolean;\n secondaryGrouping: GroupingData;\n tooltipsData: TooltipsData<unknown>;\n activeElementContainer?: Element;\n tooltipsContainer?: Element;\n}\n\nfunction isSecondaryGroupedAes (value: string | InheritAesDiscrete) {\n return value && typeof value === 'object' && 'type' in value && value.type === 'secondaryGrouping';\n}\n\nfunction getAesValue<ValueType>(\n scales: ChartScales,\n field: keyof AesItem,\n value: ValueType | InheritAesDiscrete,\n primaryGrouping: string,\n secondaryGrouping: string\n): ValueType {\n if (value && typeof value === 'object' && 'type' in value) {\n if (value.type === 'primaryGrouping') {\n return scales.xPrimaryAes(primaryGrouping)[field] as ValueType;\n }\n if (value.type === 'secondaryGrouping') {\n return scales.xSecondaryAes(secondaryGrouping)[field] as ValueType;\n }\n }\n return value as ValueType;\n}\n\nfunction getAreas(\n scales: ChartScales,\n barWidth: number,\n bandWidth: number,\n primaryKeys: string[],\n secondaryKeys: string[],\n isVertical: boolean,\n bars: StackedBar[],\n) {\n const offsetX = (bandWidth - barWidth) / 2;\n const ys = bars.reduce((res, bar) => {\n const yValues: Record<string, {y1: number, y2: number}> = {};\n let currentHeight = 0;\n secondaryKeys.forEach(secondaryKey => {\n const height = bar.valuesMap[secondaryKey]?.height ?? 0;\n yValues[secondaryKey] = {\n y1: currentHeight,\n y2: currentHeight + height,\n };\n currentHeight += height;\n });\n res[bar.primaryGrouping] = yValues;\n return res;\n }, {} as Record<string, Record<string, {y1: number, y2: number}>>);\n\n return secondaryKeys.map((secondaryKey) => {\n const points:[number, number, number][] = primaryKeys.flatMap((primaryKey) => {\n const yMap = ys[primaryKey];\n const x = scales.xPrimary(primaryKey) ?? 0;\n const y1 = scales.y(yMap[secondaryKey].y1);\n const y2 = scales.y(yMap[secondaryKey].y2);\n const p1:[number, number, number] = [x + offsetX, y1, y2];\n const p2:[number, number, number] = [x + bandWidth - offsetX, y1, y2];\n return isVertical ? [p1, p2] : [p2, p1];\n });\n\n const pathD = (isVertical ? (\n area<[number, number, number]>()\n .curve(curveBumpX)\n .x(d => d[0])\n .y0(d => d[1])\n .y1(d => d[2])(points)\n ) :\n area<[number, number, number]>()\n .curve(curveBumpY)\n .y(d => d[0])\n .x0(d => d[1])\n .x1(d => d[2])(points)) ?? '';\n return {secondaryKey, pathD};\n });\n}\n\nfunction calculateBarWidth (\n layerData: StackedAreaData,\n bandwidth: number\n) {\n if (!layerData.meta.showBars) {\n return 0;\n }\n return layerData.aes.barWidth === 'auto' ? bandwidth * 0.2 : Math.min(bandwidth, layerData.aes.barWidth);\n}\n\nexport function StackedAreaElement({\n facetKey,\n scales,\n orientation,\n layerData,\n sideDistances,\n showTooltips,\n secondaryGrouping,\n activeElementContainer,\n tooltipsContainer,\n tooltipsData,\n}: StackedAreaProps) {\n const [selectedAreaKey, setSelectedAreaKey] = useState<string | null>(null);\n const isVertical = orientation === 'vertical';\n const boxOuterWidth = scales.xPrimary.bandwidth();\n const boxWidth = calculateBarWidth(layerData, boxOuterWidth);\n const primaryKeys = scales.xPrimary.domain();\n const secondaryKeys = scales.xSecondary.domain().reverse();\n\n const needsAreas = primaryKeys.length > 1 && (isSecondaryGroupedAes(layerData.aes.fillColor) || typeof layerData.aes.fillColor === 'string');\n const areas = needsAreas ? getAreas(\n scales,\n boxWidth,\n boxOuterWidth,\n primaryKeys,\n secondaryKeys,\n isVertical,\n layerData.geoms[facetKey]\n ) : [];\n\n return (\n <g>\n <g>\n {needsAreas && areas.map(({secondaryKey, pathD}) => (\n <path\n key={secondaryKey}\n d={pathD}\n fill={getAesValue(scales, 'fillColor', layerData.aes.fillColor, primaryKeys[0], secondaryKey)}\n opacity={layerData.aes.areaOpacity * (selectedAreaKey !== null && secondaryKey !== selectedAreaKey ? 0.5 : 1)}\n onMouseEnter={() => setSelectedAreaKey(secondaryKey)}\n onMouseLeave={() => setSelectedAreaKey(null)}\n />\n ))}\n </g>\n <g>\n {layerData.meta.showBars && (layerData as StackedAreaData).geoms[facetKey].map(geom => (\n <StackedBarElement\n key={geom.key}\n facetKey={facetKey}\n geom={geom}\n elementsAmount={layerData.geoms[facetKey].length}\n scales={scales}\n orientation={orientation}\n aes={{\n ...layerData.aes,\n width: boxWidth,\n opacity: layerData.aes.barsOpacity\n }}\n normalize={layerData.meta.normalize}\n sideDistances={sideDistances}\n showTooltips={showTooltips}\n secondaryGrouping={secondaryGrouping}\n tooltipsData={tooltipsData}\n activeElementContainer={activeElementContainer}\n tooltipsContainer={tooltipsContainer}\n activeKey={selectedAreaKey}\n onSectionHover={setSelectedAreaKey}\n />\n ))}\n </g>\n </g>\n );\n}\n"],"names":["isSecondaryGroupedAes","value","getAesValue","scales","field","primaryGrouping","secondaryGrouping","getAreas","barWidth","bandWidth","primaryKeys","secondaryKeys","isVertical","bars","offsetX","ys","res","bar","yValues","currentHeight","secondaryKey","height","_a","points","primaryKey","yMap","x","y1","y2","p1","p2","pathD","area","curveBumpX","d","curveBumpY","calculateBarWidth","layerData","bandwidth","StackedAreaElement","facetKey","orientation","sideDistances","showTooltips","activeElementContainer","tooltipsContainer","tooltipsData","selectedAreaKey","setSelectedAreaKey","useState","boxOuterWidth","boxWidth","needsAreas","areas","jsx","geom","StackedBarElement"],"mappings":";;;;;AA2BA,SAASA,EAAuBC,GAAoC;AAChE,SAAOA,KAAS,OAAOA,KAAU,YAAY,UAAUA,KAASA,EAAM,SAAS;AACnF;AAEA,SAASC,EACLC,GACAC,GACAH,GACAI,GACAC,GACS;AACT,MAAIL,KAAS,OAAOA,KAAU,YAAY,UAAUA,GAAO;AACvD,QAAIA,EAAM,SAAS;AACf,aAAOE,EAAO,YAAYE,CAAe,EAAED,CAAK;AAEpD,QAAIH,EAAM,SAAS;AACf,aAAOE,EAAO,cAAcG,CAAiB,EAAEF,CAAK;AAAA,EAE5D;AACA,SAAOH;AACX;AAEA,SAASM,EACLJ,GACAK,GACAC,GACAC,GACAC,GACAC,GACAC,GACF;AACE,QAAMC,KAAWL,IAAYD,KAAY,GACnCO,IAAKF,EAAK,OAAO,CAACG,GAAKC,MAAQ;AACjC,UAAMC,IAAoD,CAAA;AAC1D,QAAIC,IAAgB;AACpB,WAAAR,EAAc,QAAQ,CAAAS,MAAgB;;AAClC,YAAMC,MAASC,IAAAL,EAAI,UAAUG,CAAY,MAA1B,gBAAAE,EAA6B,WAAU;AACtD,MAAAJ,EAAQE,CAAY,IAAI;AAAA,QACpB,IAAID;AAAA,QACJ,IAAIA,IAAgBE;AAAA,MAAA,GAExBF,KAAiBE;AAAA,IACrB,CAAC,GACDL,EAAIC,EAAI,eAAe,IAAIC,GACpBF;AAAA,EACX,GAAG,CAAA,CAA8D;AAEjE,SAAOL,EAAc,IAAI,CAACS,MAAiB;AACvC,UAAMG,IAAoCb,EAAY,QAAQ,CAACc,MAAe;AAC1E,YAAMC,IAAOV,EAAGS,CAAU,GACpBE,IAAIvB,EAAO,SAASqB,CAAU,KAAK,GACnCG,IAAKxB,EAAO,EAAEsB,EAAK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,WAAWA,EAAU,KAAK;AAAA,QAC1B,eAAAK;AAAA,QACA,cAAAC;AAAA,QACA,mBAAArC;AAAA,QACA,cAAAwC;AAAA,QACA,wBAAAF;AAAA,QACA,mBAAAC;AAAA,QACA,WAAWE;AAAA,QACX,gBAAgBC;AAAA,MAAA;AAAA,MAnBXO,EAAK;AAAA,IAAA,CAqBjB,EAAA,CACD;AAAA,EAAA,GACJ;AAER;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discrete/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAC6C,KAAK,qBAAqB,EAC1E,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discrete/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAC6C,KAAK,qBAAqB,EAC1E,KAAK,gBAAgB,EAAuB,KAAK,YAAY,EAChE,MAAM,UAAU,CAAC;AAClB,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAIH,oBAAoB,EAUvB,MAAM,wBAAwB,CAAC;AAgBhC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA0F3D,qBAAa,aAAc,SAAQ,aAAa;IAC5C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,aAAa,gBAAuB;IAEpC,mBAAmB,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAmB;IAC5D,cAAc,EAAE;QACZ,UAAU,EAAE,SAAS,EAAE,CAAC;QACxB,eAAe,EAAE,SAAS,EAAE,CAAC;QAC7B,eAAe,EAAE,YAAY,CAAC;QAC9B,iBAAiB,EAAE,YAAY,CAAC;QAChC,aAAa,EAAE,QAAQ,EAAE,EAAE,CAAC;QAC5B,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACjD,YAAY,EAAE,OAAO,CAAC;QACtB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;KACzC,GAAG,IAAI,CAAQ;gBAEJ,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,CAAC,EAAE,qBAAqB;IAS9F,KAAK,CAAC,IAAI,EAAE,WAAW;IAiBvB,OAAO;IAIP,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB;IA2BjE,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAIhD,MAAM,IAAI,MAAM;IAKhB,mCAAmC,CAAC,YAAY,EAAE,oBAAoB,EAAE,QAAQ,EAAE,oBAAoB;IAYtG,+BAA+B,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS;IAUpE,WAAW;IAiHX,gBAAgB;IAoBhB,YAAY;CAwBf"}
|
package/dist/discrete/index.js
CHANGED
|
@@ -1,237 +1,217 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var y = (
|
|
4
|
-
import { l as
|
|
5
|
-
import { s as
|
|
6
|
-
import { AbstractChart as
|
|
7
|
-
import { NO_GROUPED as
|
|
8
|
-
import { getUnknownErrorInfo as
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var O = (s, r, a) => r in s ? P(s, r, { enumerable: !0, configurable: !0, writable: !0, value: a }) : s[r] = a;
|
|
3
|
+
var y = (s, r, a) => O(s, typeof r != "symbol" ? r + "" : r, a);
|
|
4
|
+
import { l as G } from "../_virtual/lodash.js";
|
|
5
|
+
import { s as U } from "../_virtual/server.browser.js";
|
|
6
|
+
import { AbstractChart as F } from "../AbstractChart.js";
|
|
7
|
+
import { NO_GROUPED as _ } from "../DataFrame.js";
|
|
8
|
+
import { getUnknownErrorInfo as w, isErrorInfo as v } from "../types/common.js";
|
|
9
9
|
import "../types/discrete.js";
|
|
10
10
|
import "../types/scatterplot.js";
|
|
11
11
|
import "../types/heatmap.js";
|
|
12
12
|
import "../types/dendro.js";
|
|
13
13
|
import "../types/histogram.js";
|
|
14
14
|
import "../types/bubble.js";
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return x.intersection(e ?? n, n).map(String);
|
|
15
|
+
import T from "./ChartRenderer.js";
|
|
16
|
+
import { DiscreteSettingsImpl as B, StatLayer as C, BoxLayer as j, ViolinLayer as H, DotLayer as q, LineLayer as z, ErrorBarLayer as J, BarLayer as M, StackedBarLayer as Q, StackedAreaLayer as W, BinnedDotsLayer as X, PairedPointsLayer as Y, SinaLayer as Z, LogoPlotLayer as $ } from "./DiscreteSettingsImpl.js";
|
|
17
|
+
import { getBoxesData as tt } from "./layers/boxes.js";
|
|
18
|
+
import { getViolinsData as et } from "./layers/violins.js";
|
|
19
|
+
import { getSinaData as at } from "./layers/sina.js";
|
|
20
|
+
import { getDotsData as rt } from "./layers/dots.js";
|
|
21
|
+
import { getLinesData as nt } from "./layers/lines.js";
|
|
22
|
+
import { getErrorBarsData as st } from "./layers/errorbars.js";
|
|
23
|
+
import { getBarsData as ot } from "./layers/bar.js";
|
|
24
|
+
import { getStackedBarsData as it } from "./layers/stackedBar.js";
|
|
25
|
+
import { getStackedAreaData as lt } from "./layers/stackedArea.js";
|
|
26
|
+
import { getBinnedDotsData as ct } from "./layers/binnedDots.js";
|
|
27
|
+
import { getPairedPointsData as ut } from "./layers/pairedPoints.js";
|
|
28
|
+
import { getLogoData as ht } from "./layers/logo.js";
|
|
29
|
+
import { getStatsData as dt } from "./layers/stats/index.js";
|
|
30
|
+
import { getFacetStringKey as D } from "./utils/getFacetStringKey.js";
|
|
31
|
+
import { arraysAreDifferent as k } from "../utils/arraysAreDifferent.js";
|
|
32
|
+
import { getFacetLabels as mt } from "./utils/getFacetLabels.js";
|
|
33
|
+
function ft(s, r, a = null) {
|
|
34
|
+
const t = r.value, n = s.getColumnCategories(t);
|
|
35
|
+
return G.intersection(a ?? n, n).map(String);
|
|
37
36
|
}
|
|
38
|
-
function
|
|
39
|
-
if (!
|
|
37
|
+
function pt(s) {
|
|
38
|
+
if (!s.length)
|
|
40
39
|
return [];
|
|
41
40
|
let r = [[]];
|
|
42
|
-
return
|
|
41
|
+
return s.forEach((a) => {
|
|
43
42
|
const t = [];
|
|
44
|
-
|
|
45
|
-
t.push(...r.map((
|
|
43
|
+
a.forEach((n) => {
|
|
44
|
+
t.push(...r.map((o) => [...o, n]));
|
|
46
45
|
}), r = t;
|
|
47
46
|
}), r;
|
|
48
47
|
}
|
|
49
|
-
function
|
|
50
|
-
return !
|
|
48
|
+
function K(s, r) {
|
|
49
|
+
return !s && r || s && !r ? !0 : !s || !r ? !1 : s.columnName.value !== r.columnName.value || s.columnName.nullValueLabel !== r.columnName.nullValueLabel || k(s.order, r.order, { ignoreOrder: !0 }) || s.allowNullGroup !== r.allowNullGroup;
|
|
51
50
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
51
|
+
function L(s, r) {
|
|
52
|
+
const a = (r == null ? void 0 : r.columnName.nullValueLabel) ?? "NA";
|
|
54
53
|
if (!r)
|
|
55
54
|
return {
|
|
55
|
+
groupingKeys: [_],
|
|
56
56
|
keys: ["null"],
|
|
57
57
|
value: null,
|
|
58
58
|
label: "",
|
|
59
|
-
valueLabels: { null:
|
|
59
|
+
valueLabels: { null: "" },
|
|
60
60
|
inheritedAes: null
|
|
61
61
|
};
|
|
62
|
-
const t = r.columnName.value, n = r.columnName.valueLabels,
|
|
63
|
-
const
|
|
64
|
-
|
|
62
|
+
const t = r.columnName.value, n = r.columnName.valueLabels, o = s.getColumnCategories(t, !1), i = (m) => {
|
|
63
|
+
const h = n ? String(
|
|
64
|
+
s.getColumnValue(
|
|
65
65
|
n,
|
|
66
|
-
|
|
66
|
+
s.getColumnCategoryRowIndex(t, m)
|
|
67
67
|
)
|
|
68
|
-
) :
|
|
69
|
-
return
|
|
70
|
-
},
|
|
68
|
+
) : m;
|
|
69
|
+
return h === "null" ? a : h;
|
|
70
|
+
}, l = s.getColumnCategories(t, !r.allowNullGroup), u = r.order === void 0 ? l : G.intersection(r.order.map(String), l);
|
|
71
71
|
return {
|
|
72
|
-
keys:
|
|
72
|
+
keys: u,
|
|
73
|
+
groupingKeys: u,
|
|
73
74
|
value: t,
|
|
74
75
|
label: r.columnName.label ?? t,
|
|
75
|
-
valueLabels:
|
|
76
|
+
valueLabels: o.reduce((m, h) => (m[h] = i(h), m), {}),
|
|
76
77
|
inheritedAes: r.inheritedAes ?? null
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
|
-
class Jt extends
|
|
80
|
-
constructor(
|
|
81
|
-
super(
|
|
80
|
+
class Jt extends F {
|
|
81
|
+
constructor(a, t, n) {
|
|
82
|
+
super(a, t);
|
|
82
83
|
y(this, "settings");
|
|
83
|
-
y(this, "chartRenderer", new
|
|
84
|
+
y(this, "chartRenderer", new T());
|
|
84
85
|
y(this, "onTooltipHintSwitch", () => {
|
|
85
86
|
});
|
|
86
87
|
y(this, "calculatedData", null);
|
|
87
88
|
this.settings = new B(t), n && (this.onTooltipHintSwitch = n[0]);
|
|
88
89
|
}
|
|
89
|
-
mount(
|
|
90
|
+
mount(a) {
|
|
90
91
|
try {
|
|
91
|
-
this.chartRenderer.init(
|
|
92
|
+
this.chartRenderer.init(a), this._updateData(), this._updateChart(), this.hasError = !1, this.errorInfo = null;
|
|
92
93
|
} catch (t) {
|
|
93
|
-
this.hasError = !0, t instanceof Error && (this.errorInfo =
|
|
94
|
+
this.hasError = !0, t instanceof Error && (this.errorInfo = v(t.cause) ? t.cause : w(t), this.chartRenderer.renderError(t.message), console.error(t));
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
unmount() {
|
|
97
98
|
this.chartRenderer.clear();
|
|
98
99
|
}
|
|
99
|
-
updateSettingsAndData(
|
|
100
|
+
updateSettingsAndData(a, t) {
|
|
100
101
|
try {
|
|
101
|
-
const n = this.settings,
|
|
102
|
-
this.settings = new B(t), this.data =
|
|
102
|
+
const n = this.settings, o = this.data;
|
|
103
|
+
this.settings = new B(t), this.data = a, this._needUpdateCalculatedDataBySettings(n, this.settings) || this._needUpdateCalculatedDataByData(o, this.data) ? this._updateData() : this._updateAesInData(), this._updateChart(), this.hasError = !1, this.errorInfo = null;
|
|
103
104
|
} catch (n) {
|
|
104
|
-
this.hasError = !0, n instanceof Error && (this.errorInfo =
|
|
105
|
+
this.hasError = !0, n instanceof Error && (this.errorInfo = v(n.cause) ? n.cause : w(n), this.chartRenderer.renderError(n.message), console.error(n));
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
updateChartState(
|
|
108
|
+
updateChartState(a, t) {
|
|
108
109
|
console.warn("no chart state for discrete");
|
|
109
110
|
}
|
|
110
111
|
export() {
|
|
111
|
-
return this._updateChart(),
|
|
112
|
+
return this._updateChart(), U.renderToString(this.chartRenderer.component);
|
|
112
113
|
}
|
|
113
|
-
_needUpdateCalculatedDataBySettings(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return n.value !== ((l = t.facetBy[i]) == null ? void 0 : l.value);
|
|
117
|
-
}) || e.layers.length !== t.layers.length || e.layers.some((n, i) => !n.isEqualForCalculation(t.layers[i]));
|
|
118
|
-
}
|
|
119
|
-
_needUpdateCalculatedDataByData(e, t) {
|
|
120
|
-
const n = Object.keys(e.data), i = Object.keys(t.data);
|
|
121
|
-
return e.id !== t.id || n.length !== i.length || n.some((l) => {
|
|
114
|
+
_needUpdateCalculatedDataBySettings(a, t) {
|
|
115
|
+
var n, o;
|
|
116
|
+
return a.chartSettings.yAxis.scale !== t.chartSettings.yAxis.scale || K(a.primaryGrouping, t.primaryGrouping) || K(a.secondaryGrouping, t.secondaryGrouping) || a.facetBy.some((i, l) => {
|
|
122
117
|
var u;
|
|
123
|
-
return
|
|
118
|
+
return i.value !== ((u = t.facetBy[l]) == null ? void 0 : u.value);
|
|
119
|
+
}) || k(((n = a.facetSettings) == null ? void 0 : n.order) ?? [], ((o = t.facetSettings) == null ? void 0 : o.order) ?? []) || a.layers.length !== t.layers.length || a.layers.some((i, l) => !i.isEqualForCalculation(t.layers[l]));
|
|
120
|
+
}
|
|
121
|
+
_needUpdateCalculatedDataByData(a, t) {
|
|
122
|
+
const n = Object.keys(a.data), o = Object.keys(t.data);
|
|
123
|
+
return a.id !== t.id || n.length !== o.length || n.some((i) => {
|
|
124
|
+
var l;
|
|
125
|
+
return a.data[i].length !== ((l = t.data[i]) == null ? void 0 : l.length);
|
|
124
126
|
});
|
|
125
127
|
}
|
|
126
128
|
_updateData() {
|
|
127
|
-
var E
|
|
128
|
-
const { chartSettings:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
type: "tooManyPrimaryGroups",
|
|
132
|
-
info: { count: d.keys.length, maxCount: g }
|
|
133
|
-
};
|
|
134
|
-
throw Error(a.type, { cause: a });
|
|
135
|
-
}
|
|
136
|
-
if (!((S = this.settings.secondaryGrouping) != null && S.unlimitedGroupsCount) && f.keys.length > g) {
|
|
137
|
-
const a = {
|
|
138
|
-
type: "tooManySecondaryGroups",
|
|
139
|
-
info: { count: f.keys.length, maxCount: g }
|
|
140
|
-
};
|
|
141
|
-
throw Error(a.type, { cause: a });
|
|
142
|
-
}
|
|
143
|
-
let m = A(
|
|
144
|
-
i.map((a) => {
|
|
145
|
-
var p;
|
|
146
|
-
return k(this.data, a, (p = u == null ? void 0 : u.order) == null ? void 0 : p[a.value]);
|
|
147
|
-
})
|
|
129
|
+
var E;
|
|
130
|
+
const { chartSettings: a, y: t, keyColumn: n, facetBy: o, layers: i, facetSettings: l } = this.settings, { yAxis: u } = a, m = this.data.getColumn(t.value).every((e) => e === null || !(Number(e) < 0)), h = L(this.data, this.settings.primaryGrouping), g = L(this.data, this.settings.secondaryGrouping), S = o.length ? o.map((e) => e.value) : [null];
|
|
131
|
+
let d = pt(
|
|
132
|
+
o.map((e) => ft(this.data, e))
|
|
148
133
|
);
|
|
149
|
-
if (
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
info: { count: m.length, maxCount: b }
|
|
153
|
-
};
|
|
154
|
-
throw Error(a.type, { cause: a });
|
|
134
|
+
if (d.length === 0 && (d = [[_]]), (E = l == null ? void 0 : l.order) != null && E.length) {
|
|
135
|
+
const e = d.map(D);
|
|
136
|
+
d = G.intersection(l.order, e).map((f) => d.find((V) => D(V) === f)).filter((f) => f != null);
|
|
155
137
|
}
|
|
156
|
-
const
|
|
157
|
-
this.data.setGrouping(
|
|
138
|
+
const b = d.map(D), A = mt(this.data, o, b, d), N = o.length ? S.map((e, p) => [...new Set(d.map((f) => f[p]))]) : [void 0];
|
|
139
|
+
this.data.setGrouping(
|
|
140
|
+
[...S, h.value, g.value],
|
|
141
|
+
[...N, h.groupingKeys, g.groupingKeys]
|
|
142
|
+
);
|
|
158
143
|
const c = {
|
|
159
|
-
facet:
|
|
160
|
-
primary:
|
|
161
|
-
secondary:
|
|
162
|
-
},
|
|
163
|
-
(
|
|
164
|
-
).map(String),
|
|
165
|
-
if (
|
|
166
|
-
return
|
|
167
|
-
if (
|
|
168
|
-
return
|
|
169
|
-
if (
|
|
170
|
-
return
|
|
171
|
-
if (
|
|
172
|
-
return
|
|
173
|
-
if (
|
|
174
|
-
return
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
177
|
-
if (
|
|
178
|
-
return
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
181
|
-
if (
|
|
182
|
-
return
|
|
183
|
-
if (
|
|
184
|
-
return
|
|
185
|
-
if (
|
|
186
|
-
return
|
|
187
|
-
if (
|
|
188
|
-
return
|
|
144
|
+
facet: d,
|
|
145
|
+
primary: h.groupingKeys,
|
|
146
|
+
secondary: g.groupingKeys
|
|
147
|
+
}, x = c.facet.reduce((e, p) => (e[D(p)] = c.primary.filter(
|
|
148
|
+
(f) => this.data.getRowsByGrouping([...p, f]).length > 0
|
|
149
|
+
).map(String), e), {}), I = i.filter((e) => !(e instanceof C)).map((e) => {
|
|
150
|
+
if (e instanceof j)
|
|
151
|
+
return tt(e, c, this.data, t, n, u);
|
|
152
|
+
if (e instanceof H)
|
|
153
|
+
return et(e, c, this.data, t, u);
|
|
154
|
+
if (e instanceof q)
|
|
155
|
+
return rt(e, c, this.data, t, u, n);
|
|
156
|
+
if (e instanceof z)
|
|
157
|
+
return nt(e, c, this.data, t, u);
|
|
158
|
+
if (e instanceof J)
|
|
159
|
+
return st(e, c, this.data, t, u);
|
|
160
|
+
if (e instanceof M)
|
|
161
|
+
return ot(e, c, this.data, t, u);
|
|
162
|
+
if (e instanceof Q)
|
|
163
|
+
return it(e, c, this.data, t);
|
|
164
|
+
if (e instanceof W)
|
|
165
|
+
return lt(e, c, this.data, t);
|
|
166
|
+
if (e instanceof X)
|
|
167
|
+
return ct(e, c, this.data, t, u);
|
|
168
|
+
if (e instanceof Y)
|
|
169
|
+
return ut(e, c, this.data, t, u);
|
|
170
|
+
if (e instanceof Z)
|
|
171
|
+
return at(e, c, this.data, t, u);
|
|
172
|
+
if (e instanceof $)
|
|
173
|
+
return ht(e, c, this.data, t);
|
|
189
174
|
throw new Error("Unknown layer type");
|
|
190
|
-
}),
|
|
191
|
-
if (
|
|
175
|
+
}), R = i.filter((e) => e instanceof C).map((e) => {
|
|
176
|
+
if (h.value === null)
|
|
192
177
|
throw new Error("Cannot calculate p-value without data grouping");
|
|
193
|
-
return
|
|
178
|
+
return dt(e, c.facet, c.primary, t, this.data);
|
|
194
179
|
});
|
|
195
180
|
this.calculatedData = {
|
|
196
|
-
layersData:
|
|
197
|
-
statsLayersData:
|
|
198
|
-
primaryGrouping:
|
|
199
|
-
secondaryGrouping:
|
|
200
|
-
facetKeyLists:
|
|
201
|
-
nonEmptyGroupsByFacets:
|
|
202
|
-
onlyPositive:
|
|
203
|
-
facetKeys:
|
|
204
|
-
facetLabels:
|
|
181
|
+
layersData: I,
|
|
182
|
+
statsLayersData: R,
|
|
183
|
+
primaryGrouping: h,
|
|
184
|
+
secondaryGrouping: g,
|
|
185
|
+
facetKeyLists: d,
|
|
186
|
+
nonEmptyGroupsByFacets: x,
|
|
187
|
+
onlyPositive: m,
|
|
188
|
+
facetKeys: b,
|
|
189
|
+
facetLabels: A
|
|
205
190
|
};
|
|
206
191
|
}
|
|
207
192
|
_updateAesInData() {
|
|
208
193
|
if (this.calculatedData === null)
|
|
209
194
|
return;
|
|
210
|
-
const { layers:
|
|
211
|
-
for (let
|
|
212
|
-
const
|
|
213
|
-
"aes" in
|
|
195
|
+
const { layers: a, primaryGrouping: t, secondaryGrouping: n } = this.settings, o = a.filter((i) => !(i instanceof C));
|
|
196
|
+
for (let i = 0; i < o.length; i++) {
|
|
197
|
+
const l = o[i];
|
|
198
|
+
"aes" in l && (this.calculatedData.layersData[i].aes = l.aes);
|
|
214
199
|
}
|
|
215
|
-
this.calculatedData.primaryGrouping =
|
|
216
|
-
t.map((s) => {
|
|
217
|
-
var h;
|
|
218
|
-
return k(this.data, s, (h = l == null ? void 0 : l.order) == null ? void 0 : h[s.value]);
|
|
219
|
-
})
|
|
220
|
-
) : [[D]];
|
|
200
|
+
this.calculatedData.primaryGrouping = L(this.data, t), this.calculatedData.secondaryGrouping = L(this.data, n);
|
|
221
201
|
}
|
|
222
202
|
_updateChart() {
|
|
223
203
|
if (!this.calculatedData)
|
|
224
204
|
return;
|
|
225
|
-
const { id:
|
|
205
|
+
const { id: a, chartSettings: t, keyColumn: n, facetSettings: o } = this.settings, { facetLabels: i } = this.calculatedData;
|
|
226
206
|
this.chartRenderer.render(
|
|
227
207
|
this.data,
|
|
228
|
-
|
|
208
|
+
a,
|
|
229
209
|
t,
|
|
230
210
|
this.calculatedData.primaryGrouping,
|
|
231
211
|
this.calculatedData.secondaryGrouping,
|
|
232
|
-
|
|
212
|
+
o,
|
|
233
213
|
this.calculatedData.facetKeys,
|
|
234
|
-
this.calculatedData.facetKeys.map((
|
|
214
|
+
this.calculatedData.facetKeys.map((l) => i[l]),
|
|
235
215
|
this.calculatedData.layersData,
|
|
236
216
|
this.calculatedData.statsLayersData,
|
|
237
217
|
n,
|