@milaboratories/graph-maker 1.1.161 → 1.1.163
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 +6 -0
- package/dist/GraphMaker/constantsCommon.d.ts.map +1 -1
- package/dist/GraphMaker/constantsCommon.js +25 -19
- package/dist/GraphMaker/constantsCommon.js.map +1 -1
- package/dist/GraphMaker/forms/LayersForm/Layer/heatmap/Heatmap.vue.d.ts.map +1 -1
- package/dist/GraphMaker/forms/LayersForm/Layer/heatmap/Heatmap.vue.js +122 -91
- package/dist/GraphMaker/forms/LayersForm/Layer/heatmap/Heatmap.vue.js.map +1 -1
- package/dist/GraphMaker/forms/LayersForm/Layer/heatmap/HeatmapClustered.vue.d.ts.map +1 -1
- package/dist/GraphMaker/forms/LayersForm/Layer/heatmap/HeatmapClustered.vue.js +105 -77
- package/dist/GraphMaker/forms/LayersForm/Layer/heatmap/HeatmapClustered.vue.js.map +1 -1
- package/dist/GraphMaker/index.vue.d.ts.map +1 -1
- package/dist/GraphMaker/index.vue.js +77 -73
- package/dist/GraphMaker/index.vue.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts +5 -0
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.js +28 -24
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/MiPlots.js +4 -4
- package/dist/node_modules/@milaboratories/miplots4/dist/common/Legend.js +3 -3
- package/dist/node_modules/@milaboratories/miplots4/dist/common/Legend.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js +25 -25
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/HeatmapSettingsImpl.js +13 -8
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/HeatmapSettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/index.js +58 -58
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js +10 -10
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Dendrograms.js +51 -51
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Dendrograms.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js +204 -110
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getClusters.js +135 -46
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getClusters.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getDendrograms.js +35 -37
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getDendrograms.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js +81 -78
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/heatmap.js +14 -9
- package/dist/node_modules/@milaboratories/miplots4/dist/types/heatmap.js.map +1 -1
- package/package.json +2 -2
package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Annotations/index.tsx"],"sourcesContent":["import type {TooltipsData} from '../../../common/Tooltip';\nimport {Annotation} from './Annotation';\nimport type {\n AnnotationColorScales,\n AnnotationTooltipData,\n ChartDimensionsData,\n ChartScales,\n} from '../types';\nimport {ANNOTATION_WIDTH, ANNOTATIONS_OFFSET} from '../../constants';\nimport type {Cell} from '../../getCells';\nimport type {GroupedCellsData} from '../../getCells';\nimport type {HeatmapSettingsImpl} from '../../HeatmapSettingsImpl';\nimport React from 'react';\n\nfunction showTitle(item: HeatmapSettingsImpl['annotations'][0], chartEdgeSides: ChartDimensionsData['chartEdgeSides']) {\n return item.showTitle && chartEdgeSides.includes(item.titlePosition);\n}\n\ninterface AnnotationProps {\n facetKey: string;\n sideElementBBoxes: ChartDimensionsData['sideElementBBoxes'];\n annotations: HeatmapSettingsImpl['annotations'];\n cellsMeta: GroupedCellsData['meta'];\n annotationColorScales: AnnotationColorScales;\n sharedX: boolean;\n sharedY: boolean;\n chartEdgeSides: ChartDimensionsData['chartEdgeSides'];\n width: number;\n height: number;\n scales: ChartScales;\n stepX: number;\n stepY: number;\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 Annotations({\n facetKey,\n sideElementBBoxes,\n annotations,\n annotationColorScales,\n cellsMeta,\n chartEdgeSides,\n sharedX,\n sharedY,\n width,\n height,\n scales,\n stepX,\n stepY,\n aes,\n frame,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups,\n yKeysByGroups,\n tooltipsData,\n cellsRenderingMode,\n}: AnnotationProps) {\n const usedAnnotations = annotations.filter(item => {\n return (\n chartEdgeSides.includes(item.position) ||\n (!sharedX && ['left', 'right'].includes(item.position)) ||\n (!sharedY && ['top', 'bottom'].includes(item.position))\n );\n });\n const leftAnnotations = usedAnnotations.filter(item => item.position === 'left');\n const rightAnnotations = usedAnnotations.filter(item => item.position === 'right');\n const topAnnotations = usedAnnotations.filter(item => item.position === 'top');\n const bottomAnnotations = usedAnnotations.filter(item => item.position === 'bottom');\n const {xDataByKeys, yDataByKeys} = cellsMeta;\n\n const commonProps = {\n facetKey,\n scales,\n stepX,\n stepY,\n width,\n height,\n aes,\n frame,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups,\n yKeysByGroups,\n tooltipsData,\n cellsRenderingMode,\n };\n return (\n <g>\n {leftAnnotations.map((item, idx) => {\n return (\n <Annotation\n key={item.id}\n annotation={item}\n colorScale={annotationColorScales[item.id]}\n data={yDataByKeys[item.valueColumn.value]}\n showTitle={showTitle(item, chartEdgeSides)}\n x={sideElementBBoxes.left.annotations.x + idx * ANNOTATION_WIDTH}\n y={sideElementBBoxes.left.annotations.y}\n {...commonProps}\n />\n );\n })}\n {rightAnnotations.map((item, idx) => {\n return (\n <Annotation\n key={item.id}\n annotation={item}\n colorScale={annotationColorScales[item.id]}\n data={yDataByKeys[item.valueColumn.value]}\n showTitle={showTitle(item, chartEdgeSides)}\n x={sideElementBBoxes.right.annotations.x + idx * ANNOTATION_WIDTH + ANNOTATIONS_OFFSET}\n y={sideElementBBoxes.right.annotations.y}\n {...commonProps}\n />\n );\n })}\n {topAnnotations.map((item, idx) => {\n return (\n <Annotation\n key={item.id}\n annotation={item}\n colorScale={annotationColorScales[item.id]}\n data={xDataByKeys[item.valueColumn.value]}\n showTitle={showTitle(item, chartEdgeSides)}\n x={sideElementBBoxes.top.annotations.x}\n y={sideElementBBoxes.top.annotations.y + idx * ANNOTATION_WIDTH}\n {...commonProps}\n />\n );\n })}\n {bottomAnnotations.map((item, idx) => {\n return (\n <Annotation\n key={item.id}\n annotation={item}\n colorScale={annotationColorScales[item.id]}\n data={xDataByKeys[item.valueColumn.value]}\n showTitle={showTitle(item, chartEdgeSides)}\n x={sideElementBBoxes.bottom.annotations.x}\n y={sideElementBBoxes.bottom.annotations.y + idx * ANNOTATION_WIDTH + ANNOTATIONS_OFFSET}\n {...commonProps}\n />\n );\n })}\n </g>\n );\n}\n"],"names":["showTitle","item","chartEdgeSides","Annotations","facetKey","sideElementBBoxes","annotations","annotationColorScales","cellsMeta","sharedX","sharedY","width","height","scales","stepX","stepY","aes","frame","xGroupKeys","yGroupKeys","xKeysByGroups","yKeysByGroups","tooltipsData","cellsRenderingMode","usedAnnotations","leftAnnotations","rightAnnotations","topAnnotations","bottomAnnotations","xDataByKeys","yDataByKeys","commonProps","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Annotations/index.tsx"],"sourcesContent":["import type {TooltipsData} from '../../../common/Tooltip';\nimport {Annotation} from './Annotation';\nimport type {\n AnnotationColorScales,\n AnnotationTooltipData,\n ChartDimensionsData,\n ChartScales,\n} from '../types';\nimport {ANNOTATION_WIDTH, ANNOTATIONS_OFFSET} from '../../constants';\nimport type {Cell} from '../../getCells';\nimport type {GroupedCellsData} from '../../getCells';\nimport type {HeatmapSettingsImpl} from '../../HeatmapSettingsImpl';\nimport React from 'react';\n\nfunction showTitle(item: HeatmapSettingsImpl['annotations'][0], chartEdgeSides: ChartDimensionsData['chartEdgeSides']) {\n return item.showTitle && chartEdgeSides.includes(item.titlePosition);\n}\n\ninterface AnnotationProps {\n facetKey: string;\n sideElementBBoxes: ChartDimensionsData['sideElementBBoxes'];\n annotations: HeatmapSettingsImpl['annotations'];\n cellsMeta: GroupedCellsData['meta'];\n annotationColorScales: AnnotationColorScales;\n sharedX: boolean;\n sharedY: boolean;\n chartEdgeSides: ChartDimensionsData['chartEdgeSides'];\n width: number;\n height: number;\n scales: ChartScales;\n stepX: number;\n stepY: number;\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 Annotations({\n facetKey,\n sideElementBBoxes,\n annotations,\n annotationColorScales,\n cellsMeta,\n chartEdgeSides,\n sharedX,\n sharedY,\n width,\n height,\n scales,\n stepX,\n stepY,\n aes,\n frame,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups,\n yKeysByGroups,\n tooltipsData,\n cellsRenderingMode,\n}: AnnotationProps) {\n const usedAnnotations = annotations.filter(item => {\n return (\n chartEdgeSides.includes(item.position) ||\n (!sharedX && ['left', 'right'].includes(item.position)) ||\n (!sharedY && ['top', 'bottom'].includes(item.position))\n );\n });\n const leftAnnotations = usedAnnotations.filter(item => item.position === 'left');\n const rightAnnotations = usedAnnotations.filter(item => item.position === 'right');\n const topAnnotations = usedAnnotations.filter(item => item.position === 'top');\n const bottomAnnotations = usedAnnotations.filter(item => item.position === 'bottom');\n const {xDataByKeys, yDataByKeys} = cellsMeta;\n\n const commonProps = {\n facetKey,\n scales,\n stepX,\n stepY,\n width,\n height,\n aes,\n frame,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups,\n yKeysByGroups,\n tooltipsData,\n cellsRenderingMode,\n };\n return (\n <g>\n {leftAnnotations.map((item, idx) => {\n return (\n <Annotation\n key={item.id}\n annotation={item}\n colorScale={annotationColorScales[item.id]}\n data={yDataByKeys[item.valueColumn.valueLabels ?? item.valueColumn.value]}\n showTitle={showTitle(item, chartEdgeSides)}\n x={sideElementBBoxes.left.annotations.x + idx * ANNOTATION_WIDTH}\n y={sideElementBBoxes.left.annotations.y}\n {...commonProps}\n />\n );\n })}\n {rightAnnotations.map((item, idx) => {\n return (\n <Annotation\n key={item.id}\n annotation={item}\n colorScale={annotationColorScales[item.id]}\n data={yDataByKeys[item.valueColumn.valueLabels ?? item.valueColumn.value]}\n showTitle={showTitle(item, chartEdgeSides)}\n x={sideElementBBoxes.right.annotations.x + idx * ANNOTATION_WIDTH + ANNOTATIONS_OFFSET}\n y={sideElementBBoxes.right.annotations.y}\n {...commonProps}\n />\n );\n })}\n {topAnnotations.map((item, idx) => {\n return (\n <Annotation\n key={item.id}\n annotation={item}\n colorScale={annotationColorScales[item.id]}\n data={xDataByKeys[item.valueColumn.valueLabels ?? item.valueColumn.value]}\n showTitle={showTitle(item, chartEdgeSides)}\n x={sideElementBBoxes.top.annotations.x}\n y={sideElementBBoxes.top.annotations.y + idx * ANNOTATION_WIDTH}\n {...commonProps}\n />\n );\n })}\n {bottomAnnotations.map((item, idx) => {\n return (\n <Annotation\n key={item.id}\n annotation={item}\n colorScale={annotationColorScales[item.id]}\n data={xDataByKeys[item.valueColumn.valueLabels ?? item.valueColumn.value]}\n showTitle={showTitle(item, chartEdgeSides)}\n x={sideElementBBoxes.bottom.annotations.x}\n y={sideElementBBoxes.bottom.annotations.y + idx * ANNOTATION_WIDTH + ANNOTATIONS_OFFSET}\n {...commonProps}\n />\n );\n })}\n </g>\n );\n}\n"],"names":["showTitle","item","chartEdgeSides","Annotations","facetKey","sideElementBBoxes","annotations","annotationColorScales","cellsMeta","sharedX","sharedY","width","height","scales","stepX","stepY","aes","frame","xGroupKeys","yGroupKeys","xKeysByGroups","yKeysByGroups","tooltipsData","cellsRenderingMode","usedAnnotations","leftAnnotations","rightAnnotations","topAnnotations","bottomAnnotations","xDataByKeys","yDataByKeys","commonProps","l","idx","jsx","Annotation","ANNOTATION_WIDTH","ANNOTATIONS_OFFSET"],"mappings":";;;AAcA,SAASA,EAAUC,GAA6CC,GAAuD;AACnH,SAAOD,EAAK,aAAaC,EAAe,SAASD,EAAK,aAAa;AACvE;AA0BO,SAASE,EAAY;AAAA,EACxB,UAAAC;AAAAA,EACA,mBAAAC;AAAAA,EACA,aAAAC;AAAAA,EACA,uBAAAC;AAAAA,EACA,WAAAC;AAAAA,EACA,gBAAAN;AAAAA,EACA,SAAAO;AAAAA,EACA,SAAAC;AAAAA,EACA,OAAAC;AAAAA,EACA,QA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,MAACC;AAAAA,MAAA;AAAA,QAEG,YAAYlC;AAAAA,QACZ,YAAYM,EAAsBN,EAAK,EAAE;AAAA,QACzC,MAAM4B,EAAY5B,EAAK,YAAY,eAAeA,EAAK,YAAY,KAAK;AAAA,QACxE,WAAWD,EAAUC,GAAMC,CAAc;AAAA,QACzC,GAAGG,EAAkB,OAAO,YAAY;AAAA,QACxC,GAAGA,EAAkB,OAAO,YAAY,IAAI4B,IAAMG,IAAmBC;AAAAA,QACpE,GAAGN;AAAAA,MAAA;AAAA,MAPC9B,EAAK;AAAA,IAAA,CAUrB;AAAA,EAAA,GACL;AAER;","x_google_ignoreList":[0]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { j as t } from "../../node_modules/react/jsx-runtime.js";
|
|
2
2
|
import { Tooltip as E } from "../../common/Tooltip.js";
|
|
3
|
-
import { useDataFrame as
|
|
3
|
+
import { useDataFrame as J } from "../../common/useDataFrame.js";
|
|
4
4
|
import { FONT_SIZE as N, FACET_TITLE_OFFSET as P } from "../constants.js";
|
|
5
5
|
import { Annotations as Q } from "./Annotations/index.js";
|
|
6
6
|
import { Captions as U } from "./Captions/index.js";
|
|
@@ -14,7 +14,7 @@ function fe({
|
|
|
14
14
|
facetKey: o,
|
|
15
15
|
dimensions: l,
|
|
16
16
|
scales: s,
|
|
17
|
-
cells:
|
|
17
|
+
cells: j,
|
|
18
18
|
xGroupKeys: f,
|
|
19
19
|
yGroupKeys: m,
|
|
20
20
|
xKeysByGroups: g,
|
|
@@ -33,11 +33,11 @@ function fe({
|
|
|
33
33
|
labelAngles: M,
|
|
34
34
|
chartSizes: d,
|
|
35
35
|
margins: x,
|
|
36
|
-
tooltipsContainer:
|
|
36
|
+
tooltipsContainer: C,
|
|
37
37
|
tooltipsData: e,
|
|
38
38
|
cellsRenderingMode: D
|
|
39
39
|
}) {
|
|
40
|
-
const R =
|
|
40
|
+
const R = J(), { xAxis: V, yAxis: W, tooltips: T } = p, { width: G, height: B } = l.inner, { padding: i, chartEdgeSides: _, sideElementBBoxes: n } = l, { xGroupLabels: H, yGroupLabels: I, xLabels: O, yLabels: q } = a, h = s.x.domain(), S = s.y.domain(), b = {
|
|
41
41
|
left: x.left + l.left + i.left,
|
|
42
42
|
right: d.totalWidth - (x.left + l.left + i.left),
|
|
43
43
|
top: x.top + l.top + i.top,
|
|
@@ -99,7 +99,7 @@ function fe({
|
|
|
99
99
|
{
|
|
100
100
|
scales: s,
|
|
101
101
|
facetKey: o,
|
|
102
|
-
cells:
|
|
102
|
+
cells: j,
|
|
103
103
|
xKeys: h,
|
|
104
104
|
yKeys: S,
|
|
105
105
|
stepX: r,
|
|
@@ -114,7 +114,7 @@ function fe({
|
|
|
114
114
|
{
|
|
115
115
|
scales: s,
|
|
116
116
|
facetKey: o,
|
|
117
|
-
cells:
|
|
117
|
+
cells: j,
|
|
118
118
|
width: G,
|
|
119
119
|
height: B,
|
|
120
120
|
xKeys: h,
|
|
@@ -160,8 +160,8 @@ function fe({
|
|
|
160
160
|
xGroupLabels: H,
|
|
161
161
|
yGroupLabels: I,
|
|
162
162
|
labelAngles: M,
|
|
163
|
-
xLabels:
|
|
164
|
-
yLabels:
|
|
163
|
+
xLabels: O,
|
|
164
|
+
yLabels: q
|
|
165
165
|
}
|
|
166
166
|
)
|
|
167
167
|
] }),
|
|
@@ -176,7 +176,7 @@ function fe({
|
|
|
176
176
|
sideDistances: b,
|
|
177
177
|
fixed: e.fixed,
|
|
178
178
|
onClose: e.onClose,
|
|
179
|
-
container:
|
|
179
|
+
container: C
|
|
180
180
|
}
|
|
181
181
|
),
|
|
182
182
|
p.tooltips.show && L(e.selectedData) && e.currentFacet === o && /* @__PURE__ */ t.jsx(
|
|
@@ -190,7 +190,7 @@ function fe({
|
|
|
190
190
|
sideDistances: b,
|
|
191
191
|
fixed: e.fixed,
|
|
192
192
|
onClose: e.onClose,
|
|
193
|
-
container:
|
|
193
|
+
container: C
|
|
194
194
|
}
|
|
195
195
|
),
|
|
196
196
|
/* @__PURE__ */ t.jsxs("g", { transform: `translate(${i.left},${i.top})`, children: [
|
|
@@ -1,87 +1,87 @@
|
|
|
1
1
|
import { j as a } from "../../node_modules/react/jsx-runtime.js";
|
|
2
|
-
import { isColumnName as
|
|
2
|
+
import { isColumnName as W } from "../../utils/index.js";
|
|
3
3
|
import { getLineShape as k } from "../../utils/getLineShape.js";
|
|
4
|
-
import { getPointShape as
|
|
5
|
-
function
|
|
6
|
-
const { source:
|
|
7
|
-
return i === "top" || i === "bottom" ? `M ${
|
|
4
|
+
import { getPointShape as B } from "../../utils/getPointShape.js";
|
|
5
|
+
function K(s, i = "top") {
|
|
6
|
+
const { source: n, target: o } = s;
|
|
7
|
+
return i === "top" || i === "bottom" ? `M ${n.x},${n.y} L ${o.x},${n.y} L${o.x},${o.y}` : `M ${n.x},${n.y} L ${n.x},${o.y} L${o.x},${o.y}`;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
if (!
|
|
9
|
+
function D(s, i, n, o, p, m) {
|
|
10
|
+
if (!n)
|
|
11
11
|
return "";
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
14
|
-
return
|
|
15
|
-
const
|
|
16
|
-
return i.data.
|
|
12
|
+
const l = n.aes[s];
|
|
13
|
+
if (!W(l))
|
|
14
|
+
return l;
|
|
15
|
+
const r = l.value, t = m[r], g = o[i.data.indexes[0]], h = p[r][g];
|
|
16
|
+
return i.data.indexes.every((d) => h === p[r][o[d]]) ? t(String(h))[s] : t.unknown()[s];
|
|
17
17
|
}
|
|
18
18
|
const L = { x: 0, y: 0 };
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
function
|
|
22
|
-
return
|
|
19
|
+
function C({ dendrograms: s, sideElementBBoxes: i, xDataByKeys: n, yDataByKeys: o, xGroupKeys: p, yGroupKeys: m, aesScales: l }) {
|
|
20
|
+
const r = s.x.data, t = s.y.data, g = r ? i[r.position].dendro : L, h = t ? i[t.position].dendro : L;
|
|
21
|
+
function d(c, u) {
|
|
22
|
+
return D(c, u, r, p, n, l);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
24
|
+
function $(c, u) {
|
|
25
|
+
return D(c, u, t, m, o, l);
|
|
26
26
|
}
|
|
27
27
|
return /* @__PURE__ */ a.jsxs("g", { children: [
|
|
28
|
-
/* @__PURE__ */ a.jsx("g", { transform: `translate(${
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
28
|
+
/* @__PURE__ */ a.jsx("g", { transform: `translate(${g.x},${g.y})`, children: r && !r.hidden && p.map((c, u) => {
|
|
29
|
+
const x = s.x.treesByGroupKey[c];
|
|
30
|
+
if (!x)
|
|
31
31
|
return null;
|
|
32
|
-
const
|
|
32
|
+
const f = x.links(), j = x.descendants();
|
|
33
33
|
return /* @__PURE__ */ a.jsxs("g", { children: [
|
|
34
|
-
|
|
35
|
-
const
|
|
34
|
+
f.map((e, y) => {
|
|
35
|
+
const S = r.edgeInheritance === "up" ? e.source : e.target;
|
|
36
36
|
return /* @__PURE__ */ a.jsx(
|
|
37
37
|
"path",
|
|
38
38
|
{
|
|
39
|
-
d:
|
|
40
|
-
stroke:
|
|
41
|
-
strokeWidth:
|
|
42
|
-
strokeDasharray: k(
|
|
39
|
+
d: K(e, r.position),
|
|
40
|
+
stroke: d("lineColor", S),
|
|
41
|
+
strokeWidth: d("lineWidth", S),
|
|
42
|
+
strokeDasharray: k(d("lineShape", S)),
|
|
43
43
|
fill: "none"
|
|
44
44
|
},
|
|
45
|
-
`${e.source.x},${e.source.y},${e.target.x},${e.target.y}`
|
|
45
|
+
`${e.source.x},${e.source.y},${e.target.x},${e.target.y},${y}`
|
|
46
46
|
);
|
|
47
47
|
}),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
) }, `${e.x},${e.y}`))
|
|
53
|
-
] },
|
|
48
|
+
r.showNodes && j.map((e, y) => /* @__PURE__ */ a.jsx("g", { transform: `translate(${e.x},${e.y})`, children: B(
|
|
49
|
+
d("dotShape", e),
|
|
50
|
+
d("dotSize", e),
|
|
51
|
+
d("dotFill", e)
|
|
52
|
+
) }, `${e.x},${e.y},${y}}`))
|
|
53
|
+
] }, u);
|
|
54
54
|
}) }),
|
|
55
|
-
/* @__PURE__ */ a.jsx("g", { transform: `translate(${
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
55
|
+
/* @__PURE__ */ a.jsx("g", { transform: `translate(${h.x},${h.y})`, children: t && !t.hidden && m.map((c, u) => {
|
|
56
|
+
const x = s.y.treesByGroupKey[c];
|
|
57
|
+
if (!x)
|
|
58
58
|
return null;
|
|
59
|
-
const
|
|
59
|
+
const f = x.links(), j = x.descendants();
|
|
60
60
|
return /* @__PURE__ */ a.jsxs("g", { children: [
|
|
61
|
-
|
|
62
|
-
const y =
|
|
61
|
+
f.map((e) => {
|
|
62
|
+
const y = t.edgeInheritance === "up" ? e.source : e.target;
|
|
63
63
|
return /* @__PURE__ */ a.jsx(
|
|
64
64
|
"path",
|
|
65
65
|
{
|
|
66
|
-
d:
|
|
67
|
-
stroke:
|
|
68
|
-
strokeWidth:
|
|
69
|
-
strokeDasharray: k(
|
|
66
|
+
d: K(e, t.position),
|
|
67
|
+
stroke: $("lineColor", y),
|
|
68
|
+
strokeWidth: $("lineWidth", y),
|
|
69
|
+
strokeDasharray: k($("lineShape", y)),
|
|
70
70
|
fill: "none"
|
|
71
71
|
},
|
|
72
72
|
`${e.source.x},${e.source.y},${e.target.x},${e.target.y}`
|
|
73
73
|
);
|
|
74
74
|
}),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
t.showNodes && j.map((e) => /* @__PURE__ */ a.jsx("g", { transform: `translate(${e.x},${e.y})`, children: B(
|
|
76
|
+
$("dotShape", e),
|
|
77
|
+
$("dotSize", e),
|
|
78
|
+
$("dotFill", e)
|
|
79
79
|
) }, `${e.x},${e.y}`))
|
|
80
|
-
] },
|
|
80
|
+
] }, u);
|
|
81
81
|
}) })
|
|
82
82
|
] });
|
|
83
83
|
}
|
|
84
84
|
export {
|
|
85
|
-
|
|
85
|
+
C as Dendrograms
|
|
86
86
|
};
|
|
87
87
|
//# sourceMappingURL=Dendrograms.js.map
|
package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Dendrograms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dendrograms.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Dendrograms.tsx"],"sourcesContent":["import type {ChartDendrograms, ChartDimensionsData, Cluster, DendrogramAesScales} from './types';\nimport type {HeatmapDendrogramSettings, HeatmapSettingsImpl} from '../HeatmapSettingsImpl';\nimport type {DataValue} from '../../types';\nimport type {LineShape, PointShape} from '../../types';\nimport {isColumnName} from '../../utils';\nimport {getLineShape} from '../../utils/getLineShape';\nimport {getPointShape} from '../../utils/getPointShape';\nimport type {HierarchyPointLink, HierarchyPointNode} from 'd3-hierarchy';\nimport React from 'react';\n\nfunction getLinkPath(link: HierarchyPointLink<Cluster>, position = 'top'): string {\n const {source, target} = link;\n if (position === 'top' || position === 'bottom') {\n return `M ${source.x},${source.y} L ${target.x},${source.y} L${target.x},${target.y}`;\n }\n return `M ${source.x},${source.y} L ${source.x},${target.y} L${target.x},${target.y}`;\n}\n\nfunction getAes<ValueType>(\n field: keyof HeatmapDendrogramSettings['aes'],\n node: HierarchyPointNode<Cluster>,\n dendrogram: HeatmapSettingsImpl['dendrogramX' | 'dendrogramY'],\n data: Record<string, Record<string, DataValue>>,\n aesScales: DendrogramAesScales\n): ValueType {\n if (!dendrogram) {\n return '' as ValueType;\n }\n const value = dendrogram.aes[field];\n if (!isColumnName(value)) {\n return value as ValueType;\n }\n const columnName = value.value;\n const scale = aesScales[columnName];\n const valueByFirstKey = data[columnName][node.data.keys[0]];\n if (node.data.keys.every(key => valueByFirstKey === data[columnName][key])) {\n return scale(String(valueByFirstKey))[field] as ValueType;\n } else {\n return scale.unknown()[field] as ValueType;\n }\n}\n\nconst EMPTY_BBOX = {x: 0, y: 0, width: 0, height: 0};\n\ninterface DendrogramProps {\n dendrograms: ChartDendrograms;\n sideElementBBoxes: ChartDimensionsData['sideElementBBoxes'];\n xDataByKeys: Record<string, Record<string, DataValue>>;\n yDataByKeys: Record<string, Record<string, DataValue>>;\n xGroupKeys: string[];\n yGroupKeys: string[];\n aesScales: DendrogramAesScales;\n}\n\nexport function Dendrograms({dendrograms, sideElementBBoxes, xDataByKeys, yDataByKeys, xGroupKeys, yGroupKeys, aesScales}: DendrogramProps) {\n const dataX = dendrograms.x.data;\n const dataY = dendrograms.y.data;\n const dendroXBBox = dataX ? sideElementBBoxes[dataX.position].dendro : EMPTY_BBOX;\n const dendroYBBox = dataY ? sideElementBBoxes[dataY.position].dendro : EMPTY_BBOX;\n\n function aesGetterX<ValueType>(field: keyof HeatmapDendrogramSettings['aes'], node: HierarchyPointNode<Cluster>) {\n return getAes<ValueType>(field, node, dataX, xDataByKeys, aesScales);\n }\n function aesGetterY<ValueType>(field: keyof HeatmapDendrogramSettings['aes'], node: HierarchyPointNode<Cluster>) {\n return getAes<ValueType>(field, node, dataY, yDataByKeys, aesScales);\n }\n return (\n <g>\n <g transform={`translate(${dendroXBBox.x},${dendroXBBox.y})`}>\n {dataX && !dataX.hidden && xGroupKeys.map((xKey, idx) => {\n const root = dendrograms.x.treesByGroupKey[xKey];\n if (!root) {\n return null;\n }\n const links = root.links();\n const nodes = root.descendants();\n return (\n <g key={idx}>\n {links.map(link => {\n const node = dataX.edgeInheritance === 'up' ? link.source : link.target;\n return (\n <path\n key={`${link.source.x},${link.source.y},${link.target.x},${link.target.y}`}\n d={getLinkPath(link, dataX.position)}\n stroke={aesGetterX<string>('lineColor', node)}\n strokeWidth={aesGetterX<number>('lineWidth', node)}\n strokeDasharray={getLineShape(aesGetterX<LineShape>('lineShape', node))}\n fill=\"none\"\n />\n );\n })}\n {dataX.showNodes &&\n nodes.map(node => (\n <g key={`${node.x},${node.y}`} transform={`translate(${node.x},${node.y})`}>\n {getPointShape(\n aesGetterX<PointShape>('dotShape', node),\n aesGetterX<number>('dotSize', node),\n aesGetterX<string>('dotFill', node)\n )}\n </g>\n ))}\n </g>\n );\n })}\n </g>\n <g transform={`translate(${dendroYBBox.x},${dendroYBBox.y})`}>\n {dataY && !dataY.hidden && yGroupKeys.map((yKey, idx) => {\n const root = dendrograms.y.treesByGroupKey[yKey];\n if (!root) {\n return null;\n }\n const links = root.links();\n const nodes = root.descendants();\n return (\n <g key={idx}>\n {links.map(link => {\n const node = dataY.edgeInheritance === 'up' ? link.source : link.target;\n return (\n <path\n key={`${link.source.x},${link.source.y},${link.target.x},${link.target.y}`}\n d={getLinkPath(link, dataY.position)}\n stroke={aesGetterY<string>('lineColor', node)}\n strokeWidth={aesGetterY<number>('lineWidth', node)}\n strokeDasharray={getLineShape(aesGetterY<LineShape>('lineShape', node))}\n fill=\"none\"\n />\n );\n })}\n {dataY.showNodes &&\n nodes.map(node => (\n <g key={`${node.x},${node.y}`} transform={`translate(${node.x},${node.y})`}>\n {getPointShape(\n aesGetterY<PointShape>('dotShape', node),\n aesGetterY<number>('dotSize', node),\n aesGetterY<string>('dotFill', node)\n )}\n </g>\n ))}\n </g>\n );\n })}\n </g>\n </g>\n );\n}\n"],"names":["getLinkPath","link","position","source","target","getAes","field","node","dendrogram","data","aesScales","value","isColumnName","columnName","scale","valueByFirstKey","key","EMPTY_BBOX","Dendrograms","dendrograms","sideElementBBoxes","xDataByKeys","yDataByKeys","xGroupKeys","yGroupKeys","dataX","dataY","dendroXBBox","dendroYBBox","aesGetterX","aesGetterY","a","jsx","xKey","idx","root","links","nodes","getLineShape","t","getPointShape","yKey"],"mappings":";;;;AAUA,SAASA,EAAYC,GAAmCC,IAAW,OAAe;AAC9E,QAAM,EAAC,QAAAC,GAAQ,QAAAC,MAAUH;AACzB,SAAIC,MAAa,SAASA,MAAa,WAC5B,KAAKC,EAAO,CAAC,IAAIA,EAAO,CAAC,MAAMC,EAAO,CAAC,I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ACH;AAAA,MAAA,EAAA,GAvBD2B,CAwBR;AAAA,IAER,CAAC,GACL;AAAA,EAAA,GACJ;AAER;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"Dendrograms.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Dendrograms.tsx"],"sourcesContent":["import type {ChartDendrograms, ChartDimensionsData, Cluster, DendrogramAesScales} from './types';\nimport type {HeatmapDendrogramSettings, HeatmapSettingsImpl} from '../HeatmapSettingsImpl';\nimport type {DataValue} from '../../types';\nimport type {LineShape, PointShape} from '../../types';\nimport {isColumnName} from '../../utils';\nimport {getLineShape} from '../../utils/getLineShape';\nimport {getPointShape} from '../../utils/getPointShape';\nimport type {HierarchyPointLink, HierarchyPointNode} from 'd3-hierarchy';\nimport React from 'react';\n\nfunction getLinkPath(link: HierarchyPointLink<Cluster>, position = 'top'): string {\n const {source, target} = link;\n if (position === 'top' || position === 'bottom') {\n return `M ${source.x},${source.y} L ${target.x},${source.y} L${target.x},${target.y}`;\n }\n return `M ${source.x},${source.y} L ${source.x},${target.y} L${target.x},${target.y}`;\n}\n\nfunction getAes<ValueType>(\n field: keyof HeatmapDendrogramSettings['aes'],\n node: HierarchyPointNode<Cluster>,\n dendrogram: HeatmapSettingsImpl['dendrogramX' | 'dendrogramY'],\n keys: string[],\n data: Record<string, Record<string, DataValue>>,\n aesScales: DendrogramAesScales\n): ValueType {\n if (!dendrogram) {\n return '' as ValueType;\n }\n const value = dendrogram.aes[field];\n if (!isColumnName(value)) {\n return value as ValueType;\n }\n const columnName = value.value;\n const scale = aesScales[columnName];\n const firstKey = keys[node.data.indexes[0]];\n const valueByFirstKey = data[columnName][firstKey];\n if (node.data.indexes.every(index => valueByFirstKey === data[columnName][keys[index]])) {\n return scale(String(valueByFirstKey))[field] as ValueType;\n } else {\n return scale.unknown()[field] as ValueType;\n }\n}\n\nconst EMPTY_BBOX = {x: 0, y: 0, width: 0, height: 0};\n\ninterface DendrogramProps {\n dendrograms: ChartDendrograms;\n sideElementBBoxes: ChartDimensionsData['sideElementBBoxes'];\n xDataByKeys: Record<string, Record<string, DataValue>>;\n yDataByKeys: Record<string, Record<string, DataValue>>;\n xGroupKeys: string[];\n yGroupKeys: string[];\n aesScales: DendrogramAesScales;\n}\n\nexport function Dendrograms({dendrograms, sideElementBBoxes, xDataByKeys, yDataByKeys, xGroupKeys, yGroupKeys, aesScales}: DendrogramProps) {\n const dataX = dendrograms.x.data;\n const dataY = dendrograms.y.data;\n const dendroXBBox = dataX ? sideElementBBoxes[dataX.position].dendro : EMPTY_BBOX;\n const dendroYBBox = dataY ? sideElementBBoxes[dataY.position].dendro : EMPTY_BBOX;\n\n function aesGetterX<ValueType>(field: keyof HeatmapDendrogramSettings['aes'], node: HierarchyPointNode<Cluster>) {\n return getAes<ValueType>(field, node, dataX, xGroupKeys, xDataByKeys, aesScales);\n }\n function aesGetterY<ValueType>(field: keyof HeatmapDendrogramSettings['aes'], node: HierarchyPointNode<Cluster>) {\n return getAes<ValueType>(field, node, dataY, yGroupKeys, yDataByKeys, aesScales);\n }\n return (\n <g>\n <g transform={`translate(${dendroXBBox.x},${dendroXBBox.y})`}>\n {dataX && !dataX.hidden && xGroupKeys.map((xKey, idx) => {\n const root = dendrograms.x.treesByGroupKey[xKey];\n if (!root) {\n return null;\n }\n const links = root.links();\n const nodes = root.descendants();\n return (\n <g key={idx}>\n {links.map((link, idx) => {\n const node = dataX.edgeInheritance === 'up' ? link.source : link.target;\n return (\n <path\n key={`${link.source.x},${link.source.y},${link.target.x},${link.target.y},${idx}`}\n d={getLinkPath(link, dataX.position)}\n stroke={aesGetterX<string>('lineColor', node)}\n strokeWidth={aesGetterX<number>('lineWidth', node)}\n strokeDasharray={getLineShape(aesGetterX<LineShape>('lineShape', node))}\n fill=\"none\"\n />\n );\n })}\n {dataX.showNodes &&\n nodes.map((node, idx) => (\n <g key={`${node.x},${node.y},${idx}}`} transform={`translate(${node.x},${node.y})`}>\n {getPointShape(\n aesGetterX<PointShape>('dotShape', node),\n aesGetterX<number>('dotSize', node),\n aesGetterX<string>('dotFill', node)\n )}\n </g>\n ))}\n </g>\n );\n })}\n </g>\n <g transform={`translate(${dendroYBBox.x},${dendroYBBox.y})`}>\n {dataY && !dataY.hidden && yGroupKeys.map((yKey, idx) => {\n const root = dendrograms.y.treesByGroupKey[yKey];\n if (!root) {\n return null;\n }\n const links = root.links();\n const nodes = root.descendants();\n return (\n <g key={idx}>\n {links.map(link => {\n const node = dataY.edgeInheritance === 'up' ? link.source : link.target;\n return (\n <path\n key={`${link.source.x},${link.source.y},${link.target.x},${link.target.y}`}\n d={getLinkPath(link, dataY.position)}\n stroke={aesGetterY<string>('lineColor', node)}\n strokeWidth={aesGetterY<number>('lineWidth', node)}\n strokeDasharray={getLineShape(aesGetterY<LineShape>('lineShape', node))}\n fill=\"none\"\n />\n );\n })}\n {dataY.showNodes &&\n nodes.map(node => (\n <g key={`${node.x},${node.y}`} transform={`translate(${node.x},${node.y})`}>\n {getPointShape(\n aesGetterY<PointShape>('dotShape', node),\n aesGetterY<number>('dotSize', node),\n aesGetterY<string>('dotFill', node)\n )}\n </g>\n ))}\n </g>\n );\n })}\n </g>\n </g>\n );\n}\n"],"names":["getLinkPath","link","position","source","target","getAes","field","node","dendrogram","keys","data","aesScales","value","isColumnName","columnName","scale","firstKey","valueByFirstKey","index","EMPTY_BBOX","Dendrograms","dendrograms","sideElementBBoxes","xDataByKeys","yDataByKeys","xGroupKeys","yGroupKeys","dataX","dataY","dendroXBBox","dendroYBBox","aesGetterX","aesGetterY","a","jsx","xKey","idx","root","links","nodes","getLineShape","getPointShape","yKey","t"],"mappings":";;;;AAUA,SAASA,EAAYC,GAAmCC,IAAW,OAAe;AAC9E,QAAM,EAAC,QAAAC,GAAQ,QAAAC,MAAUH;AACzB,SAAIC,MAAa,SAASA,MAAa,WAC5B,KAAKC,EAAO,CAAC,IAAIA,EAAO,CAAC,MAAMC,EAAO,CAAC,IAAID,EAAO,CAAC,KAAKC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