@milaboratories/miplots4 1.0.144 → 1.0.145
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/heatmap/ChartRenderer.d.ts +1 -1
- package/dist/heatmap/ChartRenderer.d.ts.map +1 -1
- package/dist/heatmap/ChartRenderer.js +181 -181
- package/dist/heatmap/ChartRenderer.js.map +1 -1
- package/dist/heatmap/HeatmapSettingsImpl.d.ts.map +1 -1
- package/dist/heatmap/HeatmapSettingsImpl.js +29 -29
- package/dist/heatmap/HeatmapSettingsImpl.js.map +1 -1
- package/dist/heatmap/utils/calculateCaptionTails.js +60 -60
- package/dist/heatmap/utils/calculateCaptionTails.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,99 +1,99 @@
|
|
|
1
1
|
import { MIN_STEP_FOR_VISIBLE_LABELS as _ } from "../constants.js";
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
let
|
|
6
|
-
return
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
2
|
+
const E = Math.cos(Math.PI / 4);
|
|
3
|
+
function K(a, b, s, y, f, l, o, m, I, d) {
|
|
4
|
+
const u = l[a], B = u > _;
|
|
5
|
+
let x = 0;
|
|
6
|
+
return b.forEach((r) => {
|
|
7
|
+
const n = f(a, r);
|
|
8
|
+
if (n.length === 0)
|
|
9
9
|
return 0;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
return Math.max(
|
|
10
|
+
const i = n.length * u / 2, c = m ? d.getTextWidth(s[r] ?? r) * E - i - o(n[0]) : 0, p = I && B ? n.reduce((G, h) => {
|
|
11
|
+
const L = y[h];
|
|
12
|
+
return Math.max(G, d.getTextWidth(L) * E - u / 2 - o(h));
|
|
13
13
|
}, 0) : 0;
|
|
14
|
-
|
|
15
|
-
}),
|
|
14
|
+
x = Math.max(x, c, p);
|
|
15
|
+
}), x;
|
|
16
16
|
}
|
|
17
|
-
function P(a,
|
|
18
|
-
const { facetKeys: o, xGroupKeys: m, yGroupKeys: I, xKeysByGroups: d, yKeysByGroups:
|
|
19
|
-
let
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
if (!
|
|
17
|
+
function P(a, b, s, y, f, l) {
|
|
18
|
+
const { facetKeys: o, xGroupKeys: m, yGroupKeys: I, xKeysByGroups: d, yKeysByGroups: u, xLabels: B, yLabels: x, xGroupLabels: r, yGroupLabels: n } = f.meta;
|
|
19
|
+
let i = 0, c = 0;
|
|
20
|
+
const p = a.xGroupLabels === 45, G = a.xAxisLabels === 45;
|
|
21
|
+
if (p || G)
|
|
22
|
+
if (!b.sharedX)
|
|
23
23
|
o.forEach((t) => {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
i = Math.max(
|
|
25
|
+
K(
|
|
26
26
|
t,
|
|
27
27
|
m,
|
|
28
|
-
|
|
28
|
+
r,
|
|
29
29
|
B,
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
(T, e) => f.facets[T].xKeysByGroups[e],
|
|
31
|
+
y.x,
|
|
32
|
+
s.x[t],
|
|
33
|
+
p,
|
|
33
34
|
G,
|
|
34
|
-
|
|
35
|
-
y
|
|
35
|
+
l
|
|
36
36
|
),
|
|
37
|
-
|
|
37
|
+
i
|
|
38
38
|
);
|
|
39
39
|
});
|
|
40
40
|
else {
|
|
41
41
|
const t = o[0];
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
i = Math.max(
|
|
43
|
+
K(
|
|
44
44
|
t,
|
|
45
45
|
m,
|
|
46
|
-
|
|
46
|
+
r,
|
|
47
47
|
B,
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
(T, e) => d[e],
|
|
49
|
+
y.x,
|
|
50
|
+
s.x[t],
|
|
51
|
+
p,
|
|
51
52
|
G,
|
|
52
|
-
|
|
53
|
-
y
|
|
53
|
+
l
|
|
54
54
|
),
|
|
55
|
-
|
|
55
|
+
i
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
const h = a.yGroupLabels === 45,
|
|
59
|
-
if (h ||
|
|
60
|
-
if (!
|
|
58
|
+
const h = a.yGroupLabels === 45, L = a.yAxisLabels === 45;
|
|
59
|
+
if (h || L)
|
|
60
|
+
if (!b.sharedY)
|
|
61
61
|
o.forEach((t) => {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
c = Math.max(
|
|
63
|
+
K(
|
|
64
64
|
t,
|
|
65
65
|
I,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
(
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
n,
|
|
67
|
+
x,
|
|
68
|
+
(T, e) => f.facets[T].yKeysByGroups[e],
|
|
69
|
+
y.y,
|
|
70
|
+
s.y[t],
|
|
71
71
|
h,
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
L,
|
|
73
|
+
l
|
|
74
74
|
),
|
|
75
|
-
|
|
75
|
+
c
|
|
76
76
|
);
|
|
77
77
|
});
|
|
78
78
|
else {
|
|
79
79
|
const t = o[0];
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
c = Math.max(
|
|
81
|
+
K(
|
|
82
82
|
t,
|
|
83
83
|
I,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
(
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
n,
|
|
85
|
+
x,
|
|
86
|
+
(T, e) => u[e],
|
|
87
|
+
y.y,
|
|
88
|
+
s.y[t],
|
|
89
89
|
h,
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
L,
|
|
91
|
+
l
|
|
92
92
|
),
|
|
93
|
-
|
|
93
|
+
c
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
|
-
return { xCaptionTail:
|
|
96
|
+
return { xCaptionTail: i, yCaptionTail: c };
|
|
97
97
|
}
|
|
98
98
|
export {
|
|
99
99
|
P as calculateCaptionTails
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateCaptionTails.js","sources":["../../../src/heatmap/utils/calculateCaptionTails.ts"],"sourcesContent":["import type { TextMeasurer } from '../../utils/TextMeasurer/TextMeasurer';\nimport type { ChartsScales, LabelAngles } from '../components/types';\nimport { MIN_STEP_FOR_VISIBLE_LABELS } from '../constants';\nimport type { GroupedCellsData } from '../getCells';\nimport type { HeatmapSettingsImpl } from '../HeatmapSettingsImpl';\n\nconst COS_PI_4 = Math.cos(Math.PI / 4);\nfunction getTailByFacetKey (\n facetKey: string,\n groupKeys: string[],\n groupLabels: Record<string, string>,\n valueLabels: Record<string, string>,\n getKeysInGroup: (facetKey:string, groupKey:string) => string[],\n steps: Record<string, number>,\n scale: (v:string) => number,\n groupTitleInclined: boolean,\n labelTitleInclined: boolean,\n textMeasurer: TextMeasurer\n): number {\n const step = steps[facetKey];\n const labelsVisible = step > MIN_STEP_FOR_VISIBLE_LABELS;\n\n let maxTail = 0;\n groupKeys.forEach((groupKey) => {\n const keysInGroup = getKeysInGroup(facetKey, groupKey);\n if (keysInGroup.length === 0) {\n return 0;\n }\n const groupHalfWidth = (keysInGroup.length * step) / 2;\n const groupTail = groupTitleInclined\n ? textMeasurer.getTextWidth(groupLabels[groupKey] ?? groupKey) * COS_PI_4 - groupHalfWidth - scale(keysInGroup[0])\n : 0;\n const labelTail = labelTitleInclined && labelsVisible\n ?
|
|
1
|
+
{"version":3,"file":"calculateCaptionTails.js","sources":["../../../src/heatmap/utils/calculateCaptionTails.ts"],"sourcesContent":["import type { TextMeasurer } from '../../utils/TextMeasurer/TextMeasurer';\nimport type { ChartsScales, LabelAngles } from '../components/types';\nimport { MIN_STEP_FOR_VISIBLE_LABELS } from '../constants';\nimport type { GroupedCellsData } from '../getCells';\nimport type { HeatmapSettingsImpl } from '../HeatmapSettingsImpl';\n\nconst COS_PI_4 = Math.cos(Math.PI / 4);\nfunction getTailByFacetKey (\n facetKey: string,\n groupKeys: string[],\n groupLabels: Record<string, string>,\n valueLabels: Record<string, string>,\n getKeysInGroup: (facetKey:string, groupKey:string) => string[],\n steps: Record<string, number>,\n scale: (v:string) => number,\n groupTitleInclined: boolean,\n labelTitleInclined: boolean,\n textMeasurer: TextMeasurer\n): number {\n const step = steps[facetKey];\n const labelsVisible = step > MIN_STEP_FOR_VISIBLE_LABELS;\n\n let maxTail = 0;\n groupKeys.forEach((groupKey) => {\n const keysInGroup = getKeysInGroup(facetKey, groupKey);\n if (keysInGroup.length === 0) {\n return 0;\n }\n const groupHalfWidth = (keysInGroup.length * step) / 2;\n const groupTail = groupTitleInclined\n ? textMeasurer.getTextWidth(groupLabels[groupKey] ?? groupKey) * COS_PI_4 - groupHalfWidth - scale(keysInGroup[0])\n : 0;\n const labelTail = labelTitleInclined && labelsVisible\n ? keysInGroup.reduce((res, key) => {\n const label = valueLabels[key];\n return Math.max(res, textMeasurer.getTextWidth(label) * COS_PI_4 - step / 2 - scale(key));\n }, 0)\n : 0;\n maxTail = Math.max(maxTail, groupTail, labelTail);\n });\n return maxTail;\n}\n\nexport function calculateCaptionTails(\n labelAngles: LabelAngles,\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n scales: ChartsScales,\n steps: {\n x: Record<string, number>;\n y: Record<string, number>;\n },\n groupedCells: GroupedCellsData,\n textMeasurer: TextMeasurer\n): {xCaptionTail: number; yCaptionTail: number} {\n const {facetKeys, xGroupKeys, yGroupKeys, xKeysByGroups, yKeysByGroups, xLabels, yLabels, xGroupLabels, yGroupLabels} = groupedCells.meta;\n let xCaptionTail = 0;\n let yCaptionTail = 0;\n // tails from 45deg inclined captions of groups titles/cells labels, that take place on adjacent padding\n const xGroupTitleInclined = labelAngles.xGroupLabels === 45;\n const xLabelsInclined = labelAngles.xAxisLabels === 45;\n if (xGroupTitleInclined || xLabelsInclined) {\n if (!facetSettings.sharedX) {\n facetKeys.forEach(facetKey => {\n xCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n xGroupKeys,\n xGroupLabels,\n xLabels,\n (facetKey:string, groupKey:string) => groupedCells.facets[facetKey].xKeysByGroups[groupKey],\n steps.x,\n scales.x[facetKey],\n xGroupTitleInclined,\n xLabelsInclined,\n textMeasurer\n ),\n xCaptionTail\n );\n });\n } else {\n const facetKey = facetKeys[0]; // there is no difference between facets in this case\n xCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n xGroupKeys,\n xGroupLabels,\n xLabels,\n (facetKey:string, groupKey:string) => xKeysByGroups[groupKey],\n steps.x,\n scales.x[facetKey],\n xGroupTitleInclined,\n xLabelsInclined,\n textMeasurer\n ),\n xCaptionTail\n );\n }\n }\n const yGroupTitleInclined = labelAngles.yGroupLabels === 45;\n const yLabelsInclined = labelAngles.yAxisLabels === 45;\n if (yGroupTitleInclined || yLabelsInclined) {\n if (!facetSettings.sharedY) {\n facetKeys.forEach(facetKey => {\n yCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n yGroupKeys,\n yGroupLabels,\n yLabels,\n (facetKey:string, groupKey:string) => groupedCells.facets[facetKey].yKeysByGroups[groupKey],\n steps.y,\n scales.y[facetKey],\n yGroupTitleInclined,\n yLabelsInclined,\n textMeasurer\n ),\n yCaptionTail\n );\n });\n } else {\n const facetKey = facetKeys[0]; // there is no difference between facets in this case\n yCaptionTail = Math.max(\n getTailByFacetKey(\n facetKey,\n yGroupKeys,\n yGroupLabels,\n yLabels,\n (facetKey:string, groupKey:string) => yKeysByGroups[groupKey],\n steps.y,\n scales.y[facetKey],\n yGroupTitleInclined,\n yLabelsInclined,\n textMeasurer\n ),\n yCaptionTail\n );\n }\n }\n return {xCaptionTail, yCaptionTail};\n}\n"],"names":["COS_PI_4","getTailByFacetKey","facetKey","groupKeys","groupLabels","valueLabels","getKeysInGroup","steps","scale","groupTitleInclined","labelTitleInclined","textMeasurer","step","labelsVisible","MIN_STEP_FOR_VISIBLE_LABELS","maxTail","groupKey","keysInGroup","groupHalfWidth","groupTail","labelTail","res","key","label","calculateCaptionTails","labelAngles","facetSettings","scales","groupedCells","facetKeys","xGroupKeys","yGroupKeys","xKeysByGroups","yKeysByGroups","xLabels","yLabels","xGroupLabels","yGroupLabels","xCaptionTail","yCaptionTail","xGroupTitleInclined","xLabelsInclined","yGroupTitleInclined","yLabelsInclined"],"mappings":";AAMA,MAAMA,IAAW,KAAK,IAAI,KAAK,KAAK,CAAC;AACrC,SAASC,EACLC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACM;AACN,QAAMC,IAAOL,EAAML,CAAQ,GACrBW,IAAgBD,IAAOE;AAE7B,MAAIC,IAAU;AACd,SAAAZ,EAAU,QAAQ,CAACa,MAAa;AAC5B,UAAMC,IAAcX,EAAeJ,GAAUc,CAAQ;AACrD,QAAIC,EAAY,WAAW;AACvB,aAAO;AAEX,UAAMC,IAAkBD,EAAY,SAASL,IAAQ,GAC/CO,IAAYV,IACZE,EAAa,aAAaP,EAAYY,CAAQ,KAAKA,CAAQ,IAAIhB,IAAWkB,IAAiBV,EAAMS,EAAY,CAAC,CAAC,IAC/G,GACAG,IAAYV,KAAsBG,IAClCI,EAAY,OAAO,CAACI,GAAKC,MAAQ;AAC/B,YAAMC,IAAQlB,EAAYiB,CAAG;AAC7B,aAAO,KAAK,IAAID,GAAKV,EAAa,aAAaY,CAAK,IAAIvB,IAAWY,IAAO,IAAIJ,EAAMc,CAAG,CAAC;AAAA,IAC5F,GAAG,CAAC,IACF;AACN,IAAAP,IAAU,KAAK,IAAIA,GAASI,GAAWC,CAAS;AAAA,EACpD,CAAC,GACML;AACX;AAEO,SAASS,EACZC,GACAC,GACAC,GACApB,GAIAqB,GACAjB,GAC4C;AAC5C,QAAM,EAAC,WAAAkB,GAAW,YAAAC,GAAY,YAAAC,GAAY,eAAAC,GAAe,eAAAC,GAAe,SAAAC,GAAS,SAAAC,GAAS,cAAAC,GAAc,cAAAC,EAAA,IAAgBT,EAAa;AACrI,MAAIU,IAAe,GACfC,IAAe;AAEnB,QAAMC,IAAsBf,EAAY,iBAAiB,IACnDgB,IAAkBhB,EAAY,gBAAgB;AACpD,MAAIe,KAAuBC;AACvB,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