@milaboratories/graph-maker 1.1.135 → 1.1.137
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 +2 -0
- package/dist/GraphMaker/constantsCommon.d.ts.map +1 -1
- package/dist/GraphMaker/constantsCommon.js +19 -17
- 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 +144 -122
- package/dist/GraphMaker/forms/AxesSettingsForm/HeatmapAxesSettingsForm.vue.js.map +1 -1
- package/dist/GraphMaker/index.vue.js +72 -72
- package/dist/GraphMaker/index.vue.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/getAxesDataFromForms.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/getAxesDataFromForms.js +9 -9
- package/dist/GraphMaker/utils/createChartSettingsForRender/getAxesDataFromForms.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js +246 -228
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Captions/GroupCaptions.js +46 -37
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Captions/GroupCaptions.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js +63 -61
- 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 +4 -4
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Dendrograms.js +57 -51
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Dendrograms.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getDendrograms.js +33 -33
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getDendrograms.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js +20 -20
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateCaptionTails.js +89 -54
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateCaptionTails.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateChartSideElementSizes.js +19 -19
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateChartSideElementSizes.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ChartRenderer.js +181 -168
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartsGroup.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartsGroup.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/index.js +5 -5
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/Lasso.js +144 -120
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/Lasso.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/LowerSVG.js +35 -35
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/LowerSVG.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/index.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/index.js +235 -242
- package/dist/node_modules/@milaboratories/pf-plots/dist/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/pl-model-common/dist/index.js +218 -163
- package/dist/node_modules/@milaboratories/pl-model-common/dist/index.js.map +1 -1
- package/dist/node_modules/@platforma-sdk/model/dist/index.js +89 -80
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartRenderer.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/ChartRenderer.tsx"],"sourcesContent":["import {Error} from '../common/Error';\nimport {DEFAULT_AES} from './constants';\nimport type {\n AnnotationColorScales,\n CaptionsSizes,\n ChartDendrograms,\n ChartDimensionsData,\n ChartSizes,\n ChartsScales,\n Cluster,\n DendrogramAesScales,\n LabelAngles,\n Margins,\n} from './components/types';\nimport type {GroupedCellsData} from './getCells';\nimport type {DendrogramsData} from './getDendrograms';\nimport type {HeatmapSettingsImpl} from './HeatmapSettingsImpl';\nimport {\n calculateAnnotationTitleSizes,\n calculateChartSideElementSizes,\n calculateSideElementsBBoxes,\n createContinuousColorScale,\n createDiscreteColorScale,\n} from './utils';\nimport {calculateCaptionTails} from './utils/calculateCaptionTails';\nimport type {AesItem, ColumnName, DataValue} from '../types';\nimport {getChartEdgeSides} from '../utils/getChartEdgeSides';\nimport {getContinuousLegendTicks} from '../utils/getContinuousLegendTicks';\nimport {extent} from 'd3-array';\nimport type {HierarchyNode, HierarchyPointNode} from 'd3-hierarchy';\nimport {cluster} from 'd3-hierarchy';\nimport type {ScaleLinear, ScaleOrdinal} from 'd3-scale';\nimport {scaleLinear, scaleOrdinal} from 'd3-scale';\nimport lodash from 'lodash';\nimport {CHART_SIDE_ELEMENTS, LEGEND_OFFSET, MIN_MARGIN, MIN_PADDING, TITLE_LINE} from './constants';\nimport {DEFAULT_HEIGHT, DEFAULT_WIDTH, TITLE_LINE_HEIGHT, TITLE_MARGIN} from '../constants';\nimport type {ReactElement} from 'react';\nimport React from 'react';\nimport type {Root} from 'react-dom/client';\nimport {createRoot} from 'react-dom/client';\nimport {ChartsGroup} from './components/ChartsGroup';\nimport {TextMeasurer} from '../utils/TextMeasurer';\nimport type { LegendData, LegendItem } from '../common/types';\nimport { arrangeLegendParts } from '../utils/arrangeLegendParts';\n\nfunction updateLinksHeight(root: HierarchyPointNode<Cluster>, scale: (v: number) => number, coord: 'x' | 'y') {\n function setHeight(d: HierarchyPointNode<Cluster>) {\n d[coord] = scale(d.data.height);\n if (d.children) d.children.forEach(setHeight);\n }\n setHeight(root);\n}\n\n// add shift to move nodes positions with group gaps\nfunction addShiftToLinkCoord(\n root: HierarchyPointNode<Cluster>,\n shift: number,\n coordFrom: 'x' | 'y',\n coordTo = coordFrom\n) {\n function setX(d: HierarchyPointNode<Cluster>) {\n d[coordTo] = d[coordFrom] + shift;\n if (d.children) d.children.forEach(setX);\n }\n setX(root);\n}\n\nconst getSteps = (count: number, valueExtent: number[]) => {\n const min = Math.min(...valueExtent);\n const max = Math.max(...valueExtent);\n if (min === max) {\n const steps = count % 2 === 0 ? [] : [min];\n for (let i = 1; i < count / 2 + 1; i++) {\n steps.push(min + i);\n steps.unshift(min - i);\n }\n return steps;\n }\n if (count < 2) {\n return [min, max];\n }\n const step = (max - min) / (count - 1);\n const steps = [];\n for (let i = 0; i < count - 1; i++) {\n steps.push(min + step * i);\n }\n steps.push(max);\n return steps;\n};\n\nfunction getContinuousColorRange(normalization:HeatmapSettingsImpl['normalization'], colorsCount: number, valueExtent: number[]) {\n let extent = valueExtent;\n if (normalization) {\n if (normalization.colorRange) {\n extent = normalization.colorRange;\n }\n if (normalization.method === 'standardScaling') {\n extent = [-2, 2];\n }\n if (normalization.method === 'meanNormalization') {\n extent = [-0.75, 0.75];\n }\n }\n return getSteps(colorsCount, extent);\n}\n\nclass ChartRenderer {\n reactRoot: Root | null = null;\n parentNode: HTMLElement | null = null;\n rootNode: HTMLElement | null = null;\n component: ReactElement = (<></>);\n chartsDimensions: Record<string, ChartDimensionsData> = {};\n chartSizes: ChartSizes = {\n chartWidth: DEFAULT_WIDTH, // width of single chart\n chartHeight: DEFAULT_HEIGHT, // height of single chart\n chartsWidth: DEFAULT_WIDTH, // width of all charts in charts row\n chartsHeight: DEFAULT_HEIGHT, // width of all charts in charts column, without axes\n totalWidth: DEFAULT_WIDTH, // width of all charts in charts row, plus left axis, plus legend\n totalHeight: DEFAULT_HEIGHT, // width of all charts in charts height, plus bottom axis, plus top title\n };\n margins: Margins = {\n top: MIN_MARGIN,\n bottom: MIN_MARGIN,\n left: MIN_MARGIN,\n right: MIN_MARGIN,\n };\n captionsSizes: CaptionsSizes = {\n xAxisCaptions: 100,\n yAxisCaptions: 100,\n xGroupCaptions: TITLE_LINE,\n yGroupCaptions: TITLE_LINE,\n xCaptionTail: 0,\n yCaptionTail: 0,\n };\n labelAngles: LabelAngles = {\n xAxisLabels: 0,\n yAxisLabels: 0,\n xGroupLabels: 0,\n yGroupLabels: 0,\n };\n columnsCount = 1;\n rowsCount = 1;\n scales: ChartsScales = {\n // scales grouped by facet\n x: {null: scaleOrdinal<string, number>().domain(['null']).range([1])},\n y: {null: scaleOrdinal<string, number>().domain(['null']).range([1])},\n };\n step: {\n x: Record<string, number>;\n y: Record<string, number>;\n } = {x: {}, y: {}};\n colorScale: ScaleLinear<string, string> | ScaleOrdinal<string, string, string> = scaleLinear<string, string>()\n .domain([0, 1])\n .range(['white', 'black']);\n annotationColorScales: AnnotationColorScales = {};\n dendrogramAesScales: DendrogramAesScales = {};\n legend: LegendData = {\n width: 0,\n height: 0,\n items: [],\n };\n dendrograms: Record<string, ChartDendrograms> = {};\n\n clear() {\n if (this.parentNode && this.rootNode) {\n this.parentNode?.removeChild(this.rootNode);\n this.parentNode = null;\n this.rootNode = null;\n }\n // timeout to avoid trying to unmount during rendering\n setTimeout(() => {\n this.reactRoot?.unmount();\n this.reactRoot = null;\n });\n }\n\n init(node: HTMLElement) {\n if (this.parentNode === null) {\n this.parentNode = node;\n this.rootNode = document.createElement('div');\n this.parentNode.appendChild(this.rootNode);\n this.reactRoot = createRoot(this.rootNode);\n }\n }\n\n updateMargins(title: HeatmapSettingsImpl['chartSettings']['title']) {\n this.margins = {\n top: title.show ? TITLE_LINE_HEIGHT + TITLE_MARGIN * 2 : MIN_MARGIN,\n bottom: MIN_MARGIN,\n left: MIN_MARGIN,\n right: this.legend.width + MIN_MARGIN,\n };\n this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartsWidth + this.margins.right;\n this.chartSizes.totalHeight =\n this.margins.top + Math.max(this.chartSizes.chartsHeight + this.margins.bottom, this.legend.height);\n }\n\n updateLegendSize(\n valueType: HeatmapSettingsImpl['chartSettings']['valueType'],\n legend: HeatmapSettingsImpl['chartSettings']['legend'],\n annotations: HeatmapSettingsImpl['annotations'],\n columnValue: ColumnName,\n valueExtent: [number, number]\n ) {\n if (!legend.show) {\n this.legend = {width: 0, height: 0, items: []};\n return;\n }\n const legendHeight = this.chartSizes.chartHeight;\n const legendItems: LegendItem[] = [];\n const emptySizes = {width:0, height:0, left:0, top: 0};\n \n const getDefaultLabels = (values:(string|number)[]) => values.reduce((res:Record<string, string>, v:string|number) => {res[v] = String(v); return res;}, {});\n if (valueType === 'continuous') {\n const scale = this.colorScale as ScaleLinear<string, string>;\n const values = getContinuousLegendTicks(scale, valueExtent);\n const tickPositionScale = scaleLinear([values[0], values[values.length - 1]], [legendHeight, 0]); //TODO: update during adding log scale for heatmap\n const title = columnValue.label ?? columnValue.value;\n legendItems.push({\n ...emptySizes,\n type: 'continuous',\n id: 'heatmapValue',\n scale,\n values,\n title,\n tickPositionScale\n });\n } else if (valueType === 'discrete') {\n const scale = this.colorScale as ScaleOrdinal<string, string>;\n const title = columnValue.label ?? columnValue.value;\n const values = scale.domain();\n const labels = getDefaultLabels(values);\n\n legendItems.push({...emptySizes, type: 'discreteColor', id: 'heatmapValue', title, scale, values, labels });\n }\n annotations.forEach(item => {\n const title = item.valueColumn.label ?? item.valueColumn.value;\n if (item.type === 'continuous') {\n const scale = this.annotationColorScales[item.id].scale as ScaleLinear<string, string>;\n const values = getContinuousLegendTicks(scale, valueExtent);\n const tickPositionScale = scaleLinear([values[0], values[values.length - 1]], [legendHeight, 0]); //TODO: update during adding log scale for heatmap\n\n legendItems.push({...emptySizes, type: 'continuous', id: item.id, tickPositionScale, title, scale, values});\n }\n if (item.type === 'discrete') {\n const scale = this.annotationColorScales[item.id].scale as ScaleOrdinal<string, string>;\n const values = scale.domain();\n const labels = getDefaultLabels(values);\n\n legendItems.push({...emptySizes, type: 'discreteColor', id: item.id, title, scale, values, labels });\n }\n });\n\n if (!legendItems.length) {\n this.legend = {width: 0, height: 0, items: []};\n return;\n }\n\n const items = arrangeLegendParts(legendItems, this.chartSizes.chartHeight);\n const lastItem = items[items.length - 1];\n const legendWidth = lastItem.left + lastItem.width + LEGEND_OFFSET;\n\n this.legend = {\n width: legendWidth,\n height: legendHeight,\n items\n };\n }\n\n updateCaptionsSize(\n groupedCells: GroupedCellsData,\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n facetSettings: HeatmapSettingsImpl['facetSettings']\n ) {\n const textMeasurer = new TextMeasurer('bold 14px Arial');\n const {xGroupKeys, yGroupKeys, xGroupLabels, yGroupLabels, xKeysByGroups, yKeysByGroups, xLabels, yLabels} = groupedCells.meta;\n this.labelAngles = {\n xAxisLabels: xAxis.axisLabelsAngle,\n yAxisLabels: yAxis.axisLabelsAngle,\n xGroupLabels: xAxis.groupLabelsAngle,\n yGroupLabels: yAxis.groupLabelsAngle,\n };\n // check auto-rotations, if some labels longer then width of cells group or cell\n // facetKeys.forEach((facetKey) => {\n // const stepX = this.step.x[facetKey];\n // const stepY = this.step.y[facetKey];\n // const facetGroup = groupedCells.groups[facetKey];\n // const {xKeysByGroups, yKeysByGroups} = facetGroup;\n //\n // // if some group has title longer than width of its cells, title should be rotated\n // if (xGroupKeys.some((key) => textMeasurer.getTextWidth(key) > xKeysByGroups[key].length * stepX)) {\n // this.captionsAngles.xGroupCaptions = 90;\n // }\n // if (yGroupKeys.some((key) => textMeasurer.getTextWidth(key) > yKeysByGroups[key].length * stepY)) {\n // this.captionsAngles.yGroupCaptions = 90;\n // }\n // // if some axis cell label longer than cell width/height, label should be rotated\n // if (xGroupKeys.some((key) => xKeysByGroups[key].some((xKey) => textMeasurer.getTextWidth(xKey) > stepX))) {\n // this.captionsAngles.xAxisCaptions = 90;\n // }\n // if (yGroupKeys.some((key) => yKeysByGroups[key].some((yKey) => textMeasurer.getTextWidth(yKey) > stepY))) {\n // this.captionsAngles.yAxisCaptions = 90;\n // }\n // });\n function getMaxTextLength (keys:string[], labels:Record<string, string>) {\n let maxLabelSize = 0;\n for (const key of keys) {\n const l = textMeasurer.getTextWidth(labels[key]);\n if (l > maxLabelSize) {\n maxLabelSize = l;\n }\n }\n return maxLabelSize;\n }\n const xKeys = lodash.flatten(Object.values(xKeysByGroups));\n const yKeys = lodash.flatten(Object.values(yKeysByGroups));\n\n const maxXLabelSize = getMaxTextLength(xKeys, xLabels);\n const maxYLabelSize = getMaxTextLength(yKeys, yLabels);\n const maxXGroupLabelSize = getMaxTextLength(xGroupKeys, xGroupLabels);\n const maxYGroupLabelSize = getMaxTextLength(yGroupKeys, yGroupLabels);\n const {xCaptionTail, yCaptionTail} = calculateCaptionTails(\n this.labelAngles,\n facetSettings,\n this.step,\n groupedCells,\n textMeasurer\n );\n const xGroupAngle = (this.labelAngles.xGroupLabels / 180) * Math.PI;\n const yGroupAngle = (this.labelAngles.yGroupLabels / 180) * Math.PI;\n const xLabelAngle = (this.labelAngles.xAxisLabels / 180) * Math.PI;\n const yLabelAngle = (this.labelAngles.yAxisLabels / 180) * Math.PI;\n this.captionsSizes = {\n xCaptionTail,\n yCaptionTail,\n xGroupCaptions: maxXGroupLabelSize * Math.sin(xGroupAngle) || TITLE_LINE,\n yGroupCaptions: maxYGroupLabelSize * Math.sin(yGroupAngle) || TITLE_LINE,\n xAxisCaptions: maxXLabelSize * Math.sin(xLabelAngle) || TITLE_LINE,\n yAxisCaptions: maxYLabelSize * Math.sin(yLabelAngle) || TITLE_LINE,\n };\n }\n\n updateChartDimensions(\n size: HeatmapSettingsImpl['chartSettings']['size'],\n facetKeys: string[],\n xGroupKeys: string[],\n yGroupKeys: string[],\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY']\n ) {\n const facetCount = facetKeys.length;\n const maxNRows = Math.min(facetSettings.nRows ?? facetCount, facetCount);\n const maxNCols = Math.min(facetSettings.nCols ?? facetCount, facetCount);\n // Use columns/rows count from settings if some of them defined, else make 1 column\n this.columnsCount = facetSettings.nRows ? Math.ceil(facetCount / maxNRows) : maxNCols;\n this.rowsCount = Math.ceil(facetCount / this.columnsCount);\n const {width, height} = size;\n const {sharedX, sharedY} = facetSettings;\n\n this.chartsDimensions = {};\n\n let currentLeft = 0;\n let currentTop = 0;\n facetKeys.forEach((key, index) => {\n const currentColumn = (index % this.columnsCount) + 1;\n const chartSides = getChartEdgeSides(index, facetKeys.length, this.columnsCount, this.rowsCount);\n const stepX = this.step.x[key];\n const stepY = this.step.y[key];\n const sideElementSizes = calculateChartSideElementSizes(\n xAxis,\n yAxis,\n this.captionsSizes,\n annotations,\n dendrogramX,\n dendrogramY,\n chartSides,\n sharedX,\n sharedY,\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n stepX,\n stepY\n );\n const annotationsTitleSizes = calculateAnnotationTitleSizes(annotations, chartSides, sharedX, sharedY);\n function getPadding(side: 'left' | 'right' | 'top' | 'bottom') {\n return Math.max(\n CHART_SIDE_ELEMENTS[side].reduce((res, el) => res + sideElementSizes[side][el], 0),\n annotationsTitleSizes[side],\n MIN_PADDING\n );\n }\n const padding = {\n left: getPadding('left'),\n right: getPadding('right'),\n top: getPadding('top'),\n bottom: getPadding('bottom'),\n };\n if (padding.left < this.captionsSizes.xCaptionTail) {\n padding.left = this.captionsSizes.xCaptionTail;\n }\n if (padding.bottom < this.captionsSizes.yCaptionTail) {\n padding.bottom = this.captionsSizes.yCaptionTail;\n }\n const sideElementBBoxes = calculateSideElementsBBoxes(sideElementSizes, width, height);\n const outerWidth = width + padding.left + padding.right;\n const outerHeight = height + padding.top + padding.bottom;\n this.chartsDimensions[key] = {\n left: currentLeft,\n top: currentTop,\n inner: {width, height},\n outer: {width: outerWidth, height: outerHeight},\n padding,\n sideElementBBoxes,\n chartEdgeSides: chartSides,\n };\n currentLeft += outerWidth;\n if (currentColumn === this.columnsCount) {\n currentLeft = 0;\n currentTop += outerHeight;\n }\n });\n\n // sum of widths of first row\n const chartsWidth = facetKeys\n .slice(0, this.columnsCount)\n .reduce((sum, key) => sum + this.chartsDimensions[key].outer.width, 0);\n // sum of heights of first column\n const chartsHeight = facetKeys\n .filter((_key, index) => index % this.columnsCount === 0)\n .reduce((sum, key) => sum + this.chartsDimensions[key].outer.height, 0);\n this.chartSizes.chartsWidth = chartsWidth;\n this.chartSizes.chartsHeight = chartsHeight;\n }\n\n updateChartsSizes(size: HeatmapSettingsImpl['chartSettings']['size']) {\n const {width, height} = size;\n this.chartSizes.chartWidth = width;\n this.chartSizes.chartHeight = height;\n }\n\n // update scales for cell positions, x and y for each facet\n updateScales(\n facetKeys: string[],\n groupedCells: GroupedCellsData,\n groupGap: number,\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n size: HeatmapSettingsImpl['chartSettings']['size'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n ) {\n const {width, height} = size;\n const {meta, facets} = groupedCells;\n const {sharedX, sharedY} = facetSettings;\n const sortX = (arr: string[], labels: Record<string, string> = {}) => {\n return arr.sort((a, b) => xAxis.sorting === 'asc'\n ? (labels[a] ?? a).localeCompare((labels[b] ?? b), 'en', {numeric: true})\n : (labels[b] ?? b).localeCompare((labels[a] ?? a), 'en', {numeric: true})\n );\n };\n const sortY = (arr: string[], labels: Record<string, string> = {}) => {\n return arr.sort((a, b) => yAxis.sorting === 'asc'\n ? (labels[a] ?? a).localeCompare((labels[b] ?? b), 'en', {numeric: true})\n : (labels[b] ?? b).localeCompare((labels[a] ?? a), 'en', {numeric: true})\n );\n };\n facetKeys.forEach(facetKey => {\n const facetGroup = facets[facetKey];\n const xGroupKeys = sortX(meta.xGroupKeys);\n const yGroupKeys = sortY(meta.yGroupKeys);\n const {xKeysByGroups} = sharedX ? meta : facetGroup;\n const {yKeysByGroups} = sharedY ? meta : facetGroup;\n // for shared facets max cells counts in group should be used\n const xCounts = xGroupKeys.map(xGroupKey => xKeysByGroups[xGroupKey].length);\n const yCounts = yGroupKeys.map(yGroupKey => yKeysByGroups[yGroupKey].length);\n const xCellsCount = xCounts.reduce((sum, count) => sum + count, 0);\n const yCellsCount = yCounts.reduce((sum, count) => sum + count, 0);\n const xStep = (width - (xCounts.filter(count => count > 0).length - 1) * groupGap) / xCellsCount;\n const yStep = (height - (yCounts.filter(count => count > 0).length - 1) * groupGap) / yCellsCount;\n\n const xPositions: number[] = [];\n const xKeys: string[] = [];\n let currentX = 0;\n xGroupKeys.forEach(xKey => {\n const axisKeys = dendrogramX ? xKeysByGroups[xKey] : sortX(xKeysByGroups[xKey], meta.xLabels);\n xKeys.push(...axisKeys);\n axisKeys.forEach(() => {\n xPositions.push(currentX);\n currentX += xStep;\n });\n // do not add offset for empty group\n if (axisKeys.length > 0) {\n currentX += groupGap;\n }\n });\n\n const yPositions: number[] = [];\n const yKeys: string[] = [];\n let currentY = 0;\n yGroupKeys.forEach(yKey => {\n const axisKeys = dendrogramY ? yKeysByGroups[yKey] : sortY(yKeysByGroups[yKey], meta.yLabels);\n yKeys.push(...axisKeys);\n axisKeys.forEach(() => {\n yPositions.push(currentY);\n currentY += yStep;\n });\n // do not add offset for empty group\n if (axisKeys.length > 0) {\n currentY += groupGap;\n }\n });\n\n this.scales.x[facetKey] = scaleOrdinal<string, number>().domain(xKeys).range(xPositions);\n this.scales.y[facetKey] = scaleOrdinal<string, number>().domain(yKeys).range(yPositions);\n this.step.x[facetKey] = xStep;\n this.step.y[facetKey] = yStep;\n });\n }\n\n updateAesScale(\n valueType: 'discrete' | 'continuous',\n valueExtent: [number, number],\n aes: HeatmapSettingsImpl['aes'],\n annotations: HeatmapSettingsImpl['annotations'],\n groupedCellsData: GroupedCellsData,\n cellUniqValues: DataValue[],\n normalization: HeatmapSettingsImpl['normalization']\n ) {\n if (valueType === 'continuous') {\n if (aes.valueColors) {\n this.colorScale = scaleLinear<string, string>()\n .domain(aes.valuesByColors ?? getContinuousColorRange(normalization, aes.valueColors.length, valueExtent))\n .range(aes.valueColors);\n } else if (aes.colorsList) {\n this.colorScale = scaleLinear<string, string>()\n .domain(getContinuousColorRange(normalization, aes.colorsList.length, valueExtent))\n .range(aes.colorsList);\n }\n } else {\n if (aes.colorsMap) {\n const valueKeys = Object.entries(aes.colorsMap);\n this.colorScale = scaleOrdinal<string, string>()\n .domain(valueKeys.map(v => v[0]))\n .range(valueKeys.map(v => v[1]))\n .unknown('#ccc');\n } else if (aes.colorsList) {\n this.colorScale = createDiscreteColorScale(aes.colorsList, cellUniqValues.map(String));\n }\n }\n\n const {xDataByKeys, yDataByKeys} = groupedCellsData.meta;\n annotations.forEach(item => {\n const {colors, type, axis, valueColumn} = item;\n const data = (axis === 'x' ? xDataByKeys : yDataByKeys)[valueColumn.value];\n if (type === 'discrete') {\n const discreteValues = lodash.uniq(Object.values(data).map(String)).sort();\n this.annotationColorScales[item.id] = {\n type: 'discrete',\n scale: createDiscreteColorScale(colors, discreteValues),\n };\n } else {\n const values = Object.values(data).map(Number);\n if (!values.length) {\n return;\n }\n const [min = values[0], max = values[0]] = extent(values);\n this.annotationColorScales[item.id] = {\n type: 'continuous',\n scale: createContinuousColorScale(colors, min, max, 0, 0.5, 1),\n };\n }\n });\n }\n\n updateDendrogram(\n facetKeys: string[],\n xGroupKeys: string[],\n yGroupKeys: string[],\n groups: GroupedCellsData['facets'],\n dendrogramsData: DendrogramsData,\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY']\n ) {\n facetKeys.forEach(facetKey => {\n this.dendrograms[facetKey] = {x: {trees: [], data: dendrogramX}, y: {trees: [], data: dendrogramY}};\n const {xKeysByGroups, yKeysByGroups} = groups[facetKey];\n const {hierarchyX, hierarchyY} = dendrogramsData[facetKey];\n const maxHeightX = Math.max(...hierarchyX.map(root => root.data.height));\n const maxHeightY = Math.max(...hierarchyY.map(root => root.data.height));\n if (dendrogramX) {\n this.dendrograms[facetKey].x.trees = hierarchyX.map((hierarchy, idx) => {\n const groupKey = xGroupKeys[idx];\n const xKeys = xKeysByGroups[groupKey];\n cluster()\n .separation(() => 1)\n .size([xKeys.length * this.step.x[facetKey], dendrogramX.size])(\n hierarchy as HierarchyNode<unknown>\n );\n const root = hierarchy as HierarchyPointNode<Cluster>;\n const heightScale = scaleLinear()\n .domain(dendrogramX.position === 'top' ? [0, maxHeightX] : [maxHeightX, 0])\n .range([dendrogramX.size, 0]);\n updateLinksHeight(root, heightScale, 'y');\n addShiftToLinkCoord(root, this.scales.x[facetKey](xKeys[0]), 'x');\n return root;\n });\n this.dendrograms[facetKey].x.data = dendrogramX;\n }\n if (dendrogramY) {\n this.dendrograms[facetKey].y.trees = hierarchyY.map((hierarchy, idx) => {\n const groupKey = yGroupKeys[idx];\n const yKeys = yKeysByGroups[groupKey];\n cluster()\n .separation(() => 1)\n .size([yKeys.length * this.step.y[facetKey], dendrogramY.size])(\n hierarchy as HierarchyNode<unknown>\n );\n const root = hierarchy as HierarchyPointNode<Cluster>;\n const heightScale = scaleLinear()\n .domain(dendrogramY.position === 'left' ? [0, maxHeightY] : [maxHeightY, 0])\n .range([dendrogramY.size, 0]);\n addShiftToLinkCoord(root, this.scales.y[facetKey](yKeys[0]), 'x', 'y');\n updateLinksHeight(root, heightScale, 'x');\n return root;\n });\n this.dendrograms[facetKey].y.data = dendrogramY;\n }\n });\n }\n\n updateDendrogramAesScales(inheritedAes: HeatmapSettingsImpl['inheritedDendrogramAes']) {\n if (!inheritedAes) {\n return;\n }\n const usedColumns = Object.keys(inheritedAes);\n this.dendrogramAesScales = usedColumns.reduce((res: DendrogramAesScales, columnName) => {\n const aesMap = inheritedAes[columnName];\n const columnValues: string[] = Object.keys(aesMap);\n res[columnName] = scaleOrdinal<string, AesItem, AesItem>()\n .domain(columnValues)\n .range(\n columnValues.map(value => ({\n ...DEFAULT_AES,\n ...aesMap[value],\n }))\n )\n .unknown(DEFAULT_AES);\n return res;\n }, {});\n }\n\n render(\n settingsId: string,\n chartSettings: HeatmapSettingsImpl['chartSettings'],\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n aes: HeatmapSettingsImpl['aes'],\n groupedCellsData: GroupedCellsData,\n annotations: HeatmapSettingsImpl['annotations'],\n valueColumn: ColumnName,\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n dendrogramsData: DendrogramsData,\n inheritedDendrogramAes: HeatmapSettingsImpl['inheritedDendrogramAes'],\n cellUniqValues: DataValue[],\n normalization: HeatmapSettingsImpl['normalization'],\n onTooltipHintSwitch: (v:boolean) => void\n ) {\n const {meta, facets} = groupedCellsData;\n const {facetKeys, xGroupKeys, yGroupKeys, valueExtent} = meta;\n const {xAxis, yAxis, title, size, valueType} = chartSettings;\n this.updateChartsSizes(size);\n this.updateAesScale(valueType, valueExtent, aes, annotations, groupedCellsData, cellUniqValues, normalization);\n this.updateScales(facetKeys, groupedCellsData, aes.groupGap, facetSettings, size, chartSettings.xAxis, chartSettings.yAxis, dendrogramX, dendrogramY);\n // caption sizes are needed for chart paddings in chart dimensions\n this.updateCaptionsSize(groupedCellsData, xAxis, yAxis, facetSettings);\n this.updateChartDimensions(\n size,\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n facetSettings,\n xAxis,\n yAxis,\n annotations,\n dendrogramX,\n dendrogramY\n );\n this.updateLegendSize(valueType, chartSettings.legend, annotations, valueColumn, valueExtent);\n this.updateMargins(title);\n this.updateDendrogram(facetKeys, xGroupKeys, yGroupKeys, facets, dendrogramsData, dendrogramX, dendrogramY);\n this.updateDendrogramAesScales(inheritedDendrogramAes);\n const component = (\n <ChartsGroup\n aes={aes}\n annotations={annotations}\n annotationColorScales={this.annotationColorScales}\n captionsSizes={this.captionsSizes}\n cellsMeta={meta}\n columnsCount={this.columnsCount}\n chartsDimensions={this.chartsDimensions}\n chartSettings={chartSettings}\n chartSizes={this.chartSizes}\n colorScale={this.colorScale as (v: unknown) => string}\n dendrogramAesScales={this.dendrogramAesScales}\n dendrograms={this.dendrograms}\n facetKeys={facetKeys}\n facetSettings={facetSettings}\n groupedCells={facets}\n labelAngles={this.labelAngles}\n legend={this.legend}\n margins={this.margins}\n scales={this.scales}\n settingsId={settingsId}\n step={this.step}\n xGroupKeys={xGroupKeys}\n yGroupKeys={yGroupKeys}\n onTooltipHintSwitch={onTooltipHintSwitch}\n />\n );\n this.component = component;\n this.reactRoot?.render(component);\n }\n\n renderError(message: string) {\n this.reactRoot?.render(<Error message={message} />);\n }\n}\n\nexport default ChartRenderer;\n"],"names":["updateLinksHeight","root","scale","coord","setHeight","d","addShiftToLinkCoord","shift","coordFrom","coordTo","setX","getSteps","count","valueExtent","min","max","steps","i","step","getContinuousColorRange","normalization","colorsCount","extent","ChartRenderer","__publicField","jsx","Fragment","DEFAULT_WIDTH","DEFAULT_HEIGHT","MIN_MARGIN","TITLE_LINE","scaleOrdinal","scaleLinear","_a","node","createRoot","title","TITLE_LINE_HEIGHT","TITLE_MARGIN","valueType","legend","annotations","columnValue","legendHeight","legendItems","emptySizes","getDefaultLabels","values","res","v","getContinuousLegendTicks","tickPositionScale","labels","item","items","arrangeLegendParts","lastItem","legendWidth","LEGEND_OFFSET","groupedCells","xAxis","yAxis","facetSettings","textMeasurer","TextMeasurer","xGroupKeys","yGroupKeys","xGroupLabels","yGroupLabels","xKeysByGroups","yKeysByGroups","xLabels","yLabels","getMaxTextLength","keys","maxLabelSize","key","l","xKeys","lodash","yKeys","maxXLabelSize","maxYLabelSize","maxXGroupLabelSize","maxYGroupLabelSize","xCaptionTail","yCaptionTail","calculateCaptionTails","xGroupAngle","yGroupAngle","xLabelAngle","yLabelAngle","size","facetKeys","dendrogramX","dendrogramY","facetCount","maxNRows","maxNCols","width","height","sharedX","sharedY","currentLeft","currentTop","index","currentColumn","chartSides","getChartEdgeSides","stepX","stepY","sideElementSizes","calculateChartSideElementSizes","annotationsTitleSizes","calculateAnnotationTitleSizes","getPadding","side","CHART_SIDE_ELEMENTS","el","MIN_PADDING","padding","sideElementBBoxes","calculateSideElementsBBoxes","outerWidth","outerHeight","chartsWidth","sum","chartsHeight","_key","groupGap","meta","facets","sortX","arr","a","b","sortY","facetKey","facetGroup","xCounts","L","xGroupKey","yCounts","yGroupKey","xCellsCount","yCellsCount","xStep","yStep","xPositions","currentX","xKey","axisKeys","yPositions","currentY","yKey","aes","groupedCellsData","cellUniqValues","valueKeys","createDiscreteColorScale","xDataByKeys","yDataByKeys","colors","type","axis","valueColumn","data","discreteValues","createContinuousColorScale","groups","dendrogramsData","hierarchyX","hierarchyY","maxHeightX","maxHeightY","hierarchy","idx","groupKey","cluster","heightScale","inheritedAes","usedColumns","columnName","aesMap","columnValues","value","DEFAULT_AES","settingsId","chartSettings","inheritedDendrogramAes","onTooltipHintSwitch","component","ChartsGroup","message","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6CA,SAASA,EAAkBC,GAAmCC,GAA8BC,GAAkB;AAC1G,WAASC,EAAUC,GAAgC;AAC/CA,MAAEF,CAAK,IAAID,EAAMG,EAAE,KAAK,MAAM,GAC1BA,EAAE,YAAUA,EAAE,SAAS,QAAQD,CAAS;AAAA,EAChD;AACAA,EAAAA,EAAUH,CAAI;AAClB;AAGA,SAASK,EACLL,GACAM,GACAC,GACAC,IAAUD,GACZ;AACE,WAASE,EAAKL,GAAgC;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AAA,MAACuK;AAAAA,MAAA;AAAA,QACG,KAAArC;AAAAA,QACA,aAAAlH;AAAAA,QACA,uBAAuB,KAAK;AAAA,QAC5B,eAAe,KAAK;AAAA,QACpB,WAAWyF;AAAAA,QACX,cAAc,KAAK;AAAA,QACnB,kBAAkB,KAAK;AAAA,QACvB,eAAA0D;AAAAA,QACA,YAAY,KAAK;AAAA,QACjB,YAAY,KAAK;AAAA,QACjB,qBAAqB,KAAK;AAAA,QAC1B,aAAa,KAAK;AAAA,QAClB,WAAA/F;AAAAA,QACA,eAAA/B;AAAAA,QACA,cAAcqE;AAAAA,QACd,aAAa,KAAK;AAAA,QAClB,QAAQ,KAAK;AAAA,QACb,SAAS,KAAK;AAAA,QACd,QAAQ,KAAK;AAAA,QACb,YAAAwD;AAAAA,QACA,MAAM,KAAK;AAAA,QACX,YAAA1H;AAAAA,QACA,YAAAC;AAAAA,QACA,qBAAA4H;AAAAA,MAAA;AAAA,IAAA;AAGR,SAAK,YAAYC,IACjB9J,IAAA,KAAK,cAAL,QAAAA,EAAgB,OAAO8J,CAAAA;AAAAA,EAC3B;AAAA,EAEA,YAAYE,GAAiB;;AACzB,KAAAhK,IAAA,KAAK,cAAL,QAAAA,EAAgB,OAAOR,gBAAAA,EAAAA,IAACyK,IAAA,EAAM,SAAAD,EAAAA,CAAkB,CAAA;AAAA,EACpD;AACJ;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"ChartRenderer.js","sources":["../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/ChartRenderer.tsx"],"sourcesContent":["import {Error} from '../common/Error';\nimport {DEFAULT_AES} from './constants';\nimport type {\n AnnotationColorScales,\n CaptionsSizes,\n ChartDendrograms,\n ChartDimensionsData,\n ChartSizes,\n ChartsScales,\n Cluster,\n DendrogramAesScales,\n LabelAngles,\n Margins,\n} from './components/types';\nimport type {GroupedCellsData} from './getCells';\nimport type {DendrogramsData} from './getDendrograms';\nimport type {HeatmapSettingsImpl} from './HeatmapSettingsImpl';\nimport {\n calculateAnnotationTitleSizes,\n calculateChartSideElementSizes,\n calculateSideElementsBBoxes,\n createContinuousColorScale,\n createDiscreteColorScale,\n} from './utils';\nimport {calculateCaptionTails} from './utils/calculateCaptionTails';\nimport type {AesItem, ColumnName, DataValue} from '../types';\nimport {getChartEdgeSides} from '../utils/getChartEdgeSides';\nimport {getContinuousLegendTicks} from '../utils/getContinuousLegendTicks';\nimport {extent} from 'd3-array';\nimport type {HierarchyNode, HierarchyPointNode} from 'd3-hierarchy';\nimport {cluster} from 'd3-hierarchy';\nimport type {ScaleLinear, ScaleOrdinal} from 'd3-scale';\nimport {scaleLinear, scaleOrdinal} from 'd3-scale';\nimport lodash from 'lodash';\nimport {CHART_SIDE_ELEMENTS, LEGEND_OFFSET, MIN_MARGIN, MIN_PADDING, TITLE_LINE} from './constants';\nimport {DEFAULT_HEIGHT, DEFAULT_WIDTH, TITLE_LINE_HEIGHT, TITLE_MARGIN} from '../constants';\nimport type {ReactElement} from 'react';\nimport React from 'react';\nimport type {Root} from 'react-dom/client';\nimport {createRoot} from 'react-dom/client';\nimport {ChartsGroup} from './components/ChartsGroup';\nimport {TextMeasurer} from '../utils/TextMeasurer';\nimport type { LegendData, LegendItem } from '../common/types';\nimport { arrangeLegendParts } from '../utils/arrangeLegendParts';\n\nconst COS_PI_4 = Math.cos(Math.PI / 4);\nconst INCLINE_OFFSET = 5; // height of little triangle of text for captions inclined 45deg\nfunction updateLinksHeight(root: HierarchyPointNode<Cluster>, scale: (v: number) => number, coord: 'x' | 'y') {\n function setHeight(d: HierarchyPointNode<Cluster>) {\n d[coord] = scale(d.data.height);\n if (d.children) d.children.forEach(setHeight);\n }\n setHeight(root);\n}\n\n// add shift to move nodes positions with group gaps\nfunction addShiftToLinkCoord(\n root: HierarchyPointNode<Cluster>,\n shift: number,\n coordFrom: 'x' | 'y',\n coordTo = coordFrom\n) {\n function setX(d: HierarchyPointNode<Cluster>) {\n d[coordTo] = d[coordFrom] + shift;\n if (d.children) d.children.forEach(setX);\n }\n setX(root);\n}\n\nconst getSteps = (count: number, valueExtent: number[]) => {\n const min = Math.min(...valueExtent);\n const max = Math.max(...valueExtent);\n if (min === max) {\n const steps = count % 2 === 0 ? [] : [min];\n for (let i = 1; i < count / 2 + 1; i++) {\n steps.push(min + i);\n steps.unshift(min - i);\n }\n return steps;\n }\n if (count < 2) {\n return [min, max];\n }\n const step = (max - min) / (count - 1);\n const steps = [];\n for (let i = 0; i < count - 1; i++) {\n steps.push(min + step * i);\n }\n steps.push(max);\n return steps;\n};\n\nfunction getContinuousColorRange(normalization:HeatmapSettingsImpl['normalization'], colorsCount: number, valueExtent: number[]) {\n let extent = valueExtent;\n if (normalization) {\n if (normalization.colorRange) {\n extent = normalization.colorRange;\n }\n if (normalization.method === 'standardScaling') {\n extent = [-2, 2];\n }\n if (normalization.method === 'meanNormalization') {\n extent = [-0.75, 0.75];\n }\n }\n return getSteps(colorsCount, extent);\n}\n\nfunction getMaxTextLength (keys:string[], labels:Record<string, string>, textMeasurer: TextMeasurer) {\n let maxLabelSize = 0;\n for (const key of keys) {\n const l = textMeasurer.getTextWidth(labels[key]);\n if (l > maxLabelSize) {\n maxLabelSize = l;\n }\n }\n return maxLabelSize;\n}\n\nfunction getCaptionHeight (size:number, angle:number) {\n if (angle === 90) {\n return size;\n }\n if (angle === 45) {\n return size * COS_PI_4 + (size > 0 ? 2 * INCLINE_OFFSET : 0) ;\n }\n return TITLE_LINE;\n}\n\nclass ChartRenderer {\n reactRoot: Root | null = null;\n parentNode: HTMLElement | null = null;\n rootNode: HTMLElement | null = null;\n component: ReactElement = (<></>);\n chartsDimensions: Record<string, ChartDimensionsData> = {};\n chartSizes: ChartSizes = {\n chartWidth: DEFAULT_WIDTH, // width of single chart\n chartHeight: DEFAULT_HEIGHT, // height of single chart\n chartsWidth: DEFAULT_WIDTH, // width of all charts in charts row\n chartsHeight: DEFAULT_HEIGHT, // width of all charts in charts column, without axes\n totalWidth: DEFAULT_WIDTH, // width of all charts in charts row, plus left axis, plus legend\n totalHeight: DEFAULT_HEIGHT, // width of all charts in charts height, plus bottom axis, plus top title\n };\n margins: Margins = {\n top: MIN_MARGIN,\n bottom: MIN_MARGIN,\n left: MIN_MARGIN,\n right: MIN_MARGIN,\n };\n captionsSizes: CaptionsSizes = {\n xAxisCaptions: 100,\n yAxisCaptions: 100,\n xGroupCaptions: TITLE_LINE,\n yGroupCaptions: TITLE_LINE,\n xCaptionTail: 0,\n yCaptionTail: 0,\n };\n labelAngles: LabelAngles = {\n xAxisLabels: 0,\n yAxisLabels: 0,\n xGroupLabels: 0,\n yGroupLabels: 0,\n };\n columnsCount = 1;\n rowsCount = 1;\n scales: ChartsScales = {\n // scales grouped by facet\n x: {null: scaleOrdinal<string, number>().domain(['null']).range([1])},\n y: {null: scaleOrdinal<string, number>().domain(['null']).range([1])},\n };\n step: {\n x: Record<string, number>;\n y: Record<string, number>;\n } = {x: {}, y: {}};\n colorScale: ScaleLinear<string, string> | ScaleOrdinal<string, string, string> = scaleLinear<string, string>()\n .domain([0, 1])\n .range(['white', 'black']);\n annotationColorScales: AnnotationColorScales = {};\n dendrogramAesScales: DendrogramAesScales = {};\n legend: LegendData = {\n width: 0,\n height: 0,\n items: [],\n };\n dendrograms: Record<string, ChartDendrograms> = {};\n\n clear() {\n if (this.parentNode && this.rootNode) {\n this.parentNode?.removeChild(this.rootNode);\n this.parentNode = null;\n this.rootNode = null;\n }\n // timeout to avoid trying to unmount during rendering\n setTimeout(() => {\n this.reactRoot?.unmount();\n this.reactRoot = null;\n });\n }\n\n init(node: HTMLElement) {\n if (this.parentNode === null) {\n this.parentNode = node;\n this.rootNode = document.createElement('div');\n this.parentNode.appendChild(this.rootNode);\n this.reactRoot = createRoot(this.rootNode);\n }\n }\n\n updateMargins(title: HeatmapSettingsImpl['chartSettings']['title']) {\n this.margins = {\n top: title.show ? TITLE_LINE_HEIGHT + TITLE_MARGIN * 2 : MIN_MARGIN,\n bottom: MIN_MARGIN,\n left: MIN_MARGIN,\n right: this.legend.width + MIN_MARGIN,\n };\n this.chartSizes.totalWidth = this.margins.left + this.chartSizes.chartsWidth + this.margins.right;\n this.chartSizes.totalHeight =\n this.margins.top + Math.max(this.chartSizes.chartsHeight + this.margins.bottom, this.legend.height);\n }\n\n updateLegendSize(\n valueType: HeatmapSettingsImpl['chartSettings']['valueType'],\n legend: HeatmapSettingsImpl['chartSettings']['legend'],\n annotations: HeatmapSettingsImpl['annotations'],\n columnValue: ColumnName,\n valueExtent: [number, number]\n ) {\n if (!legend.show) {\n this.legend = {width: 0, height: 0, items: []};\n return;\n }\n const legendHeight = this.chartSizes.chartHeight;\n const legendItems: LegendItem[] = [];\n const emptySizes = {width:0, height:0, left:0, top: 0};\n \n const getDefaultLabels = (values:(string|number)[]) => values.reduce((res:Record<string, string>, v:string|number) => {res[v] = String(v); return res;}, {});\n if (valueType === 'continuous') {\n const scale = this.colorScale as ScaleLinear<string, string>;\n const values = getContinuousLegendTicks(scale, valueExtent);\n const tickPositionScale = scaleLinear([values[0], values[values.length - 1]], [legendHeight, 0]); //TODO: update during adding log scale for heatmap\n const title = columnValue.label ?? columnValue.value;\n legendItems.push({\n ...emptySizes,\n type: 'continuous',\n id: 'heatmapValue',\n scale,\n values,\n title,\n tickPositionScale\n });\n } else if (valueType === 'discrete') {\n const scale = this.colorScale as ScaleOrdinal<string, string>;\n const title = columnValue.label ?? columnValue.value;\n const values = scale.domain();\n const labels = getDefaultLabels(values);\n\n legendItems.push({...emptySizes, type: 'discreteColor', id: 'heatmapValue', title, scale, values, labels });\n }\n annotations.forEach(item => {\n const title = item.valueColumn.label ?? item.valueColumn.value;\n if (item.type === 'continuous') {\n const scale = this.annotationColorScales[item.id].scale as ScaleLinear<string, string>;\n const values = getContinuousLegendTicks(scale, valueExtent);\n const tickPositionScale = scaleLinear([values[0], values[values.length - 1]], [legendHeight, 0]); //TODO: update during adding log scale for heatmap\n\n legendItems.push({...emptySizes, type: 'continuous', id: item.id, tickPositionScale, title, scale, values});\n }\n if (item.type === 'discrete') {\n const scale = this.annotationColorScales[item.id].scale as ScaleOrdinal<string, string>;\n const values = scale.domain();\n const labels = getDefaultLabels(values);\n\n legendItems.push({...emptySizes, type: 'discreteColor', id: item.id, title, scale, values, labels });\n }\n });\n\n if (!legendItems.length) {\n this.legend = {width: 0, height: 0, items: []};\n return;\n }\n\n const items = arrangeLegendParts(legendItems, this.chartSizes.chartHeight);\n const lastItem = items[items.length - 1];\n const legendWidth = lastItem.left + lastItem.width + LEGEND_OFFSET;\n\n this.legend = {\n width: legendWidth,\n height: legendHeight,\n items\n };\n }\n\n updateCaptionsSize(\n groupedCells: GroupedCellsData,\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n facetSettings: HeatmapSettingsImpl['facetSettings']\n ) {\n const textMeasurer = new TextMeasurer('bold 16px Manrope');\n const {xGroupKeys, yGroupKeys, xGroupLabels, yGroupLabels, xKeysByGroups, yKeysByGroups, xLabels, yLabels} = groupedCells.meta;\n this.labelAngles = {\n xAxisLabels: xAxis.axisLabelsAngle,\n yAxisLabels: yAxis.axisLabelsAngle,\n xGroupLabels: xAxis.groupLabelsAngle,\n yGroupLabels: yAxis.groupLabelsAngle,\n };\n\n const maxXLabelSize = xGroupKeys.reduce((res, key) => Math.max(res, getMaxTextLength(xKeysByGroups[key], xLabels, textMeasurer)), 0) ;\n const maxYLabelSize = yGroupKeys.reduce((res, key) => Math.max(res, getMaxTextLength(yKeysByGroups[key], yLabels, textMeasurer)), 0) ;\n const maxXGroupLabelSize = getMaxTextLength(xGroupKeys, xGroupLabels, textMeasurer);\n const maxYGroupLabelSize = getMaxTextLength(yGroupKeys, yGroupLabels, textMeasurer);\n const {xCaptionTail, yCaptionTail} = calculateCaptionTails(\n this.labelAngles,\n facetSettings,\n this.scales,\n this.step,\n groupedCells,\n textMeasurer\n );\n this.captionsSizes = {\n xCaptionTail,\n yCaptionTail,\n xGroupCaptions: getCaptionHeight(maxXGroupLabelSize, this.labelAngles.xGroupLabels),\n yGroupCaptions: getCaptionHeight(maxYGroupLabelSize, this.labelAngles.yGroupLabels),\n xAxisCaptions: getCaptionHeight(maxXLabelSize, this.labelAngles.xAxisLabels),\n yAxisCaptions: getCaptionHeight(maxYLabelSize, this.labelAngles.yAxisLabels),\n };\n }\n\n updateChartDimensions(\n size: HeatmapSettingsImpl['chartSettings']['size'],\n facetKeys: string[],\n xGroupKeys: string[],\n yGroupKeys: string[],\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY']\n ) {\n const facetCount = facetKeys.length;\n const maxNRows = Math.min(facetSettings.nRows ?? facetCount, facetCount);\n const maxNCols = Math.min(facetSettings.nCols ?? facetCount, facetCount);\n // Use columns/rows count from settings if some of them defined, else make 1 column\n this.columnsCount = facetSettings.nRows ? Math.ceil(facetCount / maxNRows) : maxNCols;\n this.rowsCount = Math.ceil(facetCount / this.columnsCount);\n const {width, height} = size;\n const {sharedX, sharedY} = facetSettings;\n\n this.chartsDimensions = {};\n\n let currentLeft = 0;\n let currentTop = 0;\n facetKeys.forEach((key, index) => {\n const currentColumn = (index % this.columnsCount) + 1;\n const chartSides = getChartEdgeSides(index, facetKeys.length, this.columnsCount, this.rowsCount);\n const stepX = this.step.x[key];\n const stepY = this.step.y[key];\n const sideElementSizes = calculateChartSideElementSizes(\n xAxis,\n yAxis,\n this.captionsSizes,\n annotations,\n dendrogramX,\n dendrogramY,\n chartSides,\n sharedX,\n sharedY,\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n stepX,\n stepY\n );\n const annotationsTitleSizes = calculateAnnotationTitleSizes(annotations, chartSides, sharedX, sharedY);\n function getPadding(side: 'left' | 'right' | 'top' | 'bottom') {\n return Math.max(\n CHART_SIDE_ELEMENTS[side].reduce((res, el) => res + sideElementSizes[side][el], 0),\n annotationsTitleSizes[side],\n MIN_PADDING\n );\n }\n const padding = {\n left: getPadding('left'),\n right: getPadding('right'),\n top: getPadding('top'),\n bottom: getPadding('bottom'),\n };\n if (padding.left < this.captionsSizes.xCaptionTail) {\n padding.left = this.captionsSizes.xCaptionTail;\n }\n if (padding.bottom < this.captionsSizes.yCaptionTail) {\n padding.bottom = this.captionsSizes.yCaptionTail;\n }\n const sideElementBBoxes = calculateSideElementsBBoxes(sideElementSizes, width, height);\n const outerWidth = width + padding.left + padding.right;\n const outerHeight = height + padding.top + padding.bottom;\n this.chartsDimensions[key] = {\n left: currentLeft,\n top: currentTop,\n inner: {width, height},\n outer: {width: outerWidth, height: outerHeight},\n padding,\n sideElementBBoxes,\n chartEdgeSides: chartSides,\n };\n currentLeft += outerWidth;\n if (currentColumn === this.columnsCount) {\n currentLeft = 0;\n currentTop += outerHeight;\n }\n });\n\n // sum of widths of first row\n const chartsWidth = facetKeys\n .slice(0, this.columnsCount)\n .reduce((sum, key) => sum + this.chartsDimensions[key].outer.width, 0);\n // sum of heights of first column\n const chartsHeight = facetKeys\n .filter((_key, index) => index % this.columnsCount === 0)\n .reduce((sum, key) => sum + this.chartsDimensions[key].outer.height, 0);\n this.chartSizes.chartsWidth = chartsWidth;\n this.chartSizes.chartsHeight = chartsHeight;\n }\n\n updateChartsSizes(size: HeatmapSettingsImpl['chartSettings']['size']) {\n const {width, height} = size;\n this.chartSizes.chartWidth = width;\n this.chartSizes.chartHeight = height;\n }\n\n // update scales for cell positions, x and y for each facet\n updateScales(\n facetKeys: string[],\n groupedCells: GroupedCellsData,\n groupGap: number,\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n size: HeatmapSettingsImpl['chartSettings']['size'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n ) {\n const {width, height} = size;\n const {meta, facets} = groupedCells;\n const {sharedX, sharedY} = facetSettings;\n const sortX = (arr: string[], labels: Record<string, string> = {}) => {\n return arr.sort((a, b) => xAxis.sorting === 'asc'\n ? (labels[a] ?? a).localeCompare((labels[b] ?? b), 'en', {numeric: true})\n : (labels[b] ?? b).localeCompare((labels[a] ?? a), 'en', {numeric: true})\n );\n };\n const sortY = (arr: string[], labels: Record<string, string> = {}) => {\n return arr.sort((a, b) => yAxis.sorting === 'asc'\n ? (labels[a] ?? a).localeCompare((labels[b] ?? b), 'en', {numeric: true})\n : (labels[b] ?? b).localeCompare((labels[a] ?? a), 'en', {numeric: true})\n );\n };\n facetKeys.forEach(facetKey => {\n const facetGroup = facets[facetKey];\n const xGroupKeys = sortX(meta.xGroupKeys);\n const yGroupKeys = sortY(meta.yGroupKeys);\n const {xKeysByGroups} = sharedX ? meta : facetGroup;\n const {yKeysByGroups} = sharedY ? meta : facetGroup;\n // for shared facets max cells counts in group should be used\n const xCounts = xGroupKeys.map(xGroupKey => xKeysByGroups[xGroupKey].length);\n const yCounts = yGroupKeys.map(yGroupKey => yKeysByGroups[yGroupKey].length);\n const xCellsCount = xCounts.reduce((sum, count) => sum + count, 0);\n const yCellsCount = yCounts.reduce((sum, count) => sum + count, 0);\n const xStep = (width - (xCounts.filter(count => count > 0).length - 1) * groupGap) / xCellsCount;\n const yStep = (height - (yCounts.filter(count => count > 0).length - 1) * groupGap) / yCellsCount;\n\n const xPositions: number[] = [];\n const xKeys: string[] = [];\n let currentX = 0;\n xGroupKeys.forEach(xKey => {\n const axisKeys = dendrogramX ? xKeysByGroups[xKey] : sortX(xKeysByGroups[xKey], meta.xLabels);\n xKeys.push(...axisKeys);\n axisKeys.forEach(() => {\n xPositions.push(currentX);\n currentX += xStep;\n });\n // do not add offset for empty group\n if (axisKeys.length > 0) {\n currentX += groupGap;\n }\n });\n\n const yPositions: number[] = [];\n const yKeys: string[] = [];\n let currentY = 0;\n yGroupKeys.forEach(yKey => {\n const axisKeys = dendrogramY ? yKeysByGroups[yKey] : sortY(yKeysByGroups[yKey], meta.yLabels);\n yKeys.push(...axisKeys);\n axisKeys.forEach(() => {\n yPositions.push(currentY);\n currentY += yStep;\n });\n // do not add offset for empty group\n if (axisKeys.length > 0) {\n currentY += groupGap;\n }\n });\n\n this.scales.x[facetKey] = scaleOrdinal<string, number>().domain(xKeys).range(xPositions);\n this.scales.y[facetKey] = scaleOrdinal<string, number>().domain(yKeys).range(yPositions);\n this.step.x[facetKey] = xStep;\n this.step.y[facetKey] = yStep;\n });\n }\n\n updateAesScale(\n valueType: 'discrete' | 'continuous',\n valueExtent: [number, number],\n aes: HeatmapSettingsImpl['aes'],\n annotations: HeatmapSettingsImpl['annotations'],\n groupedCellsData: GroupedCellsData,\n cellUniqValues: DataValue[],\n normalization: HeatmapSettingsImpl['normalization']\n ) {\n if (valueType === 'continuous') {\n if (aes.valueColors) {\n this.colorScale = scaleLinear<string, string>()\n .domain(aes.valuesByColors ?? getContinuousColorRange(normalization, aes.valueColors.length, valueExtent))\n .range(aes.valueColors);\n } else if (aes.colorsList) {\n this.colorScale = scaleLinear<string, string>()\n .domain(getContinuousColorRange(normalization, aes.colorsList.length, valueExtent))\n .range(aes.colorsList);\n }\n } else {\n if (aes.colorsMap) {\n const valueKeys = Object.entries(aes.colorsMap);\n this.colorScale = scaleOrdinal<string, string>()\n .domain(valueKeys.map(v => v[0]))\n .range(valueKeys.map(v => v[1]))\n .unknown('#ccc');\n } else if (aes.colorsList) {\n this.colorScale = createDiscreteColorScale(aes.colorsList, cellUniqValues.map(String));\n }\n }\n\n const {xDataByKeys, yDataByKeys} = groupedCellsData.meta;\n annotations.forEach(item => {\n const {colors, type, axis, valueColumn} = item;\n const data = (axis === 'x' ? xDataByKeys : yDataByKeys)[valueColumn.value];\n if (type === 'discrete') {\n const discreteValues = lodash.uniq(Object.values(data).map(String)).sort();\n this.annotationColorScales[item.id] = {\n type: 'discrete',\n scale: createDiscreteColorScale(colors, discreteValues),\n };\n } else {\n const values = Object.values(data).map(Number);\n if (!values.length) {\n return;\n }\n const [min = values[0], max = values[0]] = extent(values);\n this.annotationColorScales[item.id] = {\n type: 'continuous',\n scale: createContinuousColorScale(colors, min, max, 0, 0.5, 1),\n };\n }\n });\n }\n\n updateDendrogram(\n facetKeys: string[],\n xGroupKeys: string[],\n yGroupKeys: string[],\n groups: GroupedCellsData['facets'],\n dendrogramsData: DendrogramsData,\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY']\n ) {\n facetKeys.forEach(facetKey => {\n this.dendrograms[facetKey] = {x: {treesByGroupKey: {}, data: dendrogramX}, y: {treesByGroupKey: {}, data: dendrogramY}};\n const {xKeysByGroups, yKeysByGroups} = groups[facetKey];\n const {hierarchyByGroupX, hierarchyByGroupY} = dendrogramsData[facetKey];\n if (dendrogramX) {\n const maxHeightX = xGroupKeys.reduce((res, xKey) => Math.max(res, hierarchyByGroupX[xKey]?.data.height), 0);\n this.dendrograms[facetKey].x.treesByGroupKey = xGroupKeys.reduce((res, groupKey) => {\n const hierarchy = hierarchyByGroupX[groupKey];\n const xKeys = xKeysByGroups[groupKey];\n cluster()\n .separation(() => 1)\n .size([xKeys.length * this.step.x[facetKey], dendrogramX.size])(\n hierarchy as HierarchyNode<unknown>\n );\n const root = hierarchy as HierarchyPointNode<Cluster>;\n const heightScale = scaleLinear()\n .domain(dendrogramX.position === 'top' ? [0, maxHeightX] : [maxHeightX, 0])\n .range([dendrogramX.size, 0]);\n updateLinksHeight(root, heightScale, 'y');\n addShiftToLinkCoord(root, this.scales.x[facetKey](xKeys[0]), 'x');\n res[groupKey] = root;\n return res;\n }, {} as Record<string, HierarchyPointNode<Cluster>>);\n this.dendrograms[facetKey].x.data = dendrogramX;\n }\n if (dendrogramY) {\n const maxHeightY = yGroupKeys.reduce((res, yKey) => Math.max(res, hierarchyByGroupY[yKey]?.data.height), 0);\n this.dendrograms[facetKey].y.treesByGroupKey = yGroupKeys.reduce((res, groupKey) => {\n const hierarchy = hierarchyByGroupY[groupKey];\n const yKeys = yKeysByGroups[groupKey];\n cluster()\n .separation(() => 1)\n .size([yKeys.length * this.step.y[facetKey], dendrogramY.size])(\n hierarchy as HierarchyNode<unknown>\n );\n const root = hierarchy as HierarchyPointNode<Cluster>;\n const heightScale = scaleLinear()\n .domain(dendrogramY.position === 'left' ? [0, maxHeightY] : [maxHeightY, 0])\n .range([dendrogramY.size, 0]);\n addShiftToLinkCoord(root, this.scales.y[facetKey](yKeys[0]), 'x', 'y');\n updateLinksHeight(root, heightScale, 'x');\n res[groupKey] = root;\n return res;\n }, {} as Record<string, HierarchyPointNode<Cluster>>);\n this.dendrograms[facetKey].y.data = dendrogramY;\n }\n });\n }\n\n updateDendrogramAesScales(inheritedAes: HeatmapSettingsImpl['inheritedDendrogramAes']) {\n if (!inheritedAes) {\n return;\n }\n const usedColumns = Object.keys(inheritedAes);\n this.dendrogramAesScales = usedColumns.reduce((res: DendrogramAesScales, columnName) => {\n const aesMap = inheritedAes[columnName];\n const columnValues: string[] = Object.keys(aesMap);\n res[columnName] = scaleOrdinal<string, AesItem, AesItem>()\n .domain(columnValues)\n .range(\n columnValues.map(value => ({\n ...DEFAULT_AES,\n ...aesMap[value],\n }))\n )\n .unknown(DEFAULT_AES);\n return res;\n }, {});\n }\n\n render(\n settingsId: string,\n chartSettings: HeatmapSettingsImpl['chartSettings'],\n facetSettings: HeatmapSettingsImpl['facetSettings'],\n aes: HeatmapSettingsImpl['aes'],\n groupedCellsData: GroupedCellsData,\n annotations: HeatmapSettingsImpl['annotations'],\n valueColumn: ColumnName,\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n dendrogramsData: DendrogramsData,\n inheritedDendrogramAes: HeatmapSettingsImpl['inheritedDendrogramAes'],\n cellUniqValues: DataValue[],\n normalization: HeatmapSettingsImpl['normalization'],\n onTooltipHintSwitch: (v:boolean) => void\n ) {\n const {meta, facets} = groupedCellsData;\n const {facetKeys, xGroupKeys, yGroupKeys, valueExtent} = meta;\n const {xAxis, yAxis, title, size, valueType} = chartSettings;\n this.updateChartsSizes(size);\n this.updateAesScale(valueType, valueExtent, aes, annotations, groupedCellsData, cellUniqValues, normalization);\n this.updateScales(facetKeys, groupedCellsData, aes.groupGap, facetSettings, size, chartSettings.xAxis, chartSettings.yAxis, dendrogramX, dendrogramY);\n // caption sizes are needed for chart paddings in chart dimensions\n this.updateCaptionsSize(groupedCellsData, xAxis, yAxis, facetSettings);\n this.updateChartDimensions(\n size,\n facetKeys,\n xGroupKeys,\n yGroupKeys,\n facetSettings,\n xAxis,\n yAxis,\n annotations,\n dendrogramX,\n dendrogramY\n );\n this.updateLegendSize(valueType, chartSettings.legend, annotations, valueColumn, valueExtent);\n this.updateMargins(title);\n this.updateDendrogram(facetKeys, xGroupKeys, yGroupKeys, facets, dendrogramsData, dendrogramX, dendrogramY);\n this.updateDendrogramAesScales(inheritedDendrogramAes);\n const component = (\n <ChartsGroup\n aes={aes}\n annotations={annotations}\n annotationColorScales={this.annotationColorScales}\n captionsSizes={this.captionsSizes}\n cellsMeta={meta}\n columnsCount={this.columnsCount}\n chartsDimensions={this.chartsDimensions}\n chartSettings={chartSettings}\n chartSizes={this.chartSizes}\n colorScale={this.colorScale as (v: unknown) => string}\n dendrogramAesScales={this.dendrogramAesScales}\n dendrograms={this.dendrograms}\n facetKeys={facetKeys}\n facetSettings={facetSettings}\n groupedCells={facets}\n labelAngles={this.labelAngles}\n legend={this.legend}\n margins={this.margins}\n scales={this.scales}\n settingsId={settingsId}\n step={this.step}\n xGroupKeys={xGroupKeys}\n yGroupKeys={yGroupKeys}\n onTooltipHintSwitch={onTooltipHintSwitch}\n />\n );\n this.component = component;\n this.reactRoot?.render(component);\n }\n\n renderError(message: string) {\n this.reactRoot?.render(<Error message={message} />);\n }\n}\n\nexport default ChartRenderer;\n"],"names":["COS_PI_4","INCLINE_OFFSET","updateLinksHeight","root","scale","coord","setHeight","d","addShiftToLinkCoord","shift","coordFrom","coordTo","setX","getSteps","count","valueExtent","min","max","steps","i","step","getContinuousColorRange","normalization","colorsCount","extent","getMaxTextLength","keys","labels","textMeasurer","maxLabelSize","key","l","getCaptionHeight","size","angle","TITLE_LINE","ChartRenderer","__publicField","jsx","Fragment","DEFAULT_WIDTH","DEFAULT_HEIGHT","MIN_MARGIN","scaleOrdinal","scaleLinear","_a","node","createRoot","title","TITLE_LINE_HEIGHT","TITLE_MARGIN","valueType","legend","annotations","columnValue","legendHeight","legendItems","emptySizes","getDefaultLabels","values","res","v","getContinuousLegendTicks","tickPositionScale","item","items","arrangeLegendParts","lastItem","legendWidth","LEGEND_OFFSET","groupedCells","xAxis","yAxis","facetSettings","TextMeasurer","xGroupKeys","yGroupKeys","xGroupLabels","yGroupLabels","xKeysByGroups","yKeysByGroups","xLabels","yLabels","maxXLabelSize","maxYLabelSize","maxXGroupLabelSize","maxYGroupLabelSize","xCaptionTail","yCaptionTail","calculateCaptionTails","facetKeys","dendrogramX","dendrogramY","facetCount","maxNRows","maxNCols","width","height","sharedX","sharedY","currentLeft","currentTop","index","currentColumn","chartSides","getChartEdgeSides","stepX","stepY","sideElementSizes","calculateChartSideElementSizes","annotationsTitleSizes","calculateAnnotationTitleSizes","getPadding","side","CHART_SIDE_ELEMENTS","el","MIN_PADDING","padding","sideElementBBoxes","calculateSideElementsBBoxes","outerWidth","outerHeight","chartsWidth","sum","chartsHeight","_key","groupGap","meta","facets","sortX","arr","a","b","sortY","facetKey","facetGroup","xCounts","L","xGroupKey","yCounts","yGroupKey","xCellsCount","yCellsCount","xStep","yStep","xPositions","xKeys","currentX","xKey","axisKeys","yPositions","yKeys","currentY","yKey","aes","groupedCellsData","cellUniqValues","valueKeys","createDiscreteColorScale","xDataByKeys","yDataByKeys","colors","type","axis","valueColumn","data","discreteValues","lodash","createContinuousColorScale","groups","dendrogramsData","hierarchyByGroupX","hierarchyByGroupY","maxHeightX","groupKey","hierarchy","cluster","heightScale","maxHeightY","inheritedAes","usedColumns","columnName","aesMap","columnValues","value","DEFAULT_AES","settingsId","chartSettings","inheritedDendrogramAes","onTooltipHintSwitch","component","ChartsGroup","message","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6CA,MAAMA,KAAW,KAAK,IAAI,KAAK,KAAK,CAAC,GAC/BC,KAAiB;AACvB,SAASC,EAAkBC,GAAmCC,GAA8BC,GAAkB;AAC1G,WAASC,EAAUC,GAAgC;AAC/CA,IAAAA,EAAEF,CAAK,IAAID,EAAMG,EAAE,KAAK,MAAM,GAC1BA,EAAE,YAAUA,EAAE,SAAS,QAAQD,CAAS;AAAA,EAChD;AACAA,EAAAA,EAAUH,CAAI;AAClB;AAGA,SAASK,EACLL,GACAM,GACAC,GACAC,IAAUD,GACZ;AACE,WAASE,EAAKL,GAAgC;AAC1CA,MAAEI,CAAO,IAAIJ,EAAEG,CAAS,IAAID,GACxBF,EAAE,YAAUA,EAAE,SAAS,QAAQK,CAAI;AAAA,EAC3C;AACAA,EAAAA,EAAKT,CAAI;AACb;AAEA,MAAMU,KAAW,CAACC,GAAeC,MAA0B;AACvD,QAAMC,IAAM,KAAK,IAAI,GAAGD,CAAW,GAC7BE,IAAM,KAAK,IAAI,GAAGF,CAAW;AACnC,MAAIC,MAAQC,GAAK;AACb,UAAMC,IAAQJ,IAAQ,MAAM,IAAI,CAAA,IAAK,CAACE,CAAG;AACzC,aAASG,IAAI,GAAGA,IAAIL,IAAQ,IAAI,GAAGK;AAC/BD,QAAM,KAAKF,IAAMG,CAAC,GAClBD,EAAM,QAAQF,IAAMG,CAAC;AAEzB,WAAOD;AAAAA,EACX;AACA,MAAIJ,IAAQ;AACR,WAAO,CAACE,GAAKC,CAAG;AAEpB,QAAMG,KAAQH,IAAMD,MAAQF,IAAQ,IAC9BI,IAAQ,CAAA;AACd,WAASC,IAAI,GAAGA,IAAIL,I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AkB,KAAK;AAAA,QACvB,eAAA4D;AAAAA,QACA,YAAY,KAAK;AAAA,QACjB,YAAY,KAAK;AAAA,QACjB,qBAAqB,KAAK;AAAA,QAC1B,aAAa,KAAK;AAAA,QAClB,WAAAjG;AAAAA,QACA,eAAAjB;AAAAA,QACA,cAAcuD;AAAAA,QACd,aAAa,KAAK;AAAA,QAClB,QAAQ,KAAK;AAAA,QACb,SAAS,KAAK;AAAA,QACd,QAAQ,KAAK;AAAA,QACb,YAAA0D;AAAAA,QACA,MAAM,KAAK;AAAA,QACX,YAAA/G;AAAAA,QACA,YAAAC;AAAAA,QACA,qBAAAiH;AAAAA,MAAA;AAAA,IAAA;AAGR,SAAK,YAAYC,IACjBjJ,IAAA,KAAK,cAAL,QAAAA,EAAgB,OAAOiJ,CAAAA;AAAAA,EAC3B;AAAA,EAEA,YAAYE,GAAiB;;AACzB,KAAAnJ,IAAA,KAAK,cAAL,QAAAA,EAAgB,OAAOP,gBAAAA,EAAAA,IAAC2J,IAAA,EAAM,SAAAD,EAAAA,CAAkB,CAAA;AAAA,EACpD;AACJ;","x_google_ignoreList":[0]}
|
package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Captions/GroupCaptions.js
CHANGED
|
@@ -1,30 +1,39 @@
|
|
|
1
1
|
import { j as r } from "../../../node_modules/react/jsx-runtime.js";
|
|
2
|
-
|
|
2
|
+
import { TICK_OFFSET as h } from "../../constants.js";
|
|
3
|
+
function I({
|
|
3
4
|
sideElementBBoxes: s,
|
|
4
|
-
xGroupKeys:
|
|
5
|
-
yGroupKeys:
|
|
6
|
-
xKeysByGroups:
|
|
7
|
-
yKeysByGroups:
|
|
8
|
-
xGroupLabels:
|
|
9
|
-
yGroupLabels:
|
|
10
|
-
scales:
|
|
11
|
-
stepX:
|
|
12
|
-
stepY:
|
|
13
|
-
xAxis:
|
|
14
|
-
yAxis:
|
|
15
|
-
labelAngles:
|
|
16
|
-
debug:
|
|
5
|
+
xGroupKeys: G,
|
|
6
|
+
yGroupKeys: $,
|
|
7
|
+
xKeysByGroups: f,
|
|
8
|
+
yKeysByGroups: m,
|
|
9
|
+
xGroupLabels: w,
|
|
10
|
+
yGroupLabels: A,
|
|
11
|
+
scales: y,
|
|
12
|
+
stepX: B,
|
|
13
|
+
stepY: V,
|
|
14
|
+
xAxis: K,
|
|
15
|
+
yAxis: k,
|
|
16
|
+
labelAngles: b,
|
|
17
|
+
debug: j
|
|
17
18
|
}) {
|
|
18
|
-
const
|
|
19
|
+
const L = s.top.groups.isVisible || s.bottom.groups.isVisible, l = s.top.groups.isVisible ? s.top.groups : s.bottom.groups, C = s.left.groups.isVisible || s.right.groups.isVisible, n = s.left.groups.isVisible ? s.left.groups : s.right.groups;
|
|
19
20
|
return /* @__PURE__ */ r.jsxs("g", { children: [
|
|
20
|
-
|
|
21
|
-
const a =
|
|
21
|
+
L && /* @__PURE__ */ r.jsx("g", { transform: `translate(${l.x},${l.y})`, children: G.map((t) => {
|
|
22
|
+
const a = f[t].length;
|
|
22
23
|
if (a === 0)
|
|
23
24
|
return null;
|
|
24
|
-
const
|
|
25
|
-
return /* @__PURE__ */ r.jsxs("g", { transform: `translate(${
|
|
26
|
-
/* @__PURE__ */ r.jsx(
|
|
27
|
-
|
|
25
|
+
const e = b.xGroupLabels, o = e !== 0, g = K.groupingPosition === "top", p = a * B, i = y.x(f[t][0]) + p / 2, u = o ? g ? l.height : 0 : l.height / 2, x = -e, d = e === 45 ? 2 * h : e === 90 ? h : 0, c = o ? g ? "start" : "end" : "middle";
|
|
26
|
+
return /* @__PURE__ */ r.jsxs("g", { transform: `translate(${i},${u + d})`, children: [
|
|
27
|
+
/* @__PURE__ */ r.jsx(
|
|
28
|
+
"text",
|
|
29
|
+
{
|
|
30
|
+
transform: `rotate(${x})`,
|
|
31
|
+
dominantBaseline: "central",
|
|
32
|
+
textAnchor: c,
|
|
33
|
+
children: w[t]
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
j && /* @__PURE__ */ r.jsx(
|
|
28
37
|
"rect",
|
|
29
38
|
{
|
|
30
39
|
x: -p / 2,
|
|
@@ -34,40 +43,40 @@ function K({
|
|
|
34
43
|
fill: "none"
|
|
35
44
|
}
|
|
36
45
|
)
|
|
37
|
-
] },
|
|
46
|
+
] }, t);
|
|
38
47
|
}) }),
|
|
39
|
-
|
|
40
|
-
const a =
|
|
48
|
+
C && /* @__PURE__ */ r.jsx("g", { transform: `translate(${n.x},${n.y})`, children: $.map((t) => {
|
|
49
|
+
const a = m[t].length;
|
|
41
50
|
if (a === 0)
|
|
42
51
|
return null;
|
|
43
|
-
const
|
|
44
|
-
return /* @__PURE__ */ r.jsxs("g", { transform: `translate(${
|
|
52
|
+
const e = a * V, o = k.groupingPosition === "left", g = o ? n.width : 0, p = y.y(m[t][0]) + e / 2, i = b.yGroupLabels, u = i !== 0, x = i === 45 ? -45 : (o ? -1 : 1) * (90 - i), d = i === 45 ? 2 * h : i === 90 ? h : 0, c = u ? o ? "end" : "start" : "middle";
|
|
53
|
+
return /* @__PURE__ */ r.jsxs("g", { transform: `translate(${g - d},${p})`, children: [
|
|
45
54
|
/* @__PURE__ */ r.jsx(
|
|
46
55
|
"text",
|
|
47
56
|
{
|
|
48
|
-
y: u ? 0 : -
|
|
49
|
-
transform: `rotate(${
|
|
57
|
+
y: u ? 0 : -n.width / 2,
|
|
58
|
+
transform: `rotate(${x})`,
|
|
50
59
|
dominantBaseline: "central",
|
|
51
|
-
textAnchor:
|
|
52
|
-
children:
|
|
60
|
+
textAnchor: c,
|
|
61
|
+
children: A[t]
|
|
53
62
|
}
|
|
54
63
|
),
|
|
55
|
-
|
|
64
|
+
j && /* @__PURE__ */ r.jsx(
|
|
56
65
|
"rect",
|
|
57
66
|
{
|
|
58
|
-
x: -
|
|
59
|
-
y: -
|
|
60
|
-
width:
|
|
61
|
-
height:
|
|
67
|
+
x: -n.width / 2,
|
|
68
|
+
y: -e / 2,
|
|
69
|
+
width: n.width,
|
|
70
|
+
height: e,
|
|
62
71
|
stroke: "black",
|
|
63
72
|
fill: "none"
|
|
64
73
|
}
|
|
65
74
|
)
|
|
66
|
-
] },
|
|
75
|
+
] }, t);
|
|
67
76
|
}) })
|
|
68
77
|
] });
|
|
69
78
|
}
|
|
70
79
|
export {
|
|
71
|
-
|
|
80
|
+
I as GroupCaptions
|
|
72
81
|
};
|
|
73
82
|
//# sourceMappingURL=GroupCaptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupCaptions.js","sources":["../../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Captions/GroupCaptions.tsx"],"sourcesContent":["import type {ChartScales, ChartSideElementsBBoxes, LabelAngles} from '../types';\nimport type {HeatmapSettingsImpl} from '../../HeatmapSettingsImpl';\nimport React from 'react';\n\ninterface GroupCaptionsProps {\n sideElementBBoxes: ChartSideElementsBBoxes;\n xGroupKeys: string[];\n yGroupKeys: string[];\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n xGroupLabels: Record<string, string>;\n yGroupLabels: Record<string, string>;\n scales: ChartScales;\n stepX: number;\n stepY: number;\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'];\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'];\n labelAngles: LabelAngles;\n debug: boolean;\n}\nexport function GroupCaptions({\n sideElementBBoxes,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups,\n yKeysByGroups,\n xGroupLabels,\n yGroupLabels,\n scales,\n stepX,\n stepY,\n xAxis,\n yAxis,\n labelAngles,\n debug,\n}: GroupCaptionsProps) {\n const xGroupsVisible = sideElementBBoxes.top.groups.isVisible || sideElementBBoxes.bottom.groups.isVisible;\n const xGroupsBBox = sideElementBBoxes.top.groups.isVisible\n ? sideElementBBoxes.top.groups\n : sideElementBBoxes.bottom.groups;\n\n const yGroupsVisible = sideElementBBoxes.left.groups.isVisible || sideElementBBoxes.right.groups.isVisible;\n const yGroupsBBox = sideElementBBoxes.left.groups.isVisible\n ? sideElementBBoxes.left.groups\n : sideElementBBoxes.right.groups;\n\n return (\n <g>\n {/* x group titles */}\n {xGroupsVisible && (\n <g transform={`translate(${xGroupsBBox.x},${xGroupsBBox.y})`}>\n {xGroupKeys.map(xGroupKey => {\n const keysCount = xKeysByGroups[xGroupKey].length;\n if (keysCount === 0) {\n return null;\n }\n const
|
|
1
|
+
{"version":3,"file":"GroupCaptions.js","sources":["../../../../../../../../node_modules/@milaboratories/miplots4/src/heatmap/components/Captions/GroupCaptions.tsx"],"sourcesContent":["import {TICK_OFFSET} from '../../constants';\nimport type {ChartScales, ChartSideElementsBBoxes, LabelAngles} from '../types';\nimport type {HeatmapSettingsImpl} from '../../HeatmapSettingsImpl';\nimport React from 'react';\n\ninterface GroupCaptionsProps {\n sideElementBBoxes: ChartSideElementsBBoxes;\n xGroupKeys: string[];\n yGroupKeys: string[];\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n xGroupLabels: Record<string, string>;\n yGroupLabels: Record<string, string>;\n scales: ChartScales;\n stepX: number;\n stepY: number;\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'];\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'];\n labelAngles: LabelAngles;\n debug: boolean;\n}\nexport function GroupCaptions({\n sideElementBBoxes,\n xGroupKeys,\n yGroupKeys,\n xKeysByGroups,\n yKeysByGroups,\n xGroupLabels,\n yGroupLabels,\n scales,\n stepX,\n stepY,\n xAxis,\n yAxis,\n labelAngles,\n debug,\n}: GroupCaptionsProps) {\n const xGroupsVisible = sideElementBBoxes.top.groups.isVisible || sideElementBBoxes.bottom.groups.isVisible;\n const xGroupsBBox = sideElementBBoxes.top.groups.isVisible\n ? sideElementBBoxes.top.groups\n : sideElementBBoxes.bottom.groups;\n\n const yGroupsVisible = sideElementBBoxes.left.groups.isVisible || sideElementBBoxes.right.groups.isVisible;\n const yGroupsBBox = sideElementBBoxes.left.groups.isVisible\n ? sideElementBBoxes.left.groups\n : sideElementBBoxes.right.groups;\n\n return (\n <g>\n {/* x group titles */}\n {xGroupsVisible && (\n <g transform={`translate(${xGroupsBBox.x},${xGroupsBBox.y})`}>\n {xGroupKeys.map(xGroupKey => {\n const keysCount = xKeysByGroups[xGroupKey].length;\n if (keysCount === 0) {\n return null;\n }\n const angle = labelAngles.xGroupLabels;\n const inclined = angle !== 0;\n const onTop = xAxis.groupingPosition === 'top';\n const groupWidth = keysCount * stepX;\n const x = scales.x(xKeysByGroups[xGroupKey][0]) + groupWidth / 2;\n const y = inclined ? (onTop ? xGroupsBBox.height : 0) : xGroupsBBox.height / 2;\n const rotate = -angle;\n const offset = angle === 45 ? 2 * TICK_OFFSET : angle === 90 ? TICK_OFFSET : 0;\n const textAnchor = !inclined ? 'middle' : onTop ? 'start' : 'end';\n return (\n <g key={xGroupKey} transform={`translate(${x},${y + offset})`}>\n <text\n transform={`rotate(${rotate})`}\n dominantBaseline=\"central\"\n textAnchor={textAnchor}\n >\n {xGroupLabels[xGroupKey]}\n </text>\n {debug && (\n <rect\n x={-groupWidth / 2}\n width={groupWidth}\n height={xGroupsBBox.height}\n stroke=\"black\"\n fill=\"none\"\n />\n )}\n </g>\n );\n })}\n </g>\n )}\n {/* y group titles */}\n {yGroupsVisible && (\n <g transform={`translate(${yGroupsBBox.x},${yGroupsBBox.y})`}>\n {yGroupKeys.map(yGroupKey => {\n const keysCount = yKeysByGroups[yGroupKey].length;\n if (keysCount === 0) {\n return null;\n }\n const groupWidth = keysCount * stepY;\n const onLeft = yAxis.groupingPosition === 'left';\n const x = onLeft ? yGroupsBBox.width : 0;\n const y = scales.y(yKeysByGroups[yGroupKey][0]) + groupWidth / 2;\n const angle = labelAngles.yGroupLabels;\n const inclined = angle !== 0;\n const rotate = angle === 45 ? -45 : (onLeft ? -1 : 1) * (90 - angle);\n const offset = angle === 45 ? 2 * TICK_OFFSET : angle === 90 ? TICK_OFFSET : 0;\n const textAnchor = !inclined ? 'middle' : onLeft ? 'end' : 'start';\n return (\n <g key={yGroupKey} transform={`translate(${x - offset},${y})`}>\n <text\n y={inclined ? 0 : -yGroupsBBox.width / 2}\n transform={`rotate(${rotate})`}\n dominantBaseline=\"central\"\n textAnchor={textAnchor}\n >\n {yGroupLabels[yGroupKey]}\n </text>\n {debug && (\n <rect\n x={-yGroupsBBox.width / 2}\n y={-groupWidth / 2}\n width={yGroupsBBox.width}\n height={groupWidth}\n stroke=\"black\"\n fill=\"none\"\n />\n )}\n </g>\n );\n })}\n </g>\n )}\n </g>\n );\n}\n"],"names":["GroupCaptions","sideElementBBoxes","xGroupKeys","yGroupKeys","xKeysByGroups","yKeysByGroups","xGroupLabels","yGroupLabels","scales","stepX","stepY","xAxis","yAxis","labelAngles","debug","xGroupsVisible","xGroupsBBox","yGroupsVisible","yGroupsBBox","n","jsx","xGroupKey","keysCount","angle","inclined","onTop","groupWidth","x","y","rotate","offset","TICK_OFFSET","textAnchor","jsxs","yGroupKey","onLeft"],"mappings":";;AAqBO,SAASA,EAAc;AAAA,EAC1B,mBAAAC;AAAAA,EACA,YAAAC;AAAAA,EACA,YAAAC;AAAAA,EACA,eAAAC;AAAAA,EACA,eAAAC;AAAAA,EACA,cAAAC;AAAAA,EACA,cAAAC;AAAAA,EACA,QAAAC;AAAAA,EACA,OAAAC;AAAAA,EACA,OAAAC;AAAAA,EACA,OAAAC;AAAAA,EACA,OAAAC;AAAAA,EACA,aAAAC;AAAAA,EACA,OAAAC;AACJ,GAAuB;AACnB,QAAMC,IAAiBd,EAAkB,IAAI,OAAO,aAAaA,EAAkB,OAAO,OAAO,WAC3Fe,IAAcf,EAAkB,IAAI,OAAO,YAC3CA,EAAkB,IAAI,SACtBA,EAAkB,OAAO,QAEzBgB,IAAiBhB,EAAkB,KAAK,OAAO,aAAaA,EAAkB,MAAM,OAAO,WAC3FiB,IAAcjB,EAAkB,KAAK,OAAO,YAC5CA,EAAkB,KAAK,SACvBA,EAAkB,MAAM;AAE9B,SAAAkB,gBAAAA,EAAA,KACK,KAAA,EAEI,U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