@milaboratories/graph-maker 1.1.157 → 1.1.159
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/GraphMaker/constantsCommon.d.ts +1 -0
- package/dist/GraphMaker/constantsCommon.d.ts.map +1 -1
- package/dist/GraphMaker/constantsCommon.js +17 -16
- package/dist/GraphMaker/constantsCommon.js.map +1 -1
- package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.d.ts.map +1 -1
- package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.js +104 -93
- package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.js.map +1 -1
- package/dist/GraphMaker/index.vue.js +33 -33
- package/dist/GraphMaker/index.vue.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts +1 -0
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.js +11 -11
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js +136 -135
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/HeatmapSettingsImpl.js +2 -2
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/HeatmapSettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/Annotation.js +115 -107
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/Annotation.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/AnnotationCellsCanvas.js +99 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/AnnotationCellsCanvas.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/AnnotationCellsSvg.js +57 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/AnnotationCellsSvg.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/index.js +43 -43
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/CanvasCells.js +85 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/CanvasCells.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Captions/AxisCaptions.js +5 -5
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Captions/GroupCaptions.js +16 -16
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js +191 -197
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/ChartsGroup.js +29 -27
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/ChartsGroup.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/SvgCells.js +38 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/SvgCells.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/tooltipUtils.js +44 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/tooltipUtils.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/constants.js +16 -15
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/constants.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js +63 -66
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js +64 -62
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateChartSideElementSizes.js +9 -9
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/components/ChartsGroup.js +14 -14
- package/dist/node_modules/@milaboratories/miplots4/dist/types/heatmap.js +5 -4
- package/dist/node_modules/@milaboratories/miplots4/dist/types/heatmap.js.map +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/constants.js +10 -8
- package/dist/node_modules/@milaboratories/pf-plots/dist/constants.js.map +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ComponentController.js +21 -21
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/bubble.js +19 -19
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/heatmap.js +8 -8
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot-umap.js +9 -9
- package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot.js +7 -7
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/blob.js +2 -2
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/blob.js.map +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/spec/spec.js +59 -57
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/drivers/pframe/spec/spec.js.map +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/components/PlDataTable.js.map +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/render/util/label.js +13 -13
- package/dist/node_modules/@milaboratories/pf-plots/dist/pframe/ColumnsProvider.js +137 -133
- package/dist/node_modules/@milaboratories/pf-plots/dist/pframe/ColumnsProvider.js.map +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/utils.js +73 -74
- package/dist/node_modules/@milaboratories/pf-plots/dist/utils.js.map +1 -1
- package/package.json +3 -3
package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/Annotation.js
CHANGED
|
@@ -1,152 +1,160 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { j as a } from "../../../node_modules/react/jsx-runtime.js";
|
|
2
|
+
import { BLACK as _ } from "../../../constants.js";
|
|
3
|
+
import { ANNOTATION_WIDTH as p } from "../../constants.js";
|
|
4
|
+
import { AnnotationCellsCanvas as O } from "./AnnotationCellsCanvas.js";
|
|
5
|
+
import { AnnotationCellsSvg as T } from "./AnnotationCellsSvg.js";
|
|
6
|
+
function X(y, f, t, c, h) {
|
|
7
|
+
if (y) {
|
|
8
|
+
const x = p / 2, $ = t === "top" ? -5 : h + 5;
|
|
9
|
+
return { x, y: $, rotate: f === "left" ? -90 : 90, anchor: f === "left" && t === "top" ? "start" : "end" };
|
|
9
10
|
}
|
|
10
|
-
const
|
|
11
|
-
return { x:
|
|
11
|
+
const e = t === "right" ? c + 5 : -5, o = p / 2;
|
|
12
|
+
return { x: e, y: o, rotate: 0, anchor: t === "right" ? "start" : "end" };
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
height: E,
|
|
28
|
-
colorScale: K,
|
|
29
|
-
aes: I,
|
|
14
|
+
function z({
|
|
15
|
+
facetKey: y,
|
|
16
|
+
data: f,
|
|
17
|
+
scales: t,
|
|
18
|
+
stepX: c,
|
|
19
|
+
stepY: h,
|
|
20
|
+
x: e,
|
|
21
|
+
y: o,
|
|
22
|
+
annotation: x,
|
|
23
|
+
showTitle: $,
|
|
24
|
+
width: B,
|
|
25
|
+
height: D,
|
|
26
|
+
colorScale: A,
|
|
27
|
+
aes: j,
|
|
30
28
|
frame: k,
|
|
31
|
-
xGroupKeys:
|
|
32
|
-
yGroupKeys:
|
|
33
|
-
xKeysByGroups:
|
|
34
|
-
yKeysByGroups:
|
|
35
|
-
tooltipsData:
|
|
36
|
-
|
|
29
|
+
xGroupKeys: v,
|
|
30
|
+
yGroupKeys: C,
|
|
31
|
+
xKeysByGroups: g,
|
|
32
|
+
yKeysByGroups: u,
|
|
33
|
+
tooltipsData: m,
|
|
34
|
+
cellsRenderingMode: w
|
|
37
35
|
}) {
|
|
38
|
-
const { position:
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
t
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
36
|
+
const { position: K, titlePosition: G, valueColumn: N } = x, i = K === "left" || K === "right", S = (i ? t.y : t.x).domain(), d = X(i, K, G, B, D);
|
|
37
|
+
return /* @__PURE__ */ a.jsxs("g", { children: [
|
|
38
|
+
w === "svg" && /* @__PURE__ */ a.jsx(
|
|
39
|
+
T,
|
|
40
|
+
{
|
|
41
|
+
facetKey: y,
|
|
42
|
+
scales: t,
|
|
43
|
+
keys: S,
|
|
44
|
+
x: e,
|
|
45
|
+
y: o,
|
|
46
|
+
stepX: c,
|
|
47
|
+
stepY: h,
|
|
48
|
+
vertical: i,
|
|
49
|
+
aes: j,
|
|
50
|
+
colorScale: A,
|
|
51
|
+
data: f,
|
|
52
|
+
annotation: x,
|
|
53
|
+
tooltipsData: m
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
w === "canvas" && /* @__PURE__ */ a.jsx(
|
|
57
|
+
O,
|
|
58
|
+
{
|
|
59
|
+
facetKey: y,
|
|
60
|
+
scales: t,
|
|
61
|
+
keys: S,
|
|
62
|
+
x: e,
|
|
63
|
+
y: o,
|
|
64
|
+
stepX: c,
|
|
65
|
+
stepY: h,
|
|
66
|
+
vertical: i,
|
|
67
|
+
aes: j,
|
|
68
|
+
colorScale: A,
|
|
69
|
+
data: f,
|
|
70
|
+
annotation: x,
|
|
71
|
+
tooltipsData: m
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
m.fixed && !i && v.map((n) => {
|
|
75
|
+
const s = g[n].length;
|
|
76
|
+
if (s === 0)
|
|
69
77
|
return null;
|
|
70
|
-
const
|
|
71
|
-
return /* @__PURE__ */
|
|
78
|
+
const l = s * c, r = t.x(g[n][0]);
|
|
79
|
+
return /* @__PURE__ */ a.jsx(
|
|
72
80
|
"rect",
|
|
73
81
|
{
|
|
74
|
-
x:
|
|
75
|
-
y:
|
|
76
|
-
width:
|
|
77
|
-
height:
|
|
82
|
+
x: r + e,
|
|
83
|
+
y: o,
|
|
84
|
+
width: l,
|
|
85
|
+
height: p,
|
|
78
86
|
stroke: "none",
|
|
79
87
|
fill: "rgba(255, 255, 255, 0.8)"
|
|
80
88
|
},
|
|
81
|
-
`${
|
|
89
|
+
`${r}_${o}`
|
|
82
90
|
);
|
|
83
91
|
}),
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
92
|
+
m.fixed && i && C.map((n) => {
|
|
93
|
+
const s = u[n].length;
|
|
94
|
+
if (s === 0)
|
|
87
95
|
return null;
|
|
88
|
-
const
|
|
89
|
-
return /* @__PURE__ */
|
|
96
|
+
const l = s * h, r = t.y(u[n][0]);
|
|
97
|
+
return /* @__PURE__ */ a.jsx(
|
|
90
98
|
"rect",
|
|
91
99
|
{
|
|
92
|
-
x:
|
|
93
|
-
y:
|
|
94
|
-
width:
|
|
95
|
-
height:
|
|
100
|
+
x: e,
|
|
101
|
+
y: r + o,
|
|
102
|
+
width: p,
|
|
103
|
+
height: l,
|
|
96
104
|
stroke: "none",
|
|
97
105
|
fill: "rgba(255, 255, 255, 0.8)"
|
|
98
106
|
},
|
|
99
|
-
`${
|
|
107
|
+
`${e}_${r}`
|
|
100
108
|
);
|
|
101
109
|
}),
|
|
102
|
-
k.type === "groups" && !
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
110
|
+
k.type === "groups" && !i && v.map((n) => {
|
|
111
|
+
const s = g[n].length;
|
|
112
|
+
if (s === 0)
|
|
105
113
|
return null;
|
|
106
|
-
const
|
|
107
|
-
return /* @__PURE__ */
|
|
114
|
+
const l = s * c, r = t.x(g[n][0]);
|
|
115
|
+
return /* @__PURE__ */ a.jsx(
|
|
108
116
|
"rect",
|
|
109
117
|
{
|
|
110
|
-
x:
|
|
111
|
-
y:
|
|
112
|
-
width:
|
|
113
|
-
height:
|
|
114
|
-
stroke:
|
|
118
|
+
x: r + e,
|
|
119
|
+
y: o,
|
|
120
|
+
width: l,
|
|
121
|
+
height: p,
|
|
122
|
+
stroke: _,
|
|
115
123
|
fill: "none"
|
|
116
124
|
},
|
|
117
|
-
`${
|
|
125
|
+
`${r}_${o}`
|
|
118
126
|
);
|
|
119
127
|
}),
|
|
120
|
-
k.type === "groups" &&
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
128
|
+
k.type === "groups" && i && C.map((n) => {
|
|
129
|
+
const s = u[n].length;
|
|
130
|
+
if (s === 0)
|
|
123
131
|
return null;
|
|
124
|
-
const
|
|
125
|
-
return /* @__PURE__ */
|
|
132
|
+
const l = s * h, r = t.y(u[n][0]);
|
|
133
|
+
return /* @__PURE__ */ a.jsx(
|
|
126
134
|
"rect",
|
|
127
135
|
{
|
|
128
|
-
x:
|
|
129
|
-
y:
|
|
130
|
-
width:
|
|
131
|
-
height:
|
|
132
|
-
stroke:
|
|
136
|
+
x: e,
|
|
137
|
+
y: r + o,
|
|
138
|
+
width: p,
|
|
139
|
+
height: l,
|
|
140
|
+
stroke: _,
|
|
133
141
|
fill: "none"
|
|
134
142
|
},
|
|
135
|
-
`${
|
|
143
|
+
`${e}_${r}`
|
|
136
144
|
);
|
|
137
145
|
}),
|
|
138
|
-
|
|
146
|
+
$ && /* @__PURE__ */ a.jsx(
|
|
139
147
|
"g",
|
|
140
148
|
{
|
|
141
149
|
fontWeight: "500",
|
|
142
150
|
fontSize: "14px",
|
|
143
|
-
transform: `translate(${
|
|
144
|
-
children: /* @__PURE__ */
|
|
151
|
+
transform: `translate(${e + d.x},${o + d.y}) rotate(${d.rotate})`,
|
|
152
|
+
children: /* @__PURE__ */ a.jsx("text", { textAnchor: d.anchor, dominantBaseline: "central", children: N.label ?? N.value })
|
|
145
153
|
}
|
|
146
154
|
)
|
|
147
155
|
] });
|
|
148
156
|
}
|
|
149
157
|
export {
|
|
150
|
-
|
|
158
|
+
z as Annotation
|
|
151
159
|
};
|
|
152
160
|
//# sourceMappingURL=Annotation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Annotation.js","sources":["../../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Annotations/Annotation.tsx"],"sourcesContent":["import { createPortal } from 'react-dom';\nimport type { TooltipsData } from '../../../common/Tooltip';\nimport { BLACK } from '../../../constants';\nimport type { DataValue } from '../../../types';\nimport { ANNOTATION_WIDTH } from '../../constants';\nimport type { Cell, GroupedCellsData } from '../../getCells';\nimport type { HeatmapSettingsImpl } from '../../HeatmapSettingsImpl';\nimport type { AnnotationColorScales, AnnotationTooltipData, ChartScales } from '../types';\n\nfunction getTextPosition(\n vertical: boolean,\n annotationPosition: string,\n titlePosition: string,\n width: number,\n height: number\n) {\n if (vertical) {\n const x = ANNOTATION_WIDTH / 2;\n const y = titlePosition === 'top' ? -5 : height + 5;\n const rotate = annotationPosition === 'left' ? -90 : 90;\n const anchor = annotationPosition === 'left' && titlePosition === 'top' ? 'start' : 'end';\n return {x, y, rotate, anchor};\n }\n const x = titlePosition === 'right' ? width + 5 : -5;\n const y = ANNOTATION_WIDTH / 2;\n const anchor = titlePosition === 'right' ? 'start' : 'end';\n return {x, y, rotate: 0, anchor};\n}\ninterface AnnotationProps {\n facetKey: string;\n scales: ChartScales;\n data: Record<string, DataValue>;\n annotation: HeatmapSettingsImpl['annotations'][0];\n stepX: number;\n stepY: number;\n vertical?: boolean;\n x: number;\n y: number;\n width: number;\n height: number;\n showTitle: boolean;\n colorScale: AnnotationColorScales[string];\n aes: HeatmapSettingsImpl['aes'];\n frame: HeatmapSettingsImpl['chartSettings']['frame'];\n xGroupKeys: string[];\n yGroupKeys: string[];\n xKeysByGroups: GroupedCellsData['facets'][keyof GroupedCellsData['facets']]['xKeysByGroups'];\n yKeysByGroups: GroupedCellsData['facets'][keyof GroupedCellsData['facets']]['yKeysByGroups'];\n tooltipsData: TooltipsData<Cell | AnnotationTooltipData>;\n activeElementContainer?: Element;\n}\n\nfunction isAnnotationTooltip(d:Cell|AnnotationTooltipData|null):d is AnnotationTooltipData {\n return d !== null && ('isAnnotation' in d);\n}\n\nexport function Annotation({\n facetKey,\n data,\n scales,\n stepX,\n stepY,\n x,\n y,\n annotation,\n showTitle,\n width,\n height,\n colorScale,\n aes,\n frame,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups,\n yKeysByGroups,\n tooltipsData,\n activeElementContainer\n}: AnnotationProps) {\n const {position, titlePosition, valueColumn} = annotation;\n const vertical = position === 'left' || position === 'right';\n const keys = (vertical ? scales.y : scales.x).domain();\n const textPosition = getTextPosition(vertical, position, titlePosition, width, height);\n const isDimmedBackground = tooltipsData.fixed && activeElementContainer;\n\n return (\n <g>\n {keys.map(key => {\n const value = data?.[key];\n const fillColor = colorScale.type === 'continuous'\n ? colorScale.scale(Number(value))\n : colorScale.scale(String(value));\n const xInner= x + (vertical ? 0 : scales.x(key));\n const yInner= y + (vertical ? scales.y(key) : 0);\n const width = vertical ? ANNOTATION_WIDTH : stepX;\n const height = vertical ? stepY : ANNOTATION_WIDTH;\n const xKey = vertical ? null : key;\n const yKey = vertical ? key : null;\n const highlighted = isDimmedBackground\n && isAnnotationTooltip(tooltipsData.selectedData)\n && tooltipsData.selectedData.xKey === xKey\n && tooltipsData.selectedData.yKey === yKey\n && facetKey === tooltipsData.currentFacet;\n const cellElement = (\n <rect\n key={key}\n x={xInner}\n y={yInner}\n width={width}\n height={height}\n fill={fillColor}\n stroke={aes.cellStrokeColor}\n onMouseEnter={() => tooltipsData.onMouseEnter({\n isAnnotation: true,\n x: xInner + width,\n y: yInner + height / 2,\n xKey,\n yKey,\n value,\n title: valueColumn.label ?? valueColumn.value,\n column: annotation.valueColumn\n } satisfies AnnotationTooltipData, facetKey)}\n onMouseLeave={() => tooltipsData.onMouseLeave()}\n />\n );\n return highlighted ? createPortal(cellElement, activeElementContainer) : cellElement;\n })}\n {tooltipsData.fixed && !vertical && xGroupKeys.map(xGroupKey => {\n const keysCountX = xKeysByGroups[xGroupKey].length;\n if (keysCountX === 0) {\n return null;\n }\n const groupWidth = keysCountX * stepX;\n const groupX = scales.x(xKeysByGroups[xGroupKey][0]);\n return (\n <rect\n key={`${groupX}_${y}`}\n x={groupX + x}\n y={y}\n width={groupWidth}\n height={ANNOTATION_WIDTH}\n stroke=\"none\"\n fill=\"rgba(255, 255, 255, 0.8)\"\n />\n );\n })}\n {tooltipsData.fixed && vertical && yGroupKeys.map(yGroupKey => {\n const keysCountY = yKeysByGroups[yGroupKey].length;\n if (keysCountY === 0) {\n return null;\n }\n const groupHeight = keysCountY * stepY;\n const groupY = scales.y(yKeysByGroups[yGroupKey][0]);\n return (\n <rect\n key={`${x}_${groupY}`}\n x={x}\n y={groupY + y}\n width={ANNOTATION_WIDTH}\n height={groupHeight}\n stroke=\"none\"\n fill=\"rgba(255, 255, 255, 0.8)\"\n />\n );\n })}\n {frame.type === 'groups' &&\n !vertical &&\n xGroupKeys.map(xGroupKey => {\n const keysCountX = xKeysByGroups[xGroupKey].length;\n if (keysCountX === 0) {\n return null;\n }\n const groupWidth = keysCountX * stepX;\n const groupX = scales.x(xKeysByGroups[xGroupKey][0]);\n return (\n <rect\n key={`${groupX}_${y}`}\n x={groupX + x}\n y={y}\n width={groupWidth}\n height={ANNOTATION_WIDTH}\n stroke={BLACK}\n fill=\"none\"\n />\n );\n })}\n {frame.type === 'groups' &&\n vertical &&\n yGroupKeys.map(yGroupKey => {\n const keysCountY = yKeysByGroups[yGroupKey].length;\n if (keysCountY === 0) {\n return null;\n }\n const groupHeight = keysCountY * stepY;\n const groupY = scales.y(yKeysByGroups[yGroupKey][0]);\n return (\n <rect\n key={`${x}_${groupY}`}\n x={x}\n y={groupY + y}\n width={ANNOTATION_WIDTH}\n height={groupHeight}\n stroke={BLACK}\n fill=\"none\"\n />\n );\n })}\n {showTitle && (\n <g\n fontWeight=\"500\"\n fontSize=\"14px\"\n transform={`translate(${x + textPosition.x},${y + textPosition.y}) rotate(${textPosition.rotate})`}\n >\n <text textAnchor={textPosition.anchor} dominantBaseline=\"central\">\n {valueColumn.label ?? valueColumn.value}\n </text>\n </g>\n )}\n </g>\n );\n}\n"],"names":["getTextPosition","vertical","annotationPosition","titlePosition","width","height","x","ANNOTATION_WIDTH","y","isAnnotationTooltip","d","Annotation","facetKey","data","scales","stepX","stepY","annotation","showTitle","colorScale","aes","frame","xGroupKeys","yGroupKeys","xKeysByGroups","yKeysByGroups","tooltipsData","activeElementContainer","position","valueColumn","keys","textPosition","isDimmedBackground","h","key","value","fillColor","xInner","yInner","xKey","yKey","highlighted","cellElement","jsx","createPortal","xGroupKey","keysCountX","groupWidth","groupX","yGroupKey","keysCountY","groupHeight","groupY","BLACK"],"mappings":";;;;AASA,SAASA,EACLC,GACAC,GACAC,GACAC,GACAC,GACF;AACE,MAAIJ,GA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Q8C;AAAAA,UACR,MAAK;AAAA,QAAA;AAAA,QANA,GAAGL,CAAM,IAAIxC,CAAC;AAAA,MAAA;AAAA,IAS/B,CAAC;AAAA,IACJa,EAAM,SAAS,YACZpB,KACAsB,EAAW,IAAI,CAAA0B,MAAa;AACxB,YAAMC,IAAazB,EAAcwB,CAAS,EAAE;AAC5C,UAAIC,MAAe;AACf,eAAO;AAEX,YAAMC,IAAcD,IAAalC,GAC3BoC,IAAStC,EAAO,EAAEW,EAAcwB,CAAS,EAAE,CAAC,CAAC;AACnD,aACIN,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UAEG,GAAArC;AAAAA,UACA,GAAG8C,IAAS5C;AAAAA,UACZ,OAAOD;AAAAA,UACP,QAAQ4C;AAAAA,UACR,QAAQE;AAAAA,UACR,MAAK;AAAA,QAAA;AAAA,QANA,GAAG/C,CAAC,IAAI8C,CAAM;AAAA,MAAA;AAAA,IAS/B,CAAC;AAAA,IACJlC,KACGyB,gBAAAA,EAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACG,YAAW;AAAA,QACX,UAAS;AAAA,QACT,WAAW,aAAarC,IAAIyB,EAAa,CAAC,IAAIvB,IAAIuB,EAAa,CAAC,YAAYA,EAAa,MAAM;AAAA,QAE/F,UAAAY,gBAAAA,EAAAA,IAAC,QAAA,EAAK,YAAYZ,EAAa,QAAQ,kBAAiB,WACnD,UAAAF,EAAY,SAASA,EAAY,OACtC;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAGZ;AAER;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"Annotation.js","sources":["../../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Annotations/Annotation.tsx"],"sourcesContent":["import type { TooltipsData } from '../../../common/Tooltip';\nimport { BLACK } from '../../../constants';\nimport type { DataValue } from '../../../types';\nimport { ANNOTATION_WIDTH } from '../../constants';\nimport type { Cell, GroupedCellsData } from '../../getCells';\nimport type { HeatmapSettingsImpl } from '../../HeatmapSettingsImpl';\nimport type { AnnotationColorScales, AnnotationTooltipData, ChartScales } from '../types';\nimport { AnnotationCellsCanvas } from './AnnotationCellsCanvas';\nimport { AnnotationCellsSvg } from './AnnotationCellsSvg';\n\nfunction getTextPosition(\n vertical: boolean,\n annotationPosition: string,\n titlePosition: string,\n width: number,\n height: number\n) {\n if (vertical) {\n const x = ANNOTATION_WIDTH / 2;\n const y = titlePosition === 'top' ? -5 : height + 5;\n const rotate = annotationPosition === 'left' ? -90 : 90;\n const anchor = annotationPosition === 'left' && titlePosition === 'top' ? 'start' : 'end';\n return { x, y, rotate, anchor };\n }\n const x = titlePosition === 'right' ? width + 5 : -5;\n const y = ANNOTATION_WIDTH / 2;\n const anchor = titlePosition === 'right' ? 'start' : 'end';\n return { x, y, rotate: 0, anchor };\n}\ninterface AnnotationProps {\n facetKey: string;\n scales: ChartScales;\n data: Record<string, DataValue>;\n annotation: HeatmapSettingsImpl['annotations'][0];\n stepX: number;\n stepY: number;\n vertical?: boolean;\n x: number;\n y: number;\n width: number;\n height: number;\n showTitle: boolean;\n colorScale: AnnotationColorScales[string];\n aes: HeatmapSettingsImpl['aes'];\n frame: HeatmapSettingsImpl['chartSettings']['frame'];\n xGroupKeys: string[];\n yGroupKeys: string[];\n xKeysByGroups: GroupedCellsData['facets'][keyof GroupedCellsData['facets']]['xKeysByGroups'];\n yKeysByGroups: GroupedCellsData['facets'][keyof GroupedCellsData['facets']]['yKeysByGroups'];\n tooltipsData: TooltipsData<Cell | AnnotationTooltipData>;\n cellsRenderingMode: 'canvas' | 'svg'\n}\n\nexport function Annotation({\n facetKey,\n data,\n scales,\n stepX,\n stepY,\n x,\n y,\n annotation,\n showTitle,\n width,\n height,\n colorScale,\n aes,\n frame,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups,\n yKeysByGroups,\n tooltipsData,\n cellsRenderingMode,\n}: AnnotationProps) {\n const { position, titlePosition, valueColumn } = annotation;\n const vertical = position === 'left' || position === 'right';\n const keys = (vertical ? scales.y : scales.x).domain();\n const textPosition = getTextPosition(vertical, position, titlePosition, width, height);\n\n return (\n <g>\n {cellsRenderingMode === 'svg' && (\n <AnnotationCellsSvg\n facetKey={facetKey}\n scales={scales}\n keys={keys}\n x={x}\n y={y}\n stepX={stepX}\n stepY={stepY}\n vertical={vertical}\n aes={aes}\n colorScale={colorScale}\n data={data}\n annotation={annotation}\n tooltipsData={tooltipsData}\n />\n )}\n {cellsRenderingMode === 'canvas' && (\n <AnnotationCellsCanvas\n facetKey={facetKey}\n scales={scales}\n keys={keys}\n x={x}\n y={y}\n stepX={stepX}\n stepY={stepY}\n vertical={vertical}\n aes={aes}\n colorScale={colorScale}\n data={data}\n annotation={annotation}\n tooltipsData={tooltipsData}\n />\n )}\n {tooltipsData.fixed && !vertical && xGroupKeys.map(xGroupKey => {\n const keysCountX = xKeysByGroups[xGroupKey].length;\n if (keysCountX === 0) {\n return null;\n }\n const groupWidth = keysCountX * stepX;\n const groupX = scales.x(xKeysByGroups[xGroupKey][0]);\n return (\n <rect\n key={`${groupX}_${y}`}\n x={groupX + x}\n y={y}\n width={groupWidth}\n height={ANNOTATION_WIDTH}\n stroke=\"none\"\n fill=\"rgba(255, 255, 255, 0.8)\"\n />\n );\n })}\n {tooltipsData.fixed && vertical && yGroupKeys.map(yGroupKey => {\n const keysCountY = yKeysByGroups[yGroupKey].length;\n if (keysCountY === 0) {\n return null;\n }\n const groupHeight = keysCountY * stepY;\n const groupY = scales.y(yKeysByGroups[yGroupKey][0]);\n return (\n <rect\n key={`${x}_${groupY}`}\n x={x}\n y={groupY + y}\n width={ANNOTATION_WIDTH}\n height={groupHeight}\n stroke=\"none\"\n fill=\"rgba(255, 255, 255, 0.8)\"\n />\n );\n })}\n {frame.type === 'groups' &&\n !vertical &&\n xGroupKeys.map(xGroupKey => {\n const keysCountX = xKeysByGroups[xGroupKey].length;\n if (keysCountX === 0) {\n return null;\n }\n const groupWidth = keysCountX * stepX;\n const groupX = scales.x(xKeysByGroups[xGroupKey][0]);\n return (\n <rect\n key={`${groupX}_${y}`}\n x={groupX + x}\n y={y}\n width={groupWidth}\n height={ANNOTATION_WIDTH}\n stroke={BLACK}\n fill=\"none\"\n />\n );\n })}\n {frame.type === 'groups' &&\n vertical &&\n yGroupKeys.map(yGroupKey => {\n const keysCountY = yKeysByGroups[yGroupKey].length;\n if (keysCountY === 0) {\n return null;\n }\n const groupHeight = keysCountY * stepY;\n const groupY = scales.y(yKeysByGroups[yGroupKey][0]);\n return (\n <rect\n key={`${x}_${groupY}`}\n x={x}\n y={groupY + y}\n width={ANNOTATION_WIDTH}\n height={groupHeight}\n stroke={BLACK}\n fill=\"none\"\n />\n );\n })}\n {showTitle && (\n <g\n fontWeight=\"500\"\n fontSize=\"14px\"\n transform={`translate(${x + textPosition.x},${y + textPosition.y}) rotate(${textPosition.rotate})`}\n >\n <text textAnchor={textPosition.anchor} dominantBaseline=\"central\">\n {valueColumn.label ?? valueColumn.value}\n </text>\n </g>\n )}\n </g>\n );\n}\n"],"names":["getTextPosition","vertical","annotationPosition","titlePosition","width","height","x","ANNOTATION_WIDTH","y","k","Annotation","facetKey","data","scales","stepX","stepY","annotation","showTitle","colorScale","aes","frame","xGroupKeys","yGroupKeys","xKeysByGroups","yKeysByGroups","tooltipsData","cellsRenderingMode","position","valueColumn","keys","textPosition","h","jsx","AnnotationCellsSvg","AnnotationCellsCanvas","xGroupKey","keysCountX","groupWidth","groupX","yGroupKey","keysCountY","groupHeight","groupY","BLACK"],"mappings":";;;;;AAUA,SAASA,EACLC,GACAC,GACAC,GACAC,GACAC,GACF;AACE,MAAIJ,GAAU;AACV,UAAMK,IAAIC,IAAmB,GACvBC,IAAIL,MAAkB,QAAQ,KAAKE,IAAS;AAGlD,WAAO,EAAEI,GAAG,GAAAD,GAAG,QAFAN,MAAuB,SAAS,MAAM,IAE9B,QADRA,MAAuB,UAAUC,MAAkB,QAAQ,UAAU,MAAA;AAAA,EAExF;AACA,QAAMG,IAAIH,MAAkB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,IAAC,QAAA,EAAK,YAAYF,EAAa,QAAQ,kBAAiB,WACnD,UAAAF,EAAY,SAASA,EAAY,OACtC;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAGZ;AAER;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { j as E } from "../../../node_modules/react/jsx-runtime.js";
|
|
2
|
+
import { ANNOTATION_WIDTH as k } from "../../constants.js";
|
|
3
|
+
import { r as N } from "../../../_virtual/index.js";
|
|
4
|
+
import { useFunction as I } from "../../../utils/hooks/useFunction.js";
|
|
5
|
+
function P(o, t, r, n, e, l, a, i, h) {
|
|
6
|
+
if (o) {
|
|
7
|
+
o.beginPath(), o.clearRect(0, 0, i, h);
|
|
8
|
+
for (const u of n) {
|
|
9
|
+
const v = r == null ? void 0 : r[u], c = a.type === "continuous" ? a.scale(Number(v)) : a.scale(String(v)), x = e ? 0 : t.x(u), m = e ? t.y(u) : 0;
|
|
10
|
+
o.fillStyle = c, o.fillRect(x, m, i, h);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function D(o, t, r) {
|
|
15
|
+
let n = 0, e = o.length - 1;
|
|
16
|
+
for (; n <= e; ) {
|
|
17
|
+
const l = Math.floor((n + e) / 2);
|
|
18
|
+
if (Math.abs(o[l] - t) < r)
|
|
19
|
+
return o[l] >= t ? l - 1 : l;
|
|
20
|
+
t < o[l] ? e = l - 1 : n = l + 1;
|
|
21
|
+
}
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
24
|
+
function A(o, t, r, n) {
|
|
25
|
+
const e = D(t, o, n);
|
|
26
|
+
return e === -1 ? -1 : r[e];
|
|
27
|
+
}
|
|
28
|
+
function F({
|
|
29
|
+
facetKey: o,
|
|
30
|
+
scales: t,
|
|
31
|
+
data: r,
|
|
32
|
+
keys: n,
|
|
33
|
+
vertical: e,
|
|
34
|
+
annotation: l,
|
|
35
|
+
x: a,
|
|
36
|
+
y: i,
|
|
37
|
+
stepX: h,
|
|
38
|
+
stepY: u,
|
|
39
|
+
aes: v,
|
|
40
|
+
colorScale: c,
|
|
41
|
+
tooltipsData: x
|
|
42
|
+
}) {
|
|
43
|
+
const { valueColumn: m } = l, y = e ? k : h, d = e ? u : k, p = e ? y : y * n.length, M = e ? d * n.length : d, w = N.useRef(null), C = window.devicePixelRatio || 1, g = N.useRef(null), R = () => {
|
|
44
|
+
P(
|
|
45
|
+
g.current,
|
|
46
|
+
t,
|
|
47
|
+
r,
|
|
48
|
+
n,
|
|
49
|
+
e,
|
|
50
|
+
v.cellStrokeColor,
|
|
51
|
+
c,
|
|
52
|
+
y,
|
|
53
|
+
d
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
N.useEffect(() => {
|
|
57
|
+
const s = w.current;
|
|
58
|
+
g.current || (g.current = (s == null ? void 0 : s.getContext("2d")) ?? null), s && g.current && (s.style.width = p + "px", s.style.height = M + "px", g.current.scale(C, C)), R();
|
|
59
|
+
}, [p, M]), R();
|
|
60
|
+
const K = I((s) => {
|
|
61
|
+
const L = s.nativeEvent.offsetX, O = s.nativeEvent.offsetY, f = e ? A(O, t.y.range(), t.y.domain(), u) : A(L, t.x.range(), t.x.domain(), h);
|
|
62
|
+
if (f !== -1) {
|
|
63
|
+
const S = e ? 0 : t.x(f), j = e ? t.y(f) : 0, b = r[f], T = c.type === "continuous" ? c.scale(Number(b)) : c.scale(String(b));
|
|
64
|
+
x.onMouseEnter({
|
|
65
|
+
isAnnotation: !0,
|
|
66
|
+
x: a + S + y,
|
|
67
|
+
y: i + j + d / 2,
|
|
68
|
+
cell: {
|
|
69
|
+
x: a + S,
|
|
70
|
+
y: i + j,
|
|
71
|
+
width: y,
|
|
72
|
+
height: d,
|
|
73
|
+
fill: T,
|
|
74
|
+
stroke: v.cellStrokeColor
|
|
75
|
+
},
|
|
76
|
+
xKey: e ? null : f,
|
|
77
|
+
yKey: e ? f : null,
|
|
78
|
+
value: b,
|
|
79
|
+
title: m.label ?? m.value,
|
|
80
|
+
column: l.valueColumn
|
|
81
|
+
}, o);
|
|
82
|
+
} else
|
|
83
|
+
x.onMouseLeave();
|
|
84
|
+
});
|
|
85
|
+
return /* @__PURE__ */ E.jsx("foreignObject", { x: a, y: i, width: p, height: M, children: /* @__PURE__ */ E.jsx(
|
|
86
|
+
"canvas",
|
|
87
|
+
{
|
|
88
|
+
ref: w,
|
|
89
|
+
width: C * p,
|
|
90
|
+
height: C * M,
|
|
91
|
+
onMouseMove: K,
|
|
92
|
+
onMouseLeave: () => x.onMouseLeave()
|
|
93
|
+
}
|
|
94
|
+
) });
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
F as AnnotationCellsCanvas
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=AnnotationCellsCanvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationCellsCanvas.js","sources":["../../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Annotations/AnnotationCellsCanvas.tsx"],"sourcesContent":["\nimport type { AnnotationColorScales, AnnotationTooltipData, ChartScales } from '../types';\nimport { ANNOTATION_WIDTH } from '../../constants';\nimport type { DataValue } from '../../../types/common';\nimport type { HeatmapSettingsImpl } from '../../HeatmapSettingsImpl';\nimport type { Cell } from '../../getCells';\nimport type { TooltipsData } from '../../../common/Tooltip';\nimport type { MouseEventHandler } from 'react';\nimport { useEffect, useRef } from 'react';\nimport { useFunction } from '../../../utils/hooks/useFunction';\n\ninterface AnnotationCellsCanvasProps {\n facetKey: string,\n scales: ChartScales,\n keys: string[],\n x: number,\n y: number,\n stepX: number,\n stepY: number,\n vertical: boolean,\n aes: HeatmapSettingsImpl['aes'];\n colorScale: AnnotationColorScales[keyof AnnotationColorScales],\n data: Record<string, DataValue>;\n annotation: HeatmapSettingsImpl['annotations'][0];\n tooltipsData: TooltipsData<Cell | AnnotationTooltipData>;\n}\n\nfunction renderCells(\n ctx: CanvasRenderingContext2D | null,\n scales: ChartScales,\n data: Record<string, DataValue>,\n keys: string[],\n vertical: boolean,\n strokeColor: string,\n colorScale: AnnotationColorScales[keyof AnnotationColorScales],\n width: number,\n height: number\n) {\n if (!ctx) {\n return;\n }\n ctx.beginPath(); // Start a new path\n ctx.clearRect(0, 0, width, height);\n for (const key of keys) {\n const value = data?.[key];\n const fillColor = colorScale.type === 'continuous'\n ? colorScale.scale(Number(value))\n : colorScale.scale(String(value));\n const x = (vertical ? 0 : scales.x(key));\n const y = (vertical ? scales.y(key) : 0);\n\n ctx.fillStyle = fillColor;\n ctx.fillRect(x, y, width, height); // Add a rectangle to the current path\n }\n}\n\nfunction binarySearch(arr: number[], val: number, step: number) {\n let start = 0;\n let end = arr.length - 1;\n\n while (start <= end) {\n const mid = Math.floor((start + end) / 2);\n if (Math.abs(arr[mid] - val) < step) {\n return arr[mid] >= val ? mid - 1 : mid;\n }\n\n if (val < arr[mid]) {\n end = mid - 1;\n } else {\n start = mid + 1;\n }\n }\n return -1;\n}\nfunction searchKey(px: number, positions: number[], keys: string[], step: number) {\n const pos = binarySearch(positions, px, step);\n if (pos === -1) {\n return -1;\n }\n return keys[pos];\n}\n\nexport function AnnotationCellsCanvas({\n facetKey,\n scales,\n data,\n keys,\n vertical,\n annotation,\n x, y, stepX, stepY,\n aes,\n colorScale,\n tooltipsData,\n}: AnnotationCellsCanvasProps) {\n const { valueColumn } = annotation;\n const cellWidth = vertical ? ANNOTATION_WIDTH : stepX;\n const cellHeight = vertical ? stepY : ANNOTATION_WIDTH;\n const annotationWidth = vertical ? cellWidth : cellWidth * keys.length;\n const annotationHeight = vertical ? cellHeight * keys.length : cellHeight;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const canvasRatio = window.devicePixelRatio || 1;\n const ctx = useRef<CanvasRenderingContext2D | null>(null);\n const render = () => {\n renderCells(\n ctx.current,\n scales,\n data,\n keys,\n vertical,\n aes.cellStrokeColor,\n colorScale,\n cellWidth,\n cellHeight\n );\n };\n useEffect(() => {\n const canvasEl = canvasRef.current;\n if (!ctx.current) {\n ctx.current = canvasEl?.getContext('2d') ?? null;\n }\n if (canvasEl && ctx.current) {\n canvasEl.style.width = annotationWidth + 'px';\n canvasEl.style.height = annotationHeight + 'px';\n ctx.current.scale(canvasRatio, canvasRatio);\n }\n render();\n }, [annotationWidth, annotationHeight]);\n render();\n\n const moveOnCanvas: MouseEventHandler<HTMLCanvasElement> = useFunction((e: React.MouseEvent) => {\n const mouseX = e.nativeEvent.offsetX;\n const mouseY = e.nativeEvent.offsetY;\n const key = vertical\n ? searchKey(mouseY, scales.y.range(), scales.y.domain(), stepY)\n : searchKey(mouseX, scales.x.range(), scales.x.domain(), stepX);\n if (key !== -1) {\n const innerX = (vertical ? 0 : scales.x(key));\n const innerY = (vertical ? scales.y(key) : 0);\n const value = data[key];\n const fillColor = colorScale.type === 'continuous'\n ? colorScale.scale(Number(value))\n : colorScale.scale(String(value));\n tooltipsData.onMouseEnter({\n isAnnotation: true,\n x: x + innerX + cellWidth,\n y: y + innerY + cellHeight / 2,\n cell: {\n x: x + innerX,\n y: y + innerY,\n width: cellWidth,\n height: cellHeight,\n fill: fillColor,\n stroke: aes.cellStrokeColor\n },\n xKey: vertical ? null : key,\n yKey: vertical ? key : null,\n value,\n title: valueColumn.label ?? valueColumn.value,\n column: annotation.valueColumn\n } satisfies AnnotationTooltipData, facetKey);\n } else {\n tooltipsData.onMouseLeave();\n }\n });\n return (\n <foreignObject x={x} y={y} width={annotationWidth} height={annotationHeight}>\n <canvas\n ref={canvasRef}\n width={canvasRatio * annotationWidth}\n height={canvasRatio * annotationHeight}\n onMouseMove={moveOnCanvas}\n onMouseLeave={() => tooltipsData.onMouseLeave()}\n />\n </foreignObject>\n );\n}"],"names":["renderCells","ctx","scales","data","keys","vertical","strokeColor","colorScale","width","height","key","value","fillColor","x","y","binarySearch","arr","val","step","start","end","mid","searchKey","px","positions","pos","AnnotationCellsCanvas","facetKey","annotation","stepX","stepY","aes","tooltipsData","valueColumn","cellWidth","ANNOTATION_WIDTH","cellHeight","annotationWidth","annotationHeight","canvasRef","useRef","canvasRatio","render","useEffect","canvasEl","moveOnCanvas","useFunction","e","mouseX","mouseY","innerX","innerY","k","jsx"],"mappings":";;;;AA2BA,SAASA,EACLC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACF;AACE,MAAKR,GAGL;AAAAA,IAAAA,EAAI,aACJA,EAAI,UAAU,GAAG,GAAGO,GAAOC,CAAM;AACjC,eAAWC,KAAON,GAAM;AACpB,YAAMO,IAAQR,KAAA,OAAA,SAAAA,EAAOO,IACfE,IAAYL,EAAW,SAAS,eAChCA,EAAW,MAAM,OAAOI,CAAK,CAAC,IAC9BJ,EAAW,MAAM,OAAOI,CAAK,CAAC,GAC9BE,IAAKR,IAAW,IAAIH,EAAO,EAAEQ,CAAG,GAChCI,IAAKT,IAAWH,EAAO,EAAEQ,CAAG,IAAI;AAEtCT,MAAAA,EAAI,YAAYW,GAChBX,EAAI,SAASY,GAAGC,GAAGN,GAAOC,CAAM;AAAA,IACpC;AAAA,EAAA;AACJ;AAEA,SAASM,EAAaC,GAAeC,GAAaC,GAAc;AAC5D,MAAIC,IAAQ,GACRC,IAAMJ,EAAI,SAAS;AAEvB,SAAOG,KAASC,KAAK;AACjB,UAAMC,IAAM,KAAK,OAAOF,IAAQC,KAAO,CAAC;AACxC,QAAI,KAAK,IAAIJ,EAAIK,CAAG,IAAIJ,CAAG,IAAIC;AAC3B,aAAOF,EAAIK,CAAG,KAAKJ,IAAMI,IAAM,IAAIA;AAGnCJ,IAAAA,IAAMD,EAAIK,CAAG,IACbD,IAAMC,IAAM,IAEZF,IAAQE,IAAM;AAAA,EAEtB;AACA,SAAO;AACX;AACA,SAASC,EAAUC,GAAYC,GAAqBpB,GAAgBc,GAAc;AAC9E,QAAMO,IAAMV,EAAaS,GAAWD,GAAIL,CAAI;AAC5C,SAAIO,MAAQ,KACD,KAEJrB,EAAKqB,CAAG;AACnB;AAEO,SAASC,EAAsB;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aAAA;AAAA,IAAA;AAAA,EAAa,GAEtD;AAER;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { j as A } from "../../../node_modules/react/jsx-runtime.js";
|
|
2
|
+
import { ANNOTATION_WIDTH as x } from "../../constants.js";
|
|
3
|
+
function j({
|
|
4
|
+
facetKey: h,
|
|
5
|
+
scales: u,
|
|
6
|
+
data: i,
|
|
7
|
+
keys: C,
|
|
8
|
+
vertical: e,
|
|
9
|
+
annotation: c,
|
|
10
|
+
x: f,
|
|
11
|
+
y: k,
|
|
12
|
+
stepX: N,
|
|
13
|
+
stepY: S,
|
|
14
|
+
aes: m,
|
|
15
|
+
colorScale: l,
|
|
16
|
+
tooltipsData: y
|
|
17
|
+
}) {
|
|
18
|
+
const { valueColumn: p } = c;
|
|
19
|
+
return C.map((t) => {
|
|
20
|
+
const o = i == null ? void 0 : i[t], v = l.type === "continuous" ? l.scale(Number(o)) : l.scale(String(o)), a = f + (e ? 0 : u.x(t)), n = k + (e ? u.y(t) : 0), s = e ? x : N, r = e ? S : x, d = e ? null : t, g = e ? t : null;
|
|
21
|
+
return /* @__PURE__ */ A.jsx(
|
|
22
|
+
"rect",
|
|
23
|
+
{
|
|
24
|
+
x: a,
|
|
25
|
+
y: n,
|
|
26
|
+
width: s,
|
|
27
|
+
height: r,
|
|
28
|
+
fill: v,
|
|
29
|
+
stroke: m.cellStrokeColor,
|
|
30
|
+
onMouseEnter: () => y.onMouseEnter({
|
|
31
|
+
isAnnotation: !0,
|
|
32
|
+
x: a + s,
|
|
33
|
+
y: n + r / 2,
|
|
34
|
+
cell: {
|
|
35
|
+
x: a,
|
|
36
|
+
y: n,
|
|
37
|
+
width: s,
|
|
38
|
+
height: r,
|
|
39
|
+
fill: v,
|
|
40
|
+
stroke: m.cellStrokeColor
|
|
41
|
+
},
|
|
42
|
+
xKey: d,
|
|
43
|
+
yKey: g,
|
|
44
|
+
value: o,
|
|
45
|
+
title: p.label ?? p.value,
|
|
46
|
+
column: c.valueColumn
|
|
47
|
+
}, h),
|
|
48
|
+
onMouseLeave: () => y.onMouseLeave()
|
|
49
|
+
},
|
|
50
|
+
t
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
j as AnnotationCellsSvg
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=AnnotationCellsSvg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationCellsSvg.js","sources":["../../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Annotations/AnnotationCellsSvg.tsx"],"sourcesContent":["\nimport type { AnnotationColorScales, AnnotationTooltipData, ChartScales } from '../types';\nimport { ANNOTATION_WIDTH } from '../../constants';\nimport type { DataValue } from '../../../types/common';\nimport type { HeatmapSettingsImpl } from '../../HeatmapSettingsImpl';\nimport type { Cell } from '../../getCells';\nimport type { TooltipsData } from '../../../common/Tooltip';\n\ninterface AnnotationCellsSvgProps {\n facetKey: string,\n scales: ChartScales,\n keys: string[],\n x: number,\n y: number,\n stepX: number,\n stepY: number,\n vertical: boolean,\n aes: HeatmapSettingsImpl['aes'];\n colorScale: AnnotationColorScales[keyof AnnotationColorScales],\n data: Record<string, DataValue>;\n annotation: HeatmapSettingsImpl['annotations'][0];\n tooltipsData: TooltipsData<Cell | AnnotationTooltipData>;\n}\n\nexport function AnnotationCellsSvg({\n facetKey,\n scales,\n data,\n keys,\n vertical,\n annotation,\n x, y, stepX, stepY,\n aes,\n colorScale,\n tooltipsData,\n}: AnnotationCellsSvgProps) {\n const { valueColumn } = annotation;\n return keys.map(key => {\n const value = data?.[key];\n const fillColor = colorScale.type === 'continuous'\n ? colorScale.scale(Number(value))\n : colorScale.scale(String(value));\n const xInner = x + (vertical ? 0 : scales.x(key));\n const yInner = y + (vertical ? scales.y(key) : 0);\n const width = vertical ? ANNOTATION_WIDTH : stepX;\n const height = vertical ? stepY : ANNOTATION_WIDTH;\n const xKey = vertical ? null : key;\n const yKey = vertical ? key : null;\n return (\n <rect\n key={key}\n x={xInner}\n y={yInner}\n width={width}\n height={height}\n fill={fillColor}\n stroke={aes.cellStrokeColor}\n onMouseEnter={() => tooltipsData.onMouseEnter({\n isAnnotation: true,\n x: xInner + width,\n y: yInner + height / 2,\n cell: {\n x: xInner,\n y: yInner,\n width,\n height,\n fill: fillColor,\n stroke: aes.cellStrokeColor\n },\n xKey,\n yKey,\n value,\n title: valueColumn.label ?? valueColumn.value,\n column: annotation.valueColumn\n } satisfies AnnotationTooltipData, facetKey)}\n onMouseLeave={() => tooltipsData.onMouseLeave()}\n />\n );\n });\n}"],"names":["AnnotationCellsSvg","facetKey","scales","data","keys","vertical","annotation","x","y","stepX","stepY","aes","colorScale","tooltipsData","valueColumn","key","value","fillColor","xInner","yInner","width","ANNOTATION_WIDTH","height","xKey","yKey","jsx"],"mappings":";;AAwBO,SAASA,EAAmB;AAAA,EAC/B,UAAAC;AAAAA,EACA,QAAAC;AAAAA,EACA,MAAAC;AAAAA,EACA,MAAAC;AAAAA,EACA,UAAAC;AAAAA,EACA,YAAAC;AAAAA,EACA,GAAAC;AAAAA,EAAG,GAAAC;AAAAA,EAAG,OAAAC;AAAAA,EAAO,OAAAC;AAAAA,EACb,KAAAC;AAAAA,EACA,YAAAC;AAAAA,EACA,cAAAC;AACJ,GAA4B;AACxB,QAAM,EAAE,aAAAC,EAAAA,IAAgBR;AACxB,SAAOF,EAAK,IAAI,CAAAW,MAAO;AACnB,UAAMC,IAAQb,KAAA,OAAA,SAAAA,EAAOY,IACfE,IAAYL,EAAW,SAAS,eAChCA,EAAW,MAAM,OAAOI,CAAK,CAAC,IAC9BJ,EAAW,MAAM,OAAOI,CAAK,CAAC,GAC9BE,IAASX,KAAKF,IAAW,IAAIH,EAAO,EAAEa,CAAG,IACzCI,IAASX,KAAKH,IAAWH,EAAO,EAAEa,CAAG,IAAI,IACzCK,IAAQf,IAAWgB,IAAmBZ,GACtCa,IAASjB,IAAWK,I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