@milaboratories/miplots4 1.0.166 → 1.0.167

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.
Files changed (35) hide show
  1. package/dist/_virtual/index10.js +5 -2
  2. package/dist/_virtual/index10.js.map +1 -1
  3. package/dist/_virtual/index5.js +2 -5
  4. package/dist/_virtual/index5.js.map +1 -1
  5. package/dist/_virtual/index6.js +4 -4
  6. package/dist/_virtual/index7.js +1 -1
  7. package/dist/_virtual/index8.js +4 -4
  8. package/dist/_virtual/index9.js +3 -3
  9. package/dist/bubble/components/ChartsGroup.js +21 -21
  10. package/dist/bubble/components/ChartsGroup.js.map +1 -1
  11. package/dist/common/Tooltip.js +2 -2
  12. package/dist/common/Tooltip.js.map +1 -1
  13. package/dist/discrete/index.d.ts +2 -0
  14. package/dist/discrete/index.js +127 -123
  15. package/dist/discrete/index.js.map +1 -1
  16. package/dist/discrete/layers/stats/pValueCalculation.js +5 -5
  17. package/dist/discrete/utils/getFacetLabels.d.ts +3 -0
  18. package/dist/discrete/utils/getFacetLabels.js +16 -0
  19. package/dist/discrete/utils/getFacetLabels.js.map +1 -0
  20. package/dist/heatmap/components/ChartsGroup.js +9 -9
  21. package/dist/heatmap/components/ChartsGroup.js.map +1 -1
  22. package/dist/heatmap/components/tooltipUtils.js +15 -15
  23. package/dist/heatmap/components/tooltipUtils.js.map +1 -1
  24. package/dist/heatmap/fillCellsData.js +88 -85
  25. package/dist/heatmap/fillCellsData.js.map +1 -1
  26. package/dist/histogram/getHistogramData.js +42 -41
  27. package/dist/histogram/getHistogramData.js.map +1 -1
  28. package/dist/histogram/index.d.ts +1 -0
  29. package/dist/histogram/index.js +59 -57
  30. package/dist/histogram/index.js.map +1 -1
  31. package/dist/node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/index.js +1 -1
  32. package/dist/scatterplot/index.d.ts +1 -0
  33. package/dist/scatterplot/index.js +61 -59
  34. package/dist/scatterplot/index.js.map +1 -1
  35. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fillCellsData.js","sources":["../../src/heatmap/fillCellsData.ts"],"sourcesContent":["import { deviation, extent, mean, quantileSorted, sum } from 'd3-array';\nimport lodash from 'lodash';\nimport type { DataFrame } from '../DataFrame';\nimport type { AggregationMethod, ColumnName, DataValue, NormalizationMethod } from '../types';\nimport type { HeatmapSettingsImpl } from './HeatmapSettingsImpl';\nimport { exhaustive } from '../utils';\nimport { getFacetOrGroupKey } from '../utils/getFacetOrGroupKey';\nimport type { BubbleSettingsImpl } from '../bubble/BubbleSettingsImpl';\n\nexport type Cell<T extends string> = {\n isCell: true;\n idx: number;\n id: string;\n value: Record<T, DataValue>;\n normalizedValue: Record<T, DataValue>;\n x: DataValue;\n y: DataValue;\n};\n\nexport type GroupedCellsData<T extends string> = {\n meta: {\n valueSources: T[]; // dataSource for heatmap, color and size for bubble - main data for every cell\n\n facetKeys: string[];\n xGroupKeys: string[];\n yGroupKeys: string[];\n\n xKeys: string[];\n yKeys: string[];\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n\n // for titles, if facet by more 1 columns title has several values separated by commas\n facetKeyValues: Record<string, string[]>;\n xGroupKeyValues: Record<string, string[]>;\n yGroupKeyValues: Record<string, string[]>;\n\n xLabels: Record<string, string>;\n yLabels: Record<string, string>;\n xGroupLabels: Record<string, string>;\n yGroupLabels: Record<string, string>;\n\n valueExtent: Record<T, [number, number]>; // for color/size scales\n // data for labels, annotations and dendrograms\n xDataByKeys: Record<string, Record<string, DataValue>>;\n yDataByKeys: Record<string, Record<string, DataValue>>;\n };\n //facet groups\n facets: Record<\n string,\n {\n // axis keys\n xKeys: string[];\n yKeys: string[];\n // axis keys grouped by group keys from meta\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // cells grouped by X, then by Y\n cells: Record<string, Record<string, Cell<T>>>;\n }\n >;\n};\n\nfunction normalizeByStd(values: number[]) {\n const stdValue = deviation(values);\n const meanValue = mean(values);\n\n if (stdValue === undefined || meanValue === undefined || stdValue === 0) {\n return (v: number) => v;\n }\n return (v: number) => (v - meanValue) / stdValue;\n}\nfunction normalizeByMinMax(values: number[]) {\n const meanValue = mean(values);\n const [min, max] = extent(values);\n if (meanValue === undefined || min === undefined || max === undefined || max === min) {\n return (v: number) => v;\n }\n return (v: number) => (v - meanValue) / (max - min);\n}\n\nfunction getNormalizationFn(method: NormalizationMethod, values: number[]) {\n if (method === 'standardScaling') {\n return normalizeByStd(values);\n }\n if (method === 'meanNormalization') {\n return normalizeByMinMax(values);\n }\n return (v: number) => v;\n}\n\nfunction aggregateNumeric(method: AggregationMethod, values: number[]) {\n switch (method) {\n case 'max': {\n let res = values[0];\n for (const v of values) {\n res = Math.max(res, v);\n }\n return res;\n }\n case 'min': {\n let res = values[0];\n for (const v of values) {\n res = Math.min(res, v);\n }\n return res;\n }\n case 'median': {\n const valuesSorted = values.sort((a, b) => a - b);\n return quantileSorted(valuesSorted, 0.5) as number;\n }\n case 'mean': {\n return mean(values) ?? values[0];\n }\n case 'sum': {\n return sum(values) as number;\n }\n default: exhaustive(method, `Unknown aggregation function ${method}`);\n }\n}\nfunction aggregateString(values: string[]) {\n const list = [...new Set(values)].sort();\n if (list.length > 3) {\n return [...list.slice(0, 3), '...'].join(', ');\n }\n return list.join(', ');\n}\n\n// all combinations with 1 key from each list\nfunction getKeysCombinations(keysLists: string[][]) {\n if (!keysLists.length) {\n return [];\n }\n let result: string[][] = [[]];\n keysLists.forEach(keys => {\n const nextResult: string[][] = [];\n keys.forEach(key => {\n nextResult.push(...result.map(resultItem => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\nconst sortByLabels = (arr: string[], direction: 'asc' | 'desc', labels: Record<string, string> = {}) => {\n return arr.sort((a, b) => direction === '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};\nfunction applyAggregation<T extends string>(\n result: GroupedCellsData<T>,\n aggregation: HeatmapSettingsImpl['aggregation'],\n additionalDataColumnsX: string[],\n additionalDataColumnsY: string[],\n annotations: HeatmapSettingsImpl['annotations']\n) {\n if (aggregation.x || aggregation.y) {\n const valueExtent: GroupedCellsData<T>['meta']['valueExtent'] = result.meta.valueSources.reduce((r, key) => {\n r[key] = [Infinity, -Infinity] as [number, number];\n return r;\n }, {} as GroupedCellsData<T>['meta']['valueExtent']);\n result.meta.facetKeys.forEach(facetKey => {\n const { xKeys, yKeys, cells, xKeysByGroups, yKeysByGroups } = result.facets[facetKey];\n const xGroups = aggregation.x ? xKeysByGroups : xKeys.reduce((res, xKey) => { res[xKey] = [xKey]; return res; }, {} as Record<string, string[]>);\n const yGroups = aggregation.y ? yKeysByGroups : yKeys.reduce((res, yKey) => { res[yKey] = [yKey]; return res; }, {} as Record<string, string[]>);\n const xNewKeys = Object.keys(xGroups);\n const yNewKeys = Object.keys(yGroups);\n\n for (const xGroupKey of xNewKeys) {\n for (const yGroupKey of yNewKeys) {\n // collect values for aggregation to arrays\n const valuesBySources: Record<T, number[]> = result.meta.valueSources.reduce((r, v) => {\n r[v] = [];\n return r;\n }, {} as Record<T, number[]>);\n xGroups[xGroupKey].forEach((xKey) => {\n yGroups[yGroupKey].forEach((yKey) => {\n for (const valueSource of result.meta.valueSources) {\n const cellValue = cells[xKey]?.[yKey]?.value?.[valueSource];\n if (cellValue !== undefined) {\n valuesBySources[valueSource].push(cellValue as number);\n }\n }\n delete cells[xKey]?.[yKey];\n });\n });\n // create new cells with aggregated values\n for (const valueSource of result.meta.valueSources) {\n const values = valuesBySources[valueSource];\n if (values.length > 0) {\n const value = aggregateNumeric(aggregation.method, values);\n if (!result.facets[facetKey].cells[xGroupKey]) {\n result.facets[facetKey].cells[xGroupKey] = {};\n }\n if (!result.facets[facetKey].cells[xGroupKey][yGroupKey]) {\n result.facets[facetKey].cells[xGroupKey][yGroupKey] = {\n isCell: true,\n idx: 0,\n id: `${xGroupKey}_${yGroupKey}`,\n x: xGroupKey,\n y: yGroupKey,\n value: result.meta.valueSources.reduce((r, v) => { r[v] = null; return r; }, {} as Record<T, DataValue>),\n normalizedValue: result.meta.valueSources.reduce((r, v) => { r[v] = null; return r; }, {} as Record<T, DataValue>),\n };\n }\n const cell = result.facets[facetKey].cells[xGroupKey][yGroupKey];\n cell.value[valueSource] = value;\n cell.normalizedValue[valueSource] = value;\n\n valueExtent[valueSource][0] = Math.min(cell.normalizedValue?.[valueSource], valueExtent[valueSource][0]);\n valueExtent[valueSource][1] = Math.max(cell.normalizedValue?.[valueSource], valueExtent[valueSource][1]);\n }\n }\n }\n }\n // add aggregated values for X annotations\n if (aggregation.x) {\n xNewKeys.forEach(xGroupKey => {\n additionalDataColumnsX.forEach(columnKey => {\n const annotation = annotations.find((v) => v.valueColumn.value === columnKey || v.valueColumn.valueLabels === columnKey);\n if (!annotation) {\n return;\n }\n const values: DataValue[] = [];\n xGroups[xGroupKey].forEach((xKey) => {\n values.push(result.meta.xDataByKeys[columnKey][xKey]);\n delete result.meta.xDataByKeys[columnKey][xKey];\n });\n const value = annotation.type === 'continuous' ? aggregateNumeric(aggregation.method, values as number[]) : aggregateString(values as string[]);\n result.meta.xDataByKeys[columnKey][xGroupKey] = value;\n });\n });\n }\n // add aggregated values for Y annotations\n if (aggregation.y) {\n additionalDataColumnsY.forEach(columnKey => {\n result.meta.yDataByKeys[columnKey] = {};\n });\n yNewKeys.forEach(yGroupKey => {\n additionalDataColumnsY.forEach(columnKey => {\n const annotation = annotations.find((v) => v.valueColumn.value === columnKey || v.valueColumn.valueLabels === columnKey);\n if (!annotation) {\n return;\n }\n const values: DataValue[] = [];\n yGroups[yGroupKey].forEach((yKey) => {\n values.push(result.meta.yDataByKeys[columnKey][yKey]);\n delete result.meta.yDataByKeys[columnKey][yKey];\n });\n const value = annotation.type === 'continuous' ? aggregateNumeric(aggregation.method, values as number[]) : aggregateString(values as string[]);\n result.meta.yDataByKeys[columnKey][yGroupKey] = value;\n });\n });\n }\n // erase grouping - we aggregated by them and now there is no grouping in the chart;\n // replace axis keys with group keys - now group keys are new axis keys\n if (aggregation.x) {\n result.facets[facetKey].xKeys = Object.keys(xKeysByGroups);\n result.facets[facetKey].xKeysByGroups = { 'null': result.facets[facetKey].xKeys };\n result.meta.xLabels = result.meta.xGroupLabels;\n result.meta.xGroupKeys = ['null'];\n result.meta.xGroupKeyValues = { null: ['null'] };\n }\n if (aggregation.y) {\n result.facets[facetKey].yKeys = Object.keys(yKeysByGroups);\n result.facets[facetKey].yKeysByGroups = { 'null': result.facets[facetKey].yKeys };\n result.meta.yLabels = result.meta.yGroupLabels;\n result.meta.yGroupKeys = ['null'];\n result.meta.yGroupKeyValues = { null: ['null'] };\n }\n });\n result.meta.valueExtent = valueExtent;\n }\n}\n\nfunction updateValueExtent<T extends string>(result: GroupedCellsData<T>, cell: Cell<T>) {\n for (const valueSource of result.meta.valueSources) {\n result.meta.valueExtent[valueSource][0] = Math.min(cell.normalizedValue?.[valueSource] as number, result.meta.valueExtent[valueSource][0]);\n result.meta.valueExtent[valueSource][1] = Math.max(cell.normalizedValue?.[valueSource] as number, result.meta.valueExtent[valueSource][1]);\n }\n\n}\nfunction applyNormalization<T extends string>(\n result: GroupedCellsData<T>,\n normalizationBySources: Record<T, HeatmapSettingsImpl['normalization']>,\n) {\n if (Object.values(normalizationBySources).length) {\n const valueExtent: GroupedCellsData<T>['meta']['valueExtent'] = result.meta.valueSources.reduce((r, key) => {\n if (normalizationBySources[key]) {\n r[key] = [Infinity, -Infinity] as [number, number];\n }\n return r;\n }, {} as GroupedCellsData<T>['meta']['valueExtent']);\n result.meta.facetKeys.forEach(facetKey => {\n const { xKeys, yKeys, cells } = result.facets[facetKey];\n\n for (const valueSource of result.meta.valueSources) {\n const normalization = normalizationBySources[valueSource];\n if (!normalization) {\n continue;\n }\n const cellKeys = normalization.direction === 'row' ? xKeys : yKeys;\n const groupKeys = normalization.direction === 'row' ? yKeys : xKeys;\n const cellGetter = normalization.direction === 'row'\n ? (cellKey: string, groupKey: string) => cells[cellKey]?.[groupKey]\n : (cellKey: string, groupKey: string) => cells[groupKey]?.[cellKey];\n groupKeys.forEach((groupKey) => {\n const values: number[] = [];\n cellKeys.forEach((cellKey) => {\n const v = cellGetter(cellKey, groupKey)?.value?.[valueSource];\n if (v !== undefined) {\n values.push(v as number);\n }\n });\n const normalize = getNormalizationFn(normalization.method, values);\n cellKeys.forEach((cellKey) => {\n const cell = cellGetter(cellKey, groupKey);\n if (cell !== undefined) {\n cell.normalizedValue[valueSource] = normalize(cell.value?.[valueSource] as number);\n valueExtent[valueSource][0] = Math.min(cell.normalizedValue?.[valueSource], valueExtent[valueSource][0]);\n valueExtent[valueSource][1] = Math.max(cell.normalizedValue?.[valueSource], valueExtent[valueSource][1]);\n }\n });\n });\n }\n\n });\n result.meta.valueExtent = {...result.meta.valueExtent, valueExtent};\n }\n}\n\nexport function fillCellsData<T extends string>(\n result: GroupedCellsData<T>,\n data: DataFrame,\n xColumn: ColumnName,\n yColumn: ColumnName,\n valueColumns: Record<string, ColumnName>,\n facetBy: ColumnName[],\n xGroupBy: ColumnName[],\n yGroupBy: ColumnName[],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n normalizationBySource: Record<T, HeatmapSettingsImpl['normalization']>, // separated for color and size for example\n NAValueAs: HeatmapSettingsImpl['NAValueAs'],\n keysOrder: HeatmapSettingsImpl['keysOrder'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'] | BubbleSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'] | BubbleSettingsImpl['chartSettings']['yAxis'],\n aggregation: HeatmapSettingsImpl['aggregation'],\n) {\n const facetKeysLists = facetBy.length\n ? facetBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const xGroupKeysLists = xGroupBy.length\n ? xGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const yGroupKeysLists = yGroupBy.length\n ? yGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const facetKeysCombinations = getKeysCombinations(facetKeysLists);\n const xGroupKeysCombinations = getKeysCombinations(xGroupKeysLists);\n const yGroupKeysCombinations = getKeysCombinations(yGroupKeysLists);\n\n const facetKeys = facetKeysCombinations.map(getFacetOrGroupKey);\n const xGroupKeys = xGroupKeysCombinations.map(getFacetOrGroupKey);\n const yGroupKeys = yGroupKeysCombinations.map(getFacetOrGroupKey);\n\n result.meta.facetKeys = facetKeys;\n result.meta.xGroupKeys = xGroupKeys;\n result.meta.yGroupKeys = yGroupKeys;\n result.meta.facetKeyValues = facetKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = facetKeysCombinations[index];\n return res;\n }, {});\n result.meta.xGroupKeyValues = xGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = xGroupKeysCombinations[index];\n return res;\n }, {});\n result.meta.yGroupKeyValues = yGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = yGroupKeysCombinations[index];\n return res;\n }, {});\n\n const xLabelsSource = xColumn.valueLabels ?? xColumn.value;\n const yLabelsSource = yColumn.valueLabels ?? yColumn.value;\n const annotationColumnsX = annotations.filter(item => item.axis === 'x').map(item => item.valueColumn.valueLabels ?? item.valueColumn.value);\n const annotationColumnsY = annotations.filter(item => item.axis === 'y').map(item => item.valueColumn.valueLabels ?? item.valueColumn.value);\n const dendrogramXColumns = Object.values(dendrogramX ?? {}).map(column => column.value);\n const dendrogramYColumns = Object.values(dendrogramY ?? {}).map(column => column.value);\n const additionalDataColumnsX = lodash.uniq([...annotationColumnsX, ...dendrogramXColumns, xLabelsSource]);\n const additionalDataColumnsY = lodash.uniq([...annotationColumnsY, ...dendrogramYColumns, yLabelsSource]);\n\n for (let i = 0; i < data.rowsCount; i++) {\n const facetKey = getFacetOrGroupKey(facetBy.map(column => data.getColumnValue(column.value, i)));\n const xGroupKey = getFacetOrGroupKey(xGroupBy.map(column => data.getColumnValue(column.value, i)));\n const yGroupKey = getFacetOrGroupKey(yGroupBy.map(column => data.getColumnValue(column.value, i)));\n const xGroupLabel = xGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ');\n const yGroupLabel = yGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ');\n result.meta.xGroupLabels[xGroupKey] = xGroupLabel;\n result.meta.yGroupLabels[yGroupKey] = yGroupLabel;\n const x = String(data.getColumnValue(xColumn.value, i));\n const y = String(data.getColumnValue(yColumn.value, i));\n\n const values = result.meta.valueSources.reduce((r, key) => {\n r[key] = (data.getColumnValue(valueColumns[key].value, i) ?? NAValueAs) as number | null;\n return r;\n }, {} as Record<string, DataValue>);\n\n if (x === 'null' || y === 'null' || Object.values(values).every(v => v === null)) {\n continue;\n }\n\n if (!result.facets[facetKey]) {\n result.facets[facetKey] = {\n xKeys: [],\n yKeys: [],\n xKeysByGroups: {},\n yKeysByGroups: {},\n cells: {},\n };\n }\n if (!result.facets[facetKey].xKeysByGroups[xGroupKey]) {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = [];\n }\n if (!result.facets[facetKey].yKeysByGroups[yGroupKey]) {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = [];\n }\n result.facets[facetKey].xKeys.push(x);\n result.facets[facetKey].yKeys.push(y);\n result.facets[facetKey].xKeysByGroups[xGroupKey].push(x);\n result.facets[facetKey].yKeysByGroups[yGroupKey].push(y);\n\n if (!result.facets[facetKey].cells[x]) {\n result.facets[facetKey].cells[x] = {};\n }\n\n for (const valueSource of result.meta.valueSources) {\n if (result.facets[facetKey].cells[x][y] && result.facets[facetKey].cells[x][y].value[valueSource] !== values[valueSource]) {\n throw Error(`More than 1 value for x=${x}, y=${y}`);\n }\n }\n\n const xLabelsSourceValue = data.getColumnValue(xLabelsSource, i);\n if (result.meta.xLabels[x] && String(xLabelsSourceValue) !== result.meta.xLabels[x]) {\n throw Error(`More than 1 x-label value for x=${x}`);\n }\n const yLabelsSourceValue = data.getColumnValue(yLabelsSource, i);\n if (result.meta.yLabels[y] && String(yLabelsSourceValue) !== result.meta.yLabels[y]) {\n throw Error(`More than 1 y-label value for y=${y}`);\n }\n result.meta.xLabels[x] = String(xLabelsSourceValue);\n result.meta.yLabels[y] = String(yLabelsSourceValue);\n // data for labels, annotations and dendrograms by X\n additionalDataColumnsX.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.xDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.xDataByKeys[columnKey][x] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.xDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.xDataByKeys[columnKey][x] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for x = ${x} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.xDataByKeys[columnKey][x] = data.getColumnValue(columnKey, i);\n }\n });\n // data for labels, annotations and dendrograms by Y\n additionalDataColumnsY.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.yDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.yDataByKeys[columnKey][y] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.yDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.yDataByKeys[columnKey][y] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for y = ${y} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.yDataByKeys[columnKey][y] = data.getColumnValue(columnKey, i);\n }\n });\n result.facets[facetKey].cells[x][y] = {\n isCell: true,\n idx: i,\n id: `${x}_${y}`,\n x,\n y,\n value: values,\n normalizedValue: values,\n };\n\n updateValueExtent(result, result.facets[facetKey].cells[x][y]);\n }\n\n result.meta.facetKeys = result.meta.facetKeys.filter((key) => result.facets[key]); // filter only used;\n\n // make uniq x, y, x-group and y-group keys\n result.meta.facetKeys.forEach(facetKey => {\n const facet = result.facets[facetKey];\n const uniqueXKeys = lodash.uniq(facet.xKeys);\n const uniqueYKeys = lodash.uniq(facet.yKeys);\n facet.xKeys = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], uniqueXKeys) : uniqueXKeys;\n facet.yKeys = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], uniqueYKeys) : uniqueYKeys;\n xGroupKeys.forEach(xGroupKey => {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = lodash.intersection(\n facet.xKeys,\n result.facets[facetKey].xKeysByGroups[xGroupKey]\n );\n });\n yGroupKeys.forEach(yGroupKey => {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = lodash.intersection(\n facet.yKeys,\n result.facets[facetKey].yKeysByGroups[yGroupKey]\n );\n });\n });\n\n applyAggregation(result, aggregation, additionalDataColumnsX, additionalDataColumnsY, annotations);\n applyNormalization(result, normalizationBySource);\n\n // every facet may contain not all of available keys, but for shared axes it is necessary to have all of them\n result.meta.xKeysByGroups = result.meta.xGroupKeys.reduce((res: Record<string, string[]>, xGroupKey) => {\n const existingXKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].xKeysByGroups[xGroupKey]))\n ), xAxis.sorting, result.meta.xLabels);\n res[xGroupKey] = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], existingXKeys) : existingXKeys;\n return res;\n }, {});\n result.meta.xKeys = result.meta.xGroupKeys.reduce((res: string[], xGroupKey: string) => {\n res = res.concat(result.meta.xKeysByGroups[xGroupKey]);\n return res;\n }, []);\n\n result.meta.yKeysByGroups = result.meta.yGroupKeys.reduce((res: Record<string, string[]>, yGroupKey) => {\n const existingYKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].yKeysByGroups[yGroupKey]))\n ), yAxis.sorting, result.meta.yLabels);\n res[yGroupKey] = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], existingYKeys) : existingYKeys;\n return res;\n }, {});\n result.meta.yKeys = result.meta.yGroupKeys.reduce((res: string[], yGroupKey: string) => {\n res = res.concat(result.meta.yKeysByGroups[yGroupKey]);\n return res;\n }, []);\n\n for (const valueSource of result.meta.valueSources) {\n // avoid render errors on empty data\n if (result.meta.valueExtent[valueSource][0] === Infinity) {\n result.meta.valueExtent[valueSource][0] = 0;\n }\n if (result.meta.valueExtent[valueSource][1] === -Infinity) {\n result.meta.valueExtent[valueSource][1] = 0;\n }\n }\n\n return result;\n}"],"names":["normalizeByStd","values","stdValue","deviation","meanValue","mean","v","normalizeByMinMax","min","max","extent","getNormalizationFn","method","aggregateNumeric","res","valuesSorted","a","b","quantileSorted","sum","exhaustive","aggregateString","list","getKeysCombinations","keysLists","result","keys","nextResult","key","resultItem","sortByLabels","arr","direction","labels","applyAggregation","aggregation","additionalDataColumnsX","additionalDataColumnsY","annotations","valueExtent","r","facetKey","xKeys","yKeys","cells","xKeysByGroups","yKeysByGroups","xGroups","xKey","yGroups","yKey","xNewKeys","yNewKeys","xGroupKey","yGroupKey","valuesBySources","valueSource","cellValue","_c","_b","_a","_d","value","cell","columnKey","annotation","updateValueExtent","applyNormalization","normalizationBySources","normalization","cellKeys","groupKeys","cellGetter","cellKey","groupKey","normalize","fillCellsData","data","xColumn","yColumn","valueColumns","facetBy","xGroupBy","yGroupBy","dendrogramX","dendrogramY","normalizationBySource","NAValueAs","keysOrder","xAxis","yAxis","facetKeysLists","column","xGroupKeysLists","yGroupKeysLists","facetKeysCombinations","xGroupKeysCombinations","yGroupKeysCombinations","facetKeys","getFacetOrGroupKey","xGroupKeys","yGroupKeys","index","xLabelsSource","yLabelsSource","annotationColumnsX","item","annotationColumnsY","dendrogramXColumns","dendrogramYColumns","lodash","i","xGroupLabel","yGroupLabel","x","y","xLabelsSourceValue","yLabelsSourceValue","isAdd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M,UAC5C/B,EAAO,KAAK,YAAY+B,CAAW,EAAE,CAAC,IAAI,IAE1C/B,EAAO,KAAK,YAAY+B,CAAW,EAAE,CAAC,MAAM,WAC5C/B,EAAO,KAAK,YAAY+B,CAAW,EAAE,CAAC,IAAI;AAIlD,SAAO/B;AACX;"}
1
+ {"version":3,"file":"fillCellsData.js","sources":["../../src/heatmap/fillCellsData.ts"],"sourcesContent":["import { deviation, extent, mean, quantileSorted, sum } from 'd3-array';\nimport lodash from 'lodash';\nimport type { DataFrame } from '../DataFrame';\nimport type { AggregationMethod, ColumnName, DataValue, NormalizationMethod } from '../types';\nimport type { HeatmapSettingsImpl } from './HeatmapSettingsImpl';\nimport { exhaustive } from '../utils';\nimport { getFacetOrGroupKey } from '../utils/getFacetOrGroupKey';\nimport type { BubbleSettingsImpl } from '../bubble/BubbleSettingsImpl';\nimport { getFacetLabels } from '../discrete/utils/getFacetLabels';\n\nexport type Cell<T extends string> = {\n isCell: true;\n idx: number;\n id: string;\n value: Record<T, DataValue>;\n normalizedValue: Record<T, DataValue>;\n x: DataValue;\n y: DataValue;\n};\n\nexport type GroupedCellsData<T extends string> = {\n meta: {\n valueSources: T[]; // dataSource for heatmap, color and size for bubble - main data for every cell\n\n facetKeys: string[];\n xGroupKeys: string[];\n yGroupKeys: string[];\n\n xKeys: string[];\n yKeys: string[];\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n\n // for titles, if facet by more 1 columns title has several values separated by commas\n facetKeyValues: Record<string, string[]>;\n xGroupKeyValues: Record<string, string[]>;\n yGroupKeyValues: Record<string, string[]>;\n\n xLabels: Record<string, string>;\n yLabels: Record<string, string>;\n xGroupLabels: Record<string, string>;\n yGroupLabels: Record<string, string>;\n\n valueExtent: Record<T, [number, number]>; // for color/size scales\n // data for labels, annotations and dendrograms\n xDataByKeys: Record<string, Record<string, DataValue>>;\n yDataByKeys: Record<string, Record<string, DataValue>>;\n };\n //facet groups\n facets: Record<\n string,\n {\n // axis keys\n xKeys: string[];\n yKeys: string[];\n // axis keys grouped by group keys from meta\n xKeysByGroups: Record<string, string[]>;\n yKeysByGroups: Record<string, string[]>;\n // cells grouped by X, then by Y\n cells: Record<string, Record<string, Cell<T>>>;\n }\n >;\n};\n\nfunction normalizeByStd(values: number[]) {\n const stdValue = deviation(values);\n const meanValue = mean(values);\n\n if (stdValue === undefined || meanValue === undefined || stdValue === 0) {\n return (v: number) => v;\n }\n return (v: number) => (v - meanValue) / stdValue;\n}\nfunction normalizeByMinMax(values: number[]) {\n const meanValue = mean(values);\n const [min, max] = extent(values);\n if (meanValue === undefined || min === undefined || max === undefined || max === min) {\n return (v: number) => v;\n }\n return (v: number) => (v - meanValue) / (max - min);\n}\n\nfunction getNormalizationFn(method: NormalizationMethod, values: number[]) {\n if (method === 'standardScaling') {\n return normalizeByStd(values);\n }\n if (method === 'meanNormalization') {\n return normalizeByMinMax(values);\n }\n return (v: number) => v;\n}\n\nfunction aggregateNumeric(method: AggregationMethod, values: number[]) {\n switch (method) {\n case 'max': {\n let res = values[0];\n for (const v of values) {\n res = Math.max(res, v);\n }\n return res;\n }\n case 'min': {\n let res = values[0];\n for (const v of values) {\n res = Math.min(res, v);\n }\n return res;\n }\n case 'median': {\n const valuesSorted = values.sort((a, b) => a - b);\n return quantileSorted(valuesSorted, 0.5) as number;\n }\n case 'mean': {\n return mean(values) ?? values[0];\n }\n case 'sum': {\n return sum(values) as number;\n }\n default: exhaustive(method, `Unknown aggregation function ${method}`);\n }\n}\nfunction aggregateString(values: string[]) {\n const list = [...new Set(values)].sort();\n if (list.length > 3) {\n return [...list.slice(0, 3), '...'].join(', ');\n }\n return list.join(', ');\n}\n\n// all combinations with 1 key from each list\nfunction getKeysCombinations(keysLists: string[][]) {\n if (!keysLists.length) {\n return [];\n }\n let result: string[][] = [[]];\n keysLists.forEach(keys => {\n const nextResult: string[][] = [];\n keys.forEach(key => {\n nextResult.push(...result.map(resultItem => [...resultItem, key]));\n });\n result = nextResult;\n });\n return result;\n}\nconst sortByLabels = (arr: string[], direction: 'asc' | 'desc', labels: Record<string, string> = {}) => {\n return arr.sort((a, b) => direction === '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};\nfunction applyAggregation<T extends string>(\n result: GroupedCellsData<T>,\n aggregation: HeatmapSettingsImpl['aggregation'],\n additionalDataColumnsX: string[],\n additionalDataColumnsY: string[],\n annotations: HeatmapSettingsImpl['annotations']\n) {\n if (aggregation.x || aggregation.y) {\n const valueExtent: GroupedCellsData<T>['meta']['valueExtent'] = result.meta.valueSources.reduce((r, key) => {\n r[key] = [Infinity, -Infinity] as [number, number];\n return r;\n }, {} as GroupedCellsData<T>['meta']['valueExtent']);\n result.meta.facetKeys.forEach(facetKey => {\n const { xKeys, yKeys, cells, xKeysByGroups, yKeysByGroups } = result.facets[facetKey];\n const xGroups = aggregation.x ? xKeysByGroups : xKeys.reduce((res, xKey) => { res[xKey] = [xKey]; return res; }, {} as Record<string, string[]>);\n const yGroups = aggregation.y ? yKeysByGroups : yKeys.reduce((res, yKey) => { res[yKey] = [yKey]; return res; }, {} as Record<string, string[]>);\n const xNewKeys = Object.keys(xGroups);\n const yNewKeys = Object.keys(yGroups);\n\n for (const xGroupKey of xNewKeys) {\n for (const yGroupKey of yNewKeys) {\n // collect values for aggregation to arrays\n const valuesBySources: Record<T, number[]> = result.meta.valueSources.reduce((r, v) => {\n r[v] = [];\n return r;\n }, {} as Record<T, number[]>);\n xGroups[xGroupKey].forEach((xKey) => {\n yGroups[yGroupKey].forEach((yKey) => {\n for (const valueSource of result.meta.valueSources) {\n const cellValue = cells[xKey]?.[yKey]?.value?.[valueSource];\n if (cellValue !== undefined) {\n valuesBySources[valueSource].push(cellValue as number);\n }\n }\n delete cells[xKey]?.[yKey];\n });\n });\n // create new cells with aggregated values\n for (const valueSource of result.meta.valueSources) {\n const values = valuesBySources[valueSource];\n if (values.length > 0) {\n const value = aggregateNumeric(aggregation.method, values);\n if (!result.facets[facetKey].cells[xGroupKey]) {\n result.facets[facetKey].cells[xGroupKey] = {};\n }\n if (!result.facets[facetKey].cells[xGroupKey][yGroupKey]) {\n result.facets[facetKey].cells[xGroupKey][yGroupKey] = {\n isCell: true,\n idx: 0,\n id: `${xGroupKey}_${yGroupKey}`,\n x: xGroupKey,\n y: yGroupKey,\n value: result.meta.valueSources.reduce((r, v) => { r[v] = null; return r; }, {} as Record<T, DataValue>),\n normalizedValue: result.meta.valueSources.reduce((r, v) => { r[v] = null; return r; }, {} as Record<T, DataValue>),\n };\n }\n const cell = result.facets[facetKey].cells[xGroupKey][yGroupKey];\n cell.value[valueSource] = value;\n cell.normalizedValue[valueSource] = value;\n\n valueExtent[valueSource][0] = Math.min(cell.normalizedValue?.[valueSource], valueExtent[valueSource][0]);\n valueExtent[valueSource][1] = Math.max(cell.normalizedValue?.[valueSource], valueExtent[valueSource][1]);\n }\n }\n }\n }\n // add aggregated values for X annotations\n if (aggregation.x) {\n xNewKeys.forEach(xGroupKey => {\n additionalDataColumnsX.forEach(columnKey => {\n const annotation = annotations.find((v) => v.valueColumn.value === columnKey || v.valueColumn.valueLabels === columnKey);\n if (!annotation) {\n return;\n }\n const values: DataValue[] = [];\n xGroups[xGroupKey].forEach((xKey) => {\n values.push(result.meta.xDataByKeys[columnKey][xKey]);\n delete result.meta.xDataByKeys[columnKey][xKey];\n });\n const value = annotation.type === 'continuous' ? aggregateNumeric(aggregation.method, values as number[]) : aggregateString(values as string[]);\n result.meta.xDataByKeys[columnKey][xGroupKey] = value;\n });\n });\n }\n // add aggregated values for Y annotations\n if (aggregation.y) {\n additionalDataColumnsY.forEach(columnKey => {\n result.meta.yDataByKeys[columnKey] = {};\n });\n yNewKeys.forEach(yGroupKey => {\n additionalDataColumnsY.forEach(columnKey => {\n const annotation = annotations.find((v) => v.valueColumn.value === columnKey || v.valueColumn.valueLabels === columnKey);\n if (!annotation) {\n return;\n }\n const values: DataValue[] = [];\n yGroups[yGroupKey].forEach((yKey) => {\n values.push(result.meta.yDataByKeys[columnKey][yKey]);\n delete result.meta.yDataByKeys[columnKey][yKey];\n });\n const value = annotation.type === 'continuous' ? aggregateNumeric(aggregation.method, values as number[]) : aggregateString(values as string[]);\n result.meta.yDataByKeys[columnKey][yGroupKey] = value;\n });\n });\n }\n // erase grouping - we aggregated by them and now there is no grouping in the chart;\n // replace axis keys with group keys - now group keys are new axis keys\n if (aggregation.x) {\n result.facets[facetKey].xKeys = Object.keys(xKeysByGroups);\n result.facets[facetKey].xKeysByGroups = { 'null': result.facets[facetKey].xKeys };\n result.meta.xLabels = result.meta.xGroupLabels;\n result.meta.xGroupKeys = ['null'];\n result.meta.xGroupKeyValues = { null: ['null'] };\n }\n if (aggregation.y) {\n result.facets[facetKey].yKeys = Object.keys(yKeysByGroups);\n result.facets[facetKey].yKeysByGroups = { 'null': result.facets[facetKey].yKeys };\n result.meta.yLabels = result.meta.yGroupLabels;\n result.meta.yGroupKeys = ['null'];\n result.meta.yGroupKeyValues = { null: ['null'] };\n }\n });\n result.meta.valueExtent = valueExtent;\n }\n}\n\nfunction updateValueExtent<T extends string>(result: GroupedCellsData<T>, cell: Cell<T>) {\n for (const valueSource of result.meta.valueSources) {\n result.meta.valueExtent[valueSource][0] = Math.min(cell.normalizedValue?.[valueSource] as number, result.meta.valueExtent[valueSource][0]);\n result.meta.valueExtent[valueSource][1] = Math.max(cell.normalizedValue?.[valueSource] as number, result.meta.valueExtent[valueSource][1]);\n }\n\n}\nfunction applyNormalization<T extends string>(\n result: GroupedCellsData<T>,\n normalizationBySources: Record<T, HeatmapSettingsImpl['normalization']>,\n) {\n if (Object.values(normalizationBySources).length) {\n const valueExtent: GroupedCellsData<T>['meta']['valueExtent'] = result.meta.valueSources.reduce((r, key) => {\n if (normalizationBySources[key]) {\n r[key] = [Infinity, -Infinity] as [number, number];\n }\n return r;\n }, {} as GroupedCellsData<T>['meta']['valueExtent']);\n result.meta.facetKeys.forEach(facetKey => {\n const { xKeys, yKeys, cells } = result.facets[facetKey];\n\n for (const valueSource of result.meta.valueSources) {\n const normalization = normalizationBySources[valueSource];\n if (!normalization) {\n continue;\n }\n const cellKeys = normalization.direction === 'row' ? xKeys : yKeys;\n const groupKeys = normalization.direction === 'row' ? yKeys : xKeys;\n const cellGetter = normalization.direction === 'row'\n ? (cellKey: string, groupKey: string) => cells[cellKey]?.[groupKey]\n : (cellKey: string, groupKey: string) => cells[groupKey]?.[cellKey];\n groupKeys.forEach((groupKey) => {\n const values: number[] = [];\n cellKeys.forEach((cellKey) => {\n const v = cellGetter(cellKey, groupKey)?.value?.[valueSource];\n if (v !== undefined) {\n values.push(v as number);\n }\n });\n const normalize = getNormalizationFn(normalization.method, values);\n cellKeys.forEach((cellKey) => {\n const cell = cellGetter(cellKey, groupKey);\n if (cell !== undefined) {\n cell.normalizedValue[valueSource] = normalize(cell.value?.[valueSource] as number);\n valueExtent[valueSource][0] = Math.min(cell.normalizedValue?.[valueSource], valueExtent[valueSource][0]);\n valueExtent[valueSource][1] = Math.max(cell.normalizedValue?.[valueSource], valueExtent[valueSource][1]);\n }\n });\n });\n }\n\n });\n result.meta.valueExtent = {...result.meta.valueExtent, valueExtent};\n }\n}\n\nexport function fillCellsData<T extends string>(\n result: GroupedCellsData<T>,\n data: DataFrame,\n xColumn: ColumnName,\n yColumn: ColumnName,\n valueColumns: Record<string, ColumnName>,\n facetBy: ColumnName[],\n xGroupBy: ColumnName[],\n yGroupBy: ColumnName[],\n annotations: HeatmapSettingsImpl['annotations'],\n dendrogramX: HeatmapSettingsImpl['dendrogramX'],\n dendrogramY: HeatmapSettingsImpl['dendrogramY'],\n normalizationBySource: Record<T, HeatmapSettingsImpl['normalization']>, // separated for color and size for example\n NAValueAs: HeatmapSettingsImpl['NAValueAs'],\n keysOrder: HeatmapSettingsImpl['keysOrder'],\n xAxis: HeatmapSettingsImpl['chartSettings']['xAxis'] | BubbleSettingsImpl['chartSettings']['xAxis'],\n yAxis: HeatmapSettingsImpl['chartSettings']['yAxis'] | BubbleSettingsImpl['chartSettings']['yAxis'],\n aggregation: HeatmapSettingsImpl['aggregation'],\n) {\n const facetKeysLists = facetBy.length\n ? facetBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const xGroupKeysLists = xGroupBy.length\n ? xGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const yGroupKeysLists = yGroupBy.length\n ? yGroupBy.map(column => keysOrder[column.value] ?? data.getColumnCategories(column.value))\n : [['null']];\n const facetKeysCombinations = getKeysCombinations(facetKeysLists);\n const xGroupKeysCombinations = getKeysCombinations(xGroupKeysLists);\n const yGroupKeysCombinations = getKeysCombinations(yGroupKeysLists);\n\n const facetKeys = facetKeysCombinations.map(getFacetOrGroupKey);\n const xGroupKeys = xGroupKeysCombinations.map(getFacetOrGroupKey);\n const yGroupKeys = yGroupKeysCombinations.map(getFacetOrGroupKey);\n\n result.meta.facetKeys = facetKeys;\n result.meta.xGroupKeys = xGroupKeys;\n result.meta.yGroupKeys = yGroupKeys;\n\n const facetLabels = getFacetLabels(data, facetBy, facetKeys, facetKeysCombinations);\n result.meta.facetKeyValues = facetKeys.reduce((res: Record<string, string[]>, key) => {\n res[key] = facetLabels[key];\n return res;\n }, {});\n\n result.meta.xGroupKeyValues = xGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = xGroupKeysCombinations[index];\n return res;\n }, {});\n result.meta.yGroupKeyValues = yGroupKeys.reduce((res: Record<string, string[]>, key, index) => {\n res[key] = yGroupKeysCombinations[index];\n return res;\n }, {});\n\n const xLabelsSource = xColumn.valueLabels ?? xColumn.value;\n const yLabelsSource = yColumn.valueLabels ?? yColumn.value;\n const annotationColumnsX = annotations.filter(item => item.axis === 'x').map(item => item.valueColumn.valueLabels ?? item.valueColumn.value);\n const annotationColumnsY = annotations.filter(item => item.axis === 'y').map(item => item.valueColumn.valueLabels ?? item.valueColumn.value);\n const dendrogramXColumns = Object.values(dendrogramX ?? {}).map(column => column.value);\n const dendrogramYColumns = Object.values(dendrogramY ?? {}).map(column => column.value);\n const additionalDataColumnsX = lodash.uniq([...annotationColumnsX, ...dendrogramXColumns, xLabelsSource]);\n const additionalDataColumnsY = lodash.uniq([...annotationColumnsY, ...dendrogramYColumns, yLabelsSource]);\n\n for (let i = 0; i < data.rowsCount; i++) {\n const facetKey = getFacetOrGroupKey(facetBy.map(column => data.getColumnValue(column.value, i)));\n const xGroupKey = getFacetOrGroupKey(xGroupBy.map(column => data.getColumnValue(column.value, i)));\n const yGroupKey = getFacetOrGroupKey(yGroupBy.map(column => data.getColumnValue(column.value, i)));\n const xGroupLabel = xGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ');\n const yGroupLabel = yGroupBy.map(column => data.getColumnValue(column.valueLabels ?? column.value, i)).join(', ');\n result.meta.xGroupLabels[xGroupKey] = xGroupLabel;\n result.meta.yGroupLabels[yGroupKey] = yGroupLabel;\n const x = String(data.getColumnValue(xColumn.value, i));\n const y = String(data.getColumnValue(yColumn.value, i));\n\n const values = result.meta.valueSources.reduce((r, key) => {\n r[key] = (data.getColumnValue(valueColumns[key].value, i) ?? NAValueAs) as number | null;\n return r;\n }, {} as Record<string, DataValue>);\n\n if (x === 'null' || y === 'null' || Object.values(values).every(v => v === null)) {\n continue;\n }\n\n if (!result.facets[facetKey]) {\n result.facets[facetKey] = {\n xKeys: [],\n yKeys: [],\n xKeysByGroups: {},\n yKeysByGroups: {},\n cells: {},\n };\n }\n if (!result.facets[facetKey].xKeysByGroups[xGroupKey]) {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = [];\n }\n if (!result.facets[facetKey].yKeysByGroups[yGroupKey]) {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = [];\n }\n result.facets[facetKey].xKeys.push(x);\n result.facets[facetKey].yKeys.push(y);\n result.facets[facetKey].xKeysByGroups[xGroupKey].push(x);\n result.facets[facetKey].yKeysByGroups[yGroupKey].push(y);\n\n if (!result.facets[facetKey].cells[x]) {\n result.facets[facetKey].cells[x] = {};\n }\n\n for (const valueSource of result.meta.valueSources) {\n if (result.facets[facetKey].cells[x][y] && result.facets[facetKey].cells[x][y].value[valueSource] !== values[valueSource]) {\n throw Error(`More than 1 value for x=${x}, y=${y}`);\n }\n }\n\n const xLabelsSourceValue = data.getColumnValue(xLabelsSource, i);\n if (result.meta.xLabels[x] && String(xLabelsSourceValue) !== result.meta.xLabels[x]) {\n throw Error(`More than 1 x-label value for x=${x}`);\n }\n const yLabelsSourceValue = data.getColumnValue(yLabelsSource, i);\n if (result.meta.yLabels[y] && String(yLabelsSourceValue) !== result.meta.yLabels[y]) {\n throw Error(`More than 1 y-label value for y=${y}`);\n }\n result.meta.xLabels[x] = String(xLabelsSourceValue);\n result.meta.yLabels[y] = String(yLabelsSourceValue);\n // data for labels, annotations and dendrograms by X\n additionalDataColumnsX.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.xDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.xDataByKeys[columnKey][x] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.xDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.xDataByKeys[columnKey][x] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for x = ${x} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.xDataByKeys[columnKey][x] = data.getColumnValue(columnKey, i);\n }\n });\n // data for labels, annotations and dendrograms by Y\n additionalDataColumnsY.forEach(columnKey => {\n const isAddedColumn = typeof result.meta.yDataByKeys[columnKey] !== 'undefined';\n const isAddedValue = isAddedColumn && typeof result.meta.yDataByKeys[columnKey][y] !== 'undefined';\n if (!isAddedColumn) {\n result.meta.yDataByKeys[columnKey] = {};\n }\n if (isAddedValue && result.meta.yDataByKeys[columnKey][y] !== data.getColumnValue(columnKey, i)) {\n throw Error(`More than 1 value for y = ${y} and column = ${columnKey}`);\n }\n if (!isAddedValue) {\n result.meta.yDataByKeys[columnKey][y] = data.getColumnValue(columnKey, i);\n }\n });\n result.facets[facetKey].cells[x][y] = {\n isCell: true,\n idx: i,\n id: `${x}_${y}`,\n x,\n y,\n value: values,\n normalizedValue: values,\n };\n\n updateValueExtent(result, result.facets[facetKey].cells[x][y]);\n }\n\n result.meta.facetKeys = result.meta.facetKeys.filter((key) => result.facets[key]); // filter only used;\n\n // make uniq x, y, x-group and y-group keys\n result.meta.facetKeys.forEach(facetKey => {\n const facet = result.facets[facetKey];\n const uniqueXKeys = lodash.uniq(facet.xKeys);\n const uniqueYKeys = lodash.uniq(facet.yKeys);\n facet.xKeys = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], uniqueXKeys) : uniqueXKeys;\n facet.yKeys = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], uniqueYKeys) : uniqueYKeys;\n xGroupKeys.forEach(xGroupKey => {\n result.facets[facetKey].xKeysByGroups[xGroupKey] = lodash.intersection(\n facet.xKeys,\n result.facets[facetKey].xKeysByGroups[xGroupKey]\n );\n });\n yGroupKeys.forEach(yGroupKey => {\n result.facets[facetKey].yKeysByGroups[yGroupKey] = lodash.intersection(\n facet.yKeys,\n result.facets[facetKey].yKeysByGroups[yGroupKey]\n );\n });\n });\n\n applyAggregation(result, aggregation, additionalDataColumnsX, additionalDataColumnsY, annotations);\n applyNormalization(result, normalizationBySource);\n\n // every facet may contain not all of available keys, but for shared axes it is necessary to have all of them\n result.meta.xKeysByGroups = result.meta.xGroupKeys.reduce((res: Record<string, string[]>, xGroupKey) => {\n const existingXKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].xKeysByGroups[xGroupKey]))\n ), xAxis.sorting, result.meta.xLabels);\n res[xGroupKey] = keysOrder[xColumn.value] ? lodash.intersection(keysOrder[xColumn.value], existingXKeys) : existingXKeys;\n return res;\n }, {});\n result.meta.xKeys = result.meta.xGroupKeys.reduce((res: string[], xGroupKey: string) => {\n res = res.concat(result.meta.xKeysByGroups[xGroupKey]);\n return res;\n }, []);\n\n result.meta.yKeysByGroups = result.meta.yGroupKeys.reduce((res: Record<string, string[]>, yGroupKey) => {\n const existingYKeys = sortByLabels(lodash.uniq(\n lodash.flatten(result.meta.facetKeys.map(facetKey => result.facets[facetKey].yKeysByGroups[yGroupKey]))\n ), yAxis.sorting, result.meta.yLabels);\n res[yGroupKey] = keysOrder[yColumn.value] ? lodash.intersection(keysOrder[yColumn.value], existingYKeys) : existingYKeys;\n return res;\n }, {});\n result.meta.yKeys = result.meta.yGroupKeys.reduce((res: string[], yGroupKey: string) => {\n res = res.concat(result.meta.yKeysByGroups[yGroupKey]);\n return res;\n }, []);\n\n for (const valueSource of result.meta.valueSources) {\n // avoid render errors on empty data\n if (result.meta.valueExtent[valueSource][0] === Infinity) {\n result.meta.valueExtent[valueSource][0] = 0;\n }\n if (result.meta.valueExtent[valueSource][1] === -Infinity) {\n result.meta.valueExtent[valueSource][1] = 0;\n }\n }\n\n return result;\n}"],"names":["normalizeByStd","values","stdValue","deviation","meanValue","mean","v","normalizeByMinMax","min","max","extent","getNormalizationFn","method","aggregateNumeric","res","valuesSorted","a","b","quantileSorted","sum","exhaustive","aggregateString","list","getKeysCombinations","keysLists","result","keys","nextResult","key","resultItem","sortByLabels","arr","direction","labels","applyAggregation","aggregation","additionalDataColumnsX","additionalDataColumnsY","annotations","valueExtent","r","facetKey","xKeys","yKeys","cells","xKeysByGroups","yKeysByGroups","xGroups","xKey","yGroups","yKey","xNewKeys","yNewKeys","xGroupKey","yGroupKey","valuesBySources","valueSource","cellValue","_c","_b","_a","_d","value","cell","columnKey","annotation","updateValueExtent","applyNormalization","normalizationBySources","normalization","cellKeys","groupKeys","cellGetter","cellKey","groupKey","normalize","fillCellsData","data","xColumn","yColumn","valueColumns","facetBy","xGroupBy","yGroupBy","dendrogramX","dendrogramY","normalizationBySource","NAValueAs","keysOrder","xAxis","yAxis","facetKeysLists","column","xGroupKeysLists","yGroupKeysLists","facetKeysCombinations","xGroupKeysCombinations","yGroupKeysCombinations","facetKeys","getFacetOrGroupKey","xGroupKeys","yGroupKeys","facetLabels","getFacetLabels","index","xLabelsSource","yLabelsSource","annotationColumnsX","item","annotationColumnsY","dendrogramXColumns","dendrogramYColumns","lodash","i","xGroupLabel","yGroupLabel","x","y","xLabelsSourceValue","yLabelsSourceValue","isAddedColumn","isAddedValue","facet","uniqueXKeys","uniqueYKeys","existingXKeys","existingYKeys"],"mappings":";;;;;;;;;AAgEA,SAASA,GAAeC,GAAkB;AACtC,QAAMC,IAAWC,GAAUF,CAAM,GAC3BG,IAAYC,EAAKJ,CAAM;AAE7B,SAAIC,MAAa,UAAaE,MAAc,UAAaF,MAAa,IAC3D,CAACI,MAAcA,IAEnB,CAACA,OAAeA,IAAIF,KAAaF;AAC5C;AACA,SAASK,GAAkBN,GAAkB;AACzC,QAAMG,IAAYC,EAAKJ,CAAM,GACvB,CAACO,GAAKC,CAAG,IAAIC,GAAOT,CAAM;AAChC,SAAIG,MAAc,UAAaI,MAAQ,UAAaC,MAAQ,UAAaA,MAAQD,IACtE,CAACF,MAAcA,IAEnB,CAACA,OAAeA,IAAIF,MAAcK,IAAMD;AACnD;AAEA,SAASG,GAAmBC,GAA6BX,GAAkB;AACvE,SAAIW,MAAW,oBACJZ,GAAeC,CAAM,IAE5BW,MAAW,sBACJL,GAAkBN,CAAM,IAE5B,CAACK,MAAcA;AAC1B;AAEA,SAASO,EAAiBD,GAA2BX,GAAkB;AACnE,UAAQW,GAAA;AAAA,IACJ,KAAK,OAAO;AACR,UAAIE,IAAMb,EAAO,CAAC;AAClB,iBAAWK,KAAKL;AACZ,QAAAa,IAAM,KAAK,IAAIA,GAAKR,CAAC;AAEzB,aAAOQ;AAAA,IACX;AAAA,IACA,KAAK,OAAO;AACR,UAAIA,IAAMb,EAAO,CAAC;AAClB,iBAAWK,KAAKL;AACZ,QAAAa,IAAM,KAAK,IAAIA,GAAKR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AaxB,EAAUT,EAAQ,KAAK,GAAG+C,CAAa,IAAIA,GACpGhH;AAAA,EACX,GAAG,CAAA,CAAE,GACLW,EAAO,KAAK,QAAQA,EAAO,KAAK,WAAW,OAAO,CAACX,GAAewC,OAC9DxC,IAAMA,EAAI,OAAOW,EAAO,KAAK,cAAc6B,CAAS,CAAC,GAC9CxC,IACR,CAAA,CAAE;AAEL,aAAW0C,KAAe/B,EAAO,KAAK;AAElC,IAAIA,EAAO,KAAK,YAAY+B,CAAW,EAAE,CAAC,MAAM,UAC5C/B,EAAO,KAAK,YAAY+B,CAAW,EAAE,CAAC,IAAI,IAE1C/B,EAAO,KAAK,YAAY+B,CAAW,EAAE,CAAC,MAAM,WAC5C/B,EAAO,KAAK,YAAY+B,CAAW,EAAE,CAAC,IAAI;AAIlD,SAAO/B;AACX;"}
@@ -1,19 +1,18 @@
1
- import E from "../node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/extent.js";
2
- import V from "../node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/bin.js";
3
- import w from "../node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/max.js";
4
- import I from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/symlog.js";
5
- const F = (o, a) => {
6
- const e = Math.min(...a), t = Math.max(...a);
1
+ import C from "../node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/bin.js";
2
+ import K from "../node_modules/.pnpm/d3-array@3.2.4/node_modules/d3-array/src/max.js";
3
+ import E from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/symlog.js";
4
+ const V = (o, i) => {
5
+ const e = Math.min(...i), t = Math.max(...i);
7
6
  if (e === t)
8
7
  return [e];
9
8
  if (o < 2)
10
9
  return [(e + t) / 2];
11
- const s = (t - e) / o, m = [];
10
+ const a = (t - e) / o, l = [];
12
11
  for (let n = 1; n < o; n++)
13
- m.push(e + s * n);
14
- return m;
12
+ l.push(e + a * n);
13
+ return l;
15
14
  };
16
- function K(o, a, e) {
15
+ function w(o, i, e) {
17
16
  return o.map((t) => ({
18
17
  indexes: t,
19
18
  x: t.x0 ?? 0,
@@ -22,29 +21,29 @@ function K(o, a, e) {
22
21
  reverse: t.length
23
22
  },
24
23
  count: t.length,
25
- groupingKey: a,
24
+ groupingKey: i,
26
25
  groupingKeyIdx: e,
27
26
  width: (t.x1 ?? 0) - (t.x0 ?? 0)
28
27
  }));
29
28
  }
30
- function L(o, a, e, t, s, m, n) {
31
- const l = F(t, s), r = V().domain(s).thresholds(l).value((i) => o.getColumnValue(e.value, i))(a);
29
+ function F(o, i, e, t, a, l, n) {
30
+ const h = V(t, a), r = C().domain(a).thresholds(h).value((m) => o.getColumnValue(e.value, m))(i);
32
31
  return {
33
- bins: K(r, m, n),
34
- maxCount: w(r, (i) => i.length) ?? 0
32
+ bins: w(r, l, n),
33
+ maxCount: K(r, (m) => m.length) ?? 0
35
34
  };
36
35
  }
37
- function M(o, a, e, t, s, m, n) {
38
- const l = F(t, s), r = I().domain(s).range(s), i = l.map((c) => r.invert(c)), x = V().domain(s).thresholds(i).value((c) => o.getColumnValue(e.value, c))(a);
36
+ function L(o, i, e, t, a, l, n) {
37
+ const h = V(t, a), r = E().domain(a).range(a), m = h.map((u) => r.invert(u)), g = C().domain(a).thresholds(m).value((u) => o.getColumnValue(e.value, u))(i);
39
38
  return {
40
- bins: K(x, m, n),
41
- maxCount: w(x, (c) => c.length) ?? 0
39
+ bins: w(g, l, n),
40
+ maxCount: K(g, (u) => u.length) ?? 0
42
41
  };
43
42
  }
44
- function A(o, a, e, t, s, m) {
43
+ function I(o, i, e, t, a, l) {
45
44
  const n = {};
46
- return a.forEach((l) => {
47
- const r = l.join("_");
45
+ return i.forEach((h) => {
46
+ const r = h.join("_");
48
47
  n[r] = {
49
48
  groupingKeys: e,
50
49
  histogramByGroupingKey: {},
@@ -52,31 +51,33 @@ function A(o, a, e, t, s, m) {
52
51
  maxX: -1 / 0,
53
52
  maxCount: 0,
54
53
  maxCountFromGroups: 0
55
- };
56
- const i = o.getRowsByGrouping([...l]);
57
- let [x, c] = E(i, (u) => o.getColumnValue(t.value, u));
58
- x ?? (x = o.getColumnValue(t.value, i[0]) ?? 0), c ?? (c = o.getColumnValue(t.value, i[0]) ?? 0);
59
- const v = [x, c], B = [...e].reverse();
60
- B.forEach((u, g) => {
61
- const f = Array.from(o.getRowsByGrouping([...l, u])), p = m === "linear" ? L(o, f, t, s, v, u, g) : M(o, f, t, s, v, u, g);
62
- n[r].histogramByGroupingKey[u] = p, n[r].minX = v[0], n[r].maxX = v[1], n[r].maxCountFromGroups = Math.max(n[r].maxCountFromGroups, p.maxCount);
63
- const h = g > 0 ? B[g - 1] : null, y = h !== null ? n[r].histogramByGroupingKey[h] : null;
64
- p.bins.forEach((G, D) => {
65
- G.y.straight = ((y == null ? void 0 : y.bins[D].y.straight) ?? 0) + G.count, n[r].maxCount = Math.max(n[r].maxCount, G.y.straight);
54
+ }, o.getRowsByGrouping([...h]);
55
+ let m, g;
56
+ for (let c = 0; c < o.getColumn(t.value).length; c++) {
57
+ const s = o.getColumnValue(t.value, c);
58
+ s !== null && (m === void 0 || m > s) && (m = s), s !== null && (g === void 0 || g < s) && (g = s);
59
+ }
60
+ const u = [m ?? 0, g ?? 0], G = [...e].reverse();
61
+ G.forEach((c, s) => {
62
+ const x = Array.from(o.getRowsByGrouping([...h, c])), p = l === "linear" ? F(o, x, t, a, u, c, s) : L(o, x, t, a, u, c, s);
63
+ n[r].histogramByGroupingKey[c] = p, n[r].minX = u[0], n[r].maxX = u[1], n[r].maxCountFromGroups = Math.max(n[r].maxCountFromGroups, p.maxCount);
64
+ const y = s > 0 ? G[s - 1] : null, f = y !== null ? n[r].histogramByGroupingKey[y] : null;
65
+ p.bins.forEach((v, D) => {
66
+ v.y.straight = ((f == null ? void 0 : f.bins[D].y.straight) ?? 0) + v.count, n[r].maxCount = Math.max(n[r].maxCount, v.y.straight);
66
67
  });
67
68
  });
68
- const C = e;
69
- C.forEach((u, g) => {
70
- const f = g > 0 ? C[g - 1] : null, p = n[r].histogramByGroupingKey[u], h = f !== null ? n[r].histogramByGroupingKey[f] : null;
71
- p.bins.forEach((y, G) => {
72
- y.y.reverse = ((h == null ? void 0 : h.bins[G].y.reverse) ?? 0) + y.count;
69
+ const B = e;
70
+ B.forEach((c, s) => {
71
+ const x = s > 0 ? B[s - 1] : null, p = n[r].histogramByGroupingKey[c], y = x !== null ? n[r].histogramByGroupingKey[x] : null;
72
+ p.bins.forEach((f, v) => {
73
+ f.y.reverse = ((y == null ? void 0 : y.bins[v].y.reverse) ?? 0) + f.count;
73
74
  });
74
75
  });
75
76
  }), n;
76
77
  }
77
78
  export {
78
- A as createHistogramDataByFacets,
79
- L as createHistogramDataLinear,
80
- M as createHistogramDataLog
79
+ I as createHistogramDataByFacets,
80
+ F as createHistogramDataLinear,
81
+ L as createHistogramDataLog
81
82
  };
82
83
  //# sourceMappingURL=getHistogramData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getHistogramData.js","sources":["../../src/histogram/getHistogramData.ts"],"sourcesContent":["import type { Bin } from 'd3-array';\nimport { bin, extent, max } from 'd3-array';\nimport { scaleSymlog } from 'd3-scale';\nimport type { DataFrame, RowIndex } from '../DataFrame';\nimport type { ColumnName } from '../types';\n\nexport type BinData = {\n indexes: RowIndex[];\n x: number,\n y: {\n straight: number,\n reverse: number\n },\n count: number,\n groupingKey: string,\n groupingKeyIdx: number,\n width: number\n}\nexport type HistogramData = {\n bins: BinData[];\n maxCount: number;\n};\n\nexport type GroupedHistogramData = {\n groupingKeys: string[],\n histogramByGroupingKey: Record<string, HistogramData>\n minX: number;\n maxX: number;\n maxCount: number;\n maxCountFromGroups: number;\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 return [min];\n }\n if (count < 2) {\n return [(min + max) / 2];\n }\n const step = (max - min) / count;\n const steps = [];\n for (let i = 1; i < count; i++) {\n steps.push(min + step * i);\n }\n return steps;\n};\n\nfunction createBinData (bins:Bin<RowIndex, number>[], key:string, keyIdx:number):BinData[] {\n return bins.map((b) => ({\n indexes: b,\n x: b.x0 ?? 0,\n y: {\n straight: b.length,\n reverse: b.length\n },\n count: b.length,\n groupingKey: key,\n groupingKeyIdx: keyIdx,\n width: (b.x1 ?? 0) - (b.x0 ?? 0)\n }));\n}\nexport function createHistogramDataLinear(dataFrame: DataFrame, indexes: RowIndex[], column: ColumnName, binsCount:number, domain:[number, number], key:string, keyIdx:number):HistogramData {\n const ticks= getSteps(binsCount, domain);\n const bins = bin<RowIndex, number>()\n .domain(domain)\n .thresholds(ticks)\n .value((idx: RowIndex) => dataFrame.getColumnValue(column.value, idx) as number)(indexes);\n return {\n bins: createBinData(bins, key, keyIdx),\n maxCount: max(bins, (bin) => bin.length) ?? 0\n };\n}\nexport function createHistogramDataLog(dataFrame: DataFrame, indexes: RowIndex[], column: ColumnName, binsCount:number, domain:[number, number], key:string, keyIdx:number):HistogramData {\n const ticks= getSteps(binsCount, domain);\n const convertLog = scaleSymlog().domain(domain).range(domain);\n const ticksLog = ticks.map(t => convertLog.invert(t));\n const bins = bin<RowIndex, number>()\n .domain(domain)\n .thresholds(ticksLog)\n .value((idx: RowIndex) => dataFrame.getColumnValue(column.value, idx) as number)(indexes);\n\n return {\n bins: createBinData(bins, key, keyIdx),\n maxCount: max(bins, (bin) => bin.length) ?? 0\n };\n}\n\nexport function createHistogramDataByFacets(\n data:DataFrame,\n facetKeysCombinations:string[][],\n groupingKeys: string[],\n valueColumn:ColumnName,\n binsCount:number,\n scale: 'linear' | 'log'\n) {\n const result:Record<string, GroupedHistogramData> = {};\n facetKeysCombinations.forEach((facetKeys) => {\n const facetKey = facetKeys.join('_');\n result[facetKey] = {\n groupingKeys,\n histogramByGroupingKey: {},\n minX: Infinity,\n maxX: -Infinity,\n maxCount: 0,\n maxCountFromGroups: 0\n };\n const allFacetRowsIndexes = data.getRowsByGrouping([...facetKeys]);\n let [minV, maxV] = extent(allFacetRowsIndexes, idx => data.getColumnValue(valueColumn.value, idx) as number);\n minV ??= (data.getColumnValue(valueColumn.value, allFacetRowsIndexes[0]) ?? 0) as number;\n maxV ??= (data.getColumnValue(valueColumn.value, allFacetRowsIndexes[0]) ?? 0) as number;\n const domain:[number, number] = [minV, maxV];\n const forwardKeys = [...groupingKeys].reverse();\n forwardKeys.forEach((groupingKey, idx) => {\n const indexes = Array.from(data.getRowsByGrouping([...facetKeys, groupingKey]));\n const histogram = scale === 'linear'\n ? createHistogramDataLinear(data, indexes, valueColumn, binsCount, domain, groupingKey, idx)\n : createHistogramDataLog(data, indexes, valueColumn, binsCount, domain, groupingKey, idx);\n result[facetKey].histogramByGroupingKey[groupingKey] = histogram;\n result[facetKey].minX = domain[0];\n result[facetKey].maxX = domain[1];\n result[facetKey].maxCountFromGroups = Math.max(result[facetKey].maxCountFromGroups, histogram.maxCount);\n\n const previousKey = idx > 0 ? forwardKeys[idx - 1] : null;\n const previousHistogram = previousKey !== null ? result[facetKey].histogramByGroupingKey[previousKey] : null;\n\n histogram.bins.forEach((bin, idx) => {\n bin.y.straight = (previousHistogram?.bins[idx].y.straight ?? 0) + bin.count;\n result[facetKey].maxCount = Math.max(result[facetKey].maxCount, bin.y.straight);\n });\n });\n\n const reversedKeys = groupingKeys;\n reversedKeys.forEach((groupingKey, idx) => {\n const previousKey = idx > 0 ? reversedKeys[idx - 1] : null;\n const histogram = result[facetKey].histogramByGroupingKey[groupingKey];\n const previousHistogram = previousKey !== null ? result[facetKey].histogramByGroupingKey[previousKey] : null;\n\n histogram.bins.forEach((bin, idx) => {\n bin.y.reverse = (previousHistogram?.bins[idx].y.reverse ?? 0) + bin.count;\n });\n });\n });\n return result;\n}"],"names":["getSteps","count","valueExtent","min","max","step","steps","i","createBinData","bins","key","keyIdx","b","createHistogramDataLinear","dataFrame","indexes","column","binsCount","domain","ticks","bin","idx","createHistogramDataLog","convertLog","scaleSymlog","ticksLog","t","createHistogramDataByFacets","data","facetKeysCombinations","groupingKeys","valueColumn","scale","result","facetKeys","facetKey","allFacetRowsIndexes","minV","maxV","extent","forwardKeys","groupingKey","histogram","previousKey","previousHistogram","reversedKeys"],"mappings":";;;;AAgCA,MAAMA,IAAW,CAACC,GAAeC,MAA0B;AACvD,QAAMC,IAAM,KAAK,IAAI,GAAGD,CAAW,GAC7BE,IAAM,KAAK,IAAI,GAAGF,CAAW;AACnC,MAAIC,MAAQC;AACR,WAAO,CAACD,CAAG;AAEf,MAAIF,IAAQ;AACR,WAAO,EAAEE,IAAMC,KAAO,CAAC;AAE3B,QAAMC,KAAQD,IAAMD,KAAOF,GACrBK,IAAQ,CAAA;AACd,WAASC,IAAI,GAAGA,IAAIN,GAAOM;AACvB,IAAAD,EAAM,KAAKH,IAAME,IAAOE,CAAC;AAE7B,SAAOD;AACX;AAEA,SAASE,EAAeC,GAA8BC,GAAYC,GAAyB;AACvF,SAAOF,EAAK,IAAI,CAACG,OAAO;AAAA,IACpB,SAASA;AAAA,IACT,GAAGA,EAAE,MAAM;AAAA,IACX,GAAG;AAAA,MACC,UAAUA,EAAE;AAAA,MACZ,SAASA,EAAE;AAAA,IAAA;AAAA,IAEf,OAAOA,EAAE;AAAA,IACT,aAAaF;AAAA,IACb,gBAAgBC;AAAA,IAChB,QAAQC,EAAE,MAAM,MAAMA,EAAE,MAAM;AAAA,EAAA,EAChC;AACN;AACO,SAASC,EAA0BC,GAAsBC,GAAqBC,GAAoBC,GAAkBC,GAAyBR,GAAYC,GAA6B;AACzL,QAAMQ,IAAOnB,EAASiB,GAAWC,CAAM,GACjCT,IAAOW,IACR,OAAOF,CAAM,EACb,WAAWC,CAAK,EAChB,MAAM,CAACE,MAAkBP,EAAU,eAAeE,EAAO,OAAOK,CAAG,CAAW,EAAEN,CAAO;AAC5F,SAAO;AAAA,IACH,MAAMP,EAAcC,GAAMC,GAAKC,CAAM;AAAA,IACrC,UAAUP,EAAIK,GAAM,CAACW,MAAQA,EAAI,M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EAAU,KAAK,QAAQ,CAACtB,GAAKC,MAAQ;AACjCD,QAAAA,EAAI,EAAE,YAAWwB,KAAA,gBAAAA,EAAmB,KAAKvB,GAAK,EAAE,YAAW,KAAKD,EAAI;AAAA,MACxE,CAAC;AAAA,IACL,CAAC;AAAA,EACL,CAAC,GACMa;AACX;"}
1
+ {"version":3,"file":"getHistogramData.js","sources":["../../src/histogram/getHistogramData.ts"],"sourcesContent":["import type { Bin } from 'd3-array';\nimport { bin, max } from 'd3-array';\nimport { scaleSymlog } from 'd3-scale';\nimport type { DataFrame, RowIndex } from '../DataFrame';\nimport type { ColumnName } from '../types';\n\nexport type BinData = {\n indexes: RowIndex[];\n x: number,\n y: {\n straight: number,\n reverse: number\n },\n count: number,\n groupingKey: string,\n groupingKeyIdx: number,\n width: number\n}\nexport type HistogramData = {\n bins: BinData[];\n maxCount: number;\n};\n\nexport type GroupedHistogramData = {\n groupingKeys: string[],\n histogramByGroupingKey: Record<string, HistogramData>\n minX: number;\n maxX: number;\n maxCount: number;\n maxCountFromGroups: number;\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 return [min];\n }\n if (count < 2) {\n return [(min + max) / 2];\n }\n const step = (max - min) / count;\n const steps = [];\n for (let i = 1; i < count; i++) {\n steps.push(min + step * i);\n }\n return steps;\n};\n\nfunction createBinData (bins:Bin<RowIndex, number>[], key:string, keyIdx:number):BinData[] {\n return bins.map((b) => ({\n indexes: b,\n x: b.x0 ?? 0,\n y: {\n straight: b.length,\n reverse: b.length\n },\n count: b.length,\n groupingKey: key,\n groupingKeyIdx: keyIdx,\n width: (b.x1 ?? 0) - (b.x0 ?? 0)\n }));\n}\nexport function createHistogramDataLinear(dataFrame: DataFrame, indexes: RowIndex[], column: ColumnName, binsCount:number, domain:[number, number], key:string, keyIdx:number):HistogramData {\n const ticks = getSteps(binsCount, domain);\n const bins = bin<RowIndex, number>()\n .domain(domain)\n .thresholds(ticks)\n .value((idx: RowIndex) => dataFrame.getColumnValue(column.value, idx) as number)(indexes);\n return {\n bins: createBinData(bins, key, keyIdx),\n maxCount: max(bins, (bin) => bin.length) ?? 0\n };\n}\nexport function createHistogramDataLog(dataFrame: DataFrame, indexes: RowIndex[], column: ColumnName, binsCount:number, domain:[number, number], key:string, keyIdx:number):HistogramData {\n const ticks= getSteps(binsCount, domain);\n const convertLog = scaleSymlog().domain(domain).range(domain);\n const ticksLog = ticks.map(t => convertLog.invert(t));\n const bins = bin<RowIndex, number>()\n .domain(domain)\n .thresholds(ticksLog)\n .value((idx: RowIndex) => dataFrame.getColumnValue(column.value, idx) as number)(indexes);\n\n return {\n bins: createBinData(bins, key, keyIdx),\n maxCount: max(bins, (bin) => bin.length) ?? 0\n };\n}\n\nexport function createHistogramDataByFacets(\n data:DataFrame,\n facetKeysCombinations:string[][],\n groupingKeys: string[],\n valueColumn:ColumnName,\n binsCount:number,\n scale: 'linear' | 'log'\n) {\n const result:Record<string, GroupedHistogramData> = {};\n facetKeysCombinations.forEach((facetKeys) => {\n const facetKey = facetKeys.join('_');\n result[facetKey] = {\n groupingKeys,\n histogramByGroupingKey: {},\n minX: Infinity,\n maxX: -Infinity,\n maxCount: 0,\n maxCountFromGroups: 0\n };\n const allFacetRowsIndexes = data.getRowsByGrouping([...facetKeys]);\n let minV: number | undefined;\n let maxV: number | undefined;\n for (let i = 0; i < data.getColumn(valueColumn.value).length; i++) {\n const v = data.getColumnValue(valueColumn.value, i) as number;\n if (v !== null && (minV === undefined || minV > v)) {\n minV = v;\n }\n if (v !== null && (maxV === undefined || maxV < v)) {\n maxV = v;\n }\n }\n // minV ??= (data.getColumnValue(valueColumn.value, allFacetRowsIndexes[0]) ?? 0) as number;\n // maxV ??= (data.getColumnValue(valueColumn.value, allFacetRowsIndexes[0]) ?? 0) as number;\n const domain:[number, number] = [minV ?? 0, maxV ?? 0];\n const forwardKeys = [...groupingKeys].reverse();\n forwardKeys.forEach((groupingKey, idx) => {\n const indexes = Array.from(data.getRowsByGrouping([...facetKeys, groupingKey]));\n const histogram = scale === 'linear'\n ? createHistogramDataLinear(data, indexes, valueColumn, binsCount, domain, groupingKey, idx)\n : createHistogramDataLog(data, indexes, valueColumn, binsCount, domain, groupingKey, idx);\n result[facetKey].histogramByGroupingKey[groupingKey] = histogram;\n result[facetKey].minX = domain[0];\n result[facetKey].maxX = domain[1];\n result[facetKey].maxCountFromGroups = Math.max(result[facetKey].maxCountFromGroups, histogram.maxCount);\n\n const previousKey = idx > 0 ? forwardKeys[idx - 1] : null;\n const previousHistogram = previousKey !== null ? result[facetKey].histogramByGroupingKey[previousKey] : null;\n\n histogram.bins.forEach((bin, idx) => {\n bin.y.straight = (previousHistogram?.bins[idx].y.straight ?? 0) + bin.count;\n result[facetKey].maxCount = Math.max(result[facetKey].maxCount, bin.y.straight);\n });\n });\n\n const reversedKeys = groupingKeys;\n reversedKeys.forEach((groupingKey, idx) => {\n const previousKey = idx > 0 ? reversedKeys[idx - 1] : null;\n const histogram = result[facetKey].histogramByGroupingKey[groupingKey];\n const previousHistogram = previousKey !== null ? result[facetKey].histogramByGroupingKey[previousKey] : null;\n\n histogram.bins.forEach((bin, idx) => {\n bin.y.reverse = (previousHistogram?.bins[idx].y.reverse ?? 0) + bin.count;\n });\n });\n });\n return result;\n}"],"names":["getSteps","count","valueExtent","min","max","step","steps","i","createBinData","bins","key","keyIdx","b","createHistogramDataLinear","dataFrame","indexes","column","binsCount","domain","ticks","bin","idx","createHistogramDataLog","convertLog","scaleSymlog","ticksLog","t","createHistogramDataByFacets","data","facetKeysCombinations","groupingKeys","valueColumn","scale","result","facetKeys","facetKey","minV","maxV","v","forwardKeys","groupingKey","histogram","previousKey","previousHistogram","reversedKeys"],"mappings":";;;AAgCA,MAAMA,IAAW,CAACC,GAAeC,MAA0B;AACvD,QAAMC,IAAM,KAAK,IAAI,GAAGD,CAAW,GAC7BE,IAAM,KAAK,IAAI,GAAGF,CAAW;AACnC,MAAIC,MA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Chart {
14
14
  facetKeysCombinations: string[][];
15
15
  histogramDataByFacets: Record<string, GroupedHistogramData>;
16
16
  legendInfo: HistogramLegendInfo;
17
+ facetLabels: Record<string, string[]>;
17
18
  } | null;
18
19
  constructor(data: DataFrame, settings: HistogramSettings, eventHandlers?: HistogramEventHandlers);
19
20
  mount(node: HTMLElement): void;
@@ -1,49 +1,50 @@
1
- var E = Object.defineProperty;
2
- var b = (c, h, a) => h in c ? E(c, h, { enumerable: !0, configurable: !0, writable: !0, value: a }) : c[h] = a;
3
- var g = (c, h, a) => b(c, typeof h != "symbol" ? h + "" : h, a);
4
- import { l as x } from "../_virtual/lodash.js";
5
- import { s as w } from "../_virtual/server.browser.js";
6
- import { AbstractChart as A } from "../AbstractChart.js";
7
- import { getUnknownErrorInfo as p, isErrorInfo as m } from "../types/common.js";
1
+ var x = Object.defineProperty;
2
+ var w = (u, h, a) => h in u ? x(u, h, { enumerable: !0, configurable: !0, writable: !0, value: a }) : u[h] = a;
3
+ var g = (u, h, a) => w(u, typeof h != "symbol" ? h + "" : h, a);
4
+ import { l as A } from "../_virtual/lodash.js";
5
+ import { s as B } from "../_virtual/server.browser.js";
6
+ import { AbstractChart as S } from "../AbstractChart.js";
7
+ import { getUnknownErrorInfo as y, isErrorInfo as C } from "../types/common.js";
8
8
  import "../types/discrete.js";
9
9
  import "../types/scatterplot.js";
10
10
  import "../types/heatmap.js";
11
11
  import "../types/dendro.js";
12
12
  import "../types/histogram.js";
13
13
  import "../types/bubble.js";
14
- import { getKeysCombinations as S } from "../utils/getKeysCombination.js";
15
- import B from "./ChartRenderer.js";
16
- import { createHistogramDataByFacets as O } from "./getHistogramData.js";
17
- import { HistogramSettingsImpl as f } from "./HistogramSettingsImpl.js";
18
- import { MAX_FACETS_COUNT as C, MAX_GROUPS_COUNT as y } from "../constants.js";
19
- function D(c, h, a) {
14
+ import { getKeysCombinations as O } from "../utils/getKeysCombination.js";
15
+ import R from "./ChartRenderer.js";
16
+ import { createHistogramDataByFacets as K } from "./getHistogramData.js";
17
+ import { HistogramSettingsImpl as D } from "./HistogramSettingsImpl.js";
18
+ import { MAX_FACETS_COUNT as _, MAX_GROUPS_COUNT as b } from "../constants.js";
19
+ import { getFacetLabels as L } from "../discrete/utils/getFacetLabels.js";
20
+ function I(u, h, a) {
20
21
  return h.reduce((t, e) => {
21
- const n = c.getColumnCategories(e.value, !1), l = (r) => e.valueLabels ? String(c.getColumnValue(
22
+ const n = u.getColumnCategories(e.value, !1), l = (r) => e.valueLabels ? String(u.getColumnValue(
22
23
  e.valueLabels,
23
- c.getColumnCategoryRowIndex(e.value, r)
24
- )) : r, s = n.reduce((r, o) => (r[o] = l(o), r), {});
24
+ u.getColumnCategoryRowIndex(e.value, r)
25
+ )) : r, i = n.reduce((r, o) => (r[o] = l(o), r), {});
25
26
  return t[e.value] = {
26
- values: n.sort((r, o) => s[r].localeCompare(s[o], "en", { numeric: !0 })),
27
+ values: n.sort((r, o) => i[r].localeCompare(i[o], "en", { numeric: !0 })),
27
28
  aesMap: a[e.value],
28
- labels: s
29
+ labels: i
29
30
  }, t;
30
31
  }, {});
31
32
  }
32
- class z extends A {
33
+ class Y extends S {
33
34
  constructor(a, t, e) {
34
35
  super(a, t);
35
36
  g(this, "settings");
36
- g(this, "chartRenderer", new B());
37
+ g(this, "chartRenderer", new R());
37
38
  g(this, "onTooltipHintSwitch", () => {
38
39
  });
39
40
  g(this, "calculatedData", null);
40
- this.settings = new f(t), e && (this.onTooltipHintSwitch = e[0]);
41
+ this.settings = new D(t), e && (this.onTooltipHintSwitch = e[0]);
41
42
  }
42
43
  mount(a) {
43
44
  try {
44
45
  this.chartRenderer.init(a), this._updateData(), this._updateChart(), this.hasError = !1, this.errorInfo = null;
45
46
  } catch (t) {
46
- this.hasError = !0, t instanceof Error && (this.errorInfo = m(t.cause) ? t.cause : p(t), this.chartRenderer.renderError(t.message), console.error(t));
47
+ this.hasError = !0, t instanceof Error && (this.errorInfo = C(t.cause) ? t.cause : y(t), this.chartRenderer.renderError(t.message), console.error(t));
47
48
  }
48
49
  }
49
50
  unmount() {
@@ -52,62 +53,63 @@ class z extends A {
52
53
  updateSettingsAndData(a, t) {
53
54
  try {
54
55
  const e = this.settings, n = this.data;
55
- this.settings = new f(t), this.data = a, this._needUpdateCalculatedDataBySettings(e, this.settings) || this._needUpdateCalculatedDataByData(n, this.data) ? this._updateData() : this._updateAesInData(), this._updateChart(), this.hasError = !1, this.errorInfo = null;
56
+ this.settings = new D(t), this.data = a, this._needUpdateCalculatedDataBySettings(e, this.settings) || this._needUpdateCalculatedDataByData(n, this.data) ? this._updateData() : this._updateAesInData(), this._updateChart(), this.hasError = !1, this.errorInfo = null;
56
57
  } catch (e) {
57
- this.hasError = !0, e instanceof Error && (this.errorInfo = m(e.cause) ? e.cause : p(e), this.chartRenderer.renderError(e.message), console.error(e));
58
+ this.hasError = !0, e instanceof Error && (this.errorInfo = C(e.cause) ? e.cause : y(e), this.chartRenderer.renderError(e.message), console.error(e));
58
59
  }
59
60
  }
60
61
  updateChartState(a, t) {
61
62
  console.warn("no chart state for histogram");
62
63
  }
63
64
  export() {
64
- return this._updateChart(), w.renderToString(this.chartRenderer.component);
65
+ return this._updateChart(), B.renderToString(this.chartRenderer.component);
65
66
  }
66
67
  _needUpdateCalculatedDataBySettings(a, t) {
67
- var e, n, l, s;
68
+ var e, n, l, i;
68
69
  return a.valueColumn.value !== t.valueColumn.value || a.facetBy.some((r, o) => {
69
- var i;
70
- return r.value !== ((i = t.facetBy[o]) == null ? void 0 : i.value);
70
+ var s;
71
+ return r.value !== ((s = t.facetBy[o]) == null ? void 0 : s.value);
71
72
  }) || ((e = a.grouping) == null ? void 0 : e.value) !== ((n = t.grouping) == null ? void 0 : n.value) || a.layers.length !== t.layers.length || a.layers.some((r, o) => r.type !== t.layers[o].type) || a.binsCount !== t.binsCount || a.chartSettings.xAxis.scale !== t.chartSettings.xAxis.scale || ((l = a.groupingOrder) == null ? void 0 : l.some((r, o) => {
72
- var i;
73
- return r !== ((i = t.groupingOrder) == null ? void 0 : i[o]);
74
- })) || ((s = t.groupingOrder) == null ? void 0 : s.some((r, o) => {
75
- var i;
76
- return r !== ((i = a.groupingOrder) == null ? void 0 : i[o]);
73
+ var s;
74
+ return r !== ((s = t.groupingOrder) == null ? void 0 : s[o]);
75
+ })) || ((i = t.groupingOrder) == null ? void 0 : i.some((r, o) => {
76
+ var s;
77
+ return r !== ((s = a.groupingOrder) == null ? void 0 : s[o]);
77
78
  }));
78
79
  }
79
80
  _needUpdateCalculatedDataByData(a, t) {
80
81
  const e = Object.keys(a.data), n = Object.keys(t.data);
81
82
  return a.id !== t.id || e.length !== n.length || e.some((l) => {
82
- var s;
83
- return a.data[l].length !== ((s = t.data[l]) == null ? void 0 : s.length);
83
+ var i;
84
+ return a.data[l].length !== ((i = t.data[l]) == null ? void 0 : i.length);
84
85
  });
85
86
  }
86
87
  _updateData() {
87
- const { valueColumn: a, facetBy: t, grouping: e, binsCount: n, chartSettings: l, inheritedAes: s, groupingOrder: r } = this.settings, o = t.map((u) => this.data.getColumnCategories(u.value)), i = o.length ? S([...o]) : [["null"]];
88
- if (i.length > C) {
89
- const u = {
88
+ const { valueColumn: a, facetBy: t, grouping: e, binsCount: n, chartSettings: l, inheritedAes: i, groupingOrder: r } = this.settings, o = t.map((c) => this.data.getColumnCategories(c.value)), s = o.length ? O([...o]) : [["null"]];
89
+ if (s.length > _) {
90
+ const c = {
90
91
  type: "tooManyFacets",
91
- info: { count: i.length, maxCount: C }
92
+ info: { count: s.length, maxCount: _ }
92
93
  };
93
- throw Error(u.type, { cause: u });
94
+ throw Error(c.type, { cause: c });
94
95
  }
95
- const _ = t.map((u) => u.value) ?? null, I = e ? [e.value] : [];
96
+ const m = t.map((c) => c.value) ?? null, p = e ? [e.value] : [];
96
97
  let d = e ? this.data.getColumnCategories(e.value) : ["null"];
97
- if (d.length > y) {
98
- const u = {
98
+ if (d.length > b) {
99
+ const c = {
99
100
  type: "tooManyHistogramGroups",
100
- info: { count: d.length, maxCount: y }
101
+ info: { count: d.length, maxCount: b }
101
102
  };
102
- throw Error(u.type, { cause: u });
103
+ throw Error(c.type, { cause: c });
103
104
  }
104
- r && (d = x.intersection(r, d)), this.data.setGrouping([..._, ...I]);
105
- const v = O(this.data, i, d, a, n, l.xAxis.scale);
105
+ r && (d = A.intersection(r, d)), this.data.setGrouping([...m, ...p]);
106
+ const v = K(this.data, s, d, a, n, l.xAxis.scale), f = s.map((c) => c.join(", ")), E = L(this.data, t, f, s);
106
107
  this.calculatedData = {
107
- facetKeys: i.map((u) => u.join(", ")),
108
- facetKeysCombinations: i,
108
+ facetKeys: f,
109
+ facetKeysCombinations: s,
110
+ facetLabels: E,
109
111
  histogramDataByFacets: v,
110
- legendInfo: D(this.data, e ? [e] : [], s)
112
+ legendInfo: I(this.data, e ? [e] : [], i)
111
113
  };
112
114
  }
113
115
  _updateAesInData() {
@@ -116,27 +118,27 @@ class z extends A {
116
118
  _updateChart() {
117
119
  if (!this.calculatedData)
118
120
  return;
119
- const { id: a, chartSettings: t, facetSettings: e, inheritedAes: n, layers: l, grouping: s, groupingDirection: r, groupingStack: o } = this.settings;
120
- this.calculatedData.legendInfo = D(this.data, s ? [s] : [], n), this.chartRenderer.render(
121
+ const { facetLabels: a } = this.calculatedData, { id: t, chartSettings: e, facetSettings: n, inheritedAes: l, layers: i, grouping: r, groupingDirection: o, groupingStack: s, facetBy: m } = this.settings;
122
+ this.calculatedData.legendInfo = I(this.data, r ? [r] : [], l), this.chartRenderer.render(
121
123
  this.data,
122
- a,
123
124
  t,
124
125
  e,
126
+ n,
125
127
  this.calculatedData.facetKeys,
126
- this.calculatedData.facetKeysCombinations,
128
+ this.calculatedData.facetKeys.map((p) => a[p]),
127
129
  //for titles, if facet by more than 1 column
128
130
  this.calculatedData.histogramDataByFacets,
129
131
  this.calculatedData.legendInfo,
132
+ i,
130
133
  l,
131
- n,
134
+ r,
132
135
  s,
133
136
  o,
134
- r,
135
137
  this.onTooltipHintSwitch
136
138
  );
137
139
  }
138
140
  }
139
141
  export {
140
- z as ChartHistogram
142
+ Y as ChartHistogram
141
143
  };
142
144
  //# sourceMappingURL=index.js.map