@milaboratories/graph-maker 1.1.138 → 1.1.139
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/components/LassoControls/index.vue.js +15 -13
- package/dist/GraphMaker/components/LassoControls/index.vue.js.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeBubbleSettings.d.ts +9 -3
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeBubbleSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeDendroSettings.d.ts +17 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeDendroSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeDiscreteSettings.d.ts +13 -4
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeDiscreteSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts +28 -7
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHeatmapSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHistogramSettings.d.ts +6 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeHistogramSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.d.ts +16 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.d.ts.map +1 -1
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.d.ts +14 -2
- package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotUmapSettings.d.ts.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/DataFrame.js +95 -72
- package/dist/node_modules/@milaboratories/miplots4/dist/DataFrame.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/MiPlots.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/ChartRenderer.js +124 -122
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/components/Chart.js +72 -91
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/components/Chart.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/components/ChartsGroup.js +43 -41
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/components/ChartsGroup.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/getCellTooltip.js +28 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/getCellTooltip.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/getGroupedCellsData.js +94 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/getGroupedCellsData.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/index.js +42 -38
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/utils/calculateCaptionTails.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/common/Legend.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/common/Tooltip.js +11 -11
- package/dist/node_modules/@milaboratories/miplots4/dist/common/Tooltip.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/common/useDataFrame.js +20 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/common/useDataFrame.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/ChartRenderer.js +181 -181
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/DendroSettingsImpl.js +2 -2
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/DendroSettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/Chart.js +45 -45
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/Chart.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/Heatmap.js +27 -27
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/Heatmap.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/Legend.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/LinksGroup.js +18 -18
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/LinksGroup.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/NodesGroup.js +36 -36
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/components/NodesGroup.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/getHeatmapData.js +45 -41
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/getHeatmapData.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/getHierarchyData.js +33 -33
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/getHierarchyData.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/index.js +90 -93
- package/dist/node_modules/@milaboratories/miplots4/dist/dendro/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/ChartRenderer.js +200 -199
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/DiscreteSettingsImpl.js +17 -17
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/DiscreteSettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/components/layers/BoxElement.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/index.js +102 -99
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/bar.js +31 -36
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/bar.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/binnedDots.js +62 -74
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/binnedDots.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/boxes.js +52 -53
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/boxes.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/dots.js +32 -32
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/dots.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/lines.js +7 -6
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/lines.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/logo.js +23 -23
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/logo.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/pairedPoints.js +63 -63
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/pairedPoints.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/sina.js +60 -64
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/sina.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/stackedBar.js +23 -23
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/layers/stackedBar.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/utils/getOutliersBounds.js +5 -5
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/utils/getOutliersBounds.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/utils/splitTextByWidth.js +13 -13
- package/dist/node_modules/@milaboratories/miplots4/dist/discrete/utils/splitTextByWidth.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js +258 -256
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/HeatmapSettingsImpl.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/HeatmapSettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/Annotation.js +45 -44
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Annotations/Annotation.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/Chart.js +107 -106
- 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 +18 -18
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/components/ChartsGroup.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js +99 -95
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/getCells.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js +30 -29
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateAnnotationTitleSizes.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateAnnotationTitleSizes.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/heatmap/utils/calculateCaptionTails.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/ChartRenderer.js +143 -142
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/HistogramSettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/components/Chart.js +30 -30
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/components/Chart.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/components/ChartsGroup.js +7 -7
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/getHistogramData.js +53 -54
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/getHistogramData.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/index.js +59 -55
- package/dist/node_modules/@milaboratories/miplots4/dist/histogram/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/@d3fc/d3fc-axis/src/axisBase.js +7 -7
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-array/src/min.js +6 -12
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-array/src/min.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-shape/src/line.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/kdbush/index.js +148 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/kdbush/index.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ChartRenderer.js +172 -168
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ScatterplotSettingsImpl.js +26 -26
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/ScatterplotSettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/Chart.js +11 -11
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartAxisTitles.js +30 -29
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartAxisTitles.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartLayersData.js +135 -153
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartLayersData.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartTooltip.js +35 -32
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartTooltip.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartTrendsData.js +27 -27
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartTrendsData.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/components/ChartsGroup.js +14 -14
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/constants.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/dots.js +24 -22
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/dots.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/getLayersData.js +11 -14
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/getLayersData.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/index.js +57 -58
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/linearRegression.js +85 -83
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/linearRegression.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/createAesGetter.js +20 -20
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/createAesGetter.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/createLegendInfo.js +44 -37
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/createLegendInfo.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/formatColumnValue.js +11 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/formatColumnValue.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/getVisibleLabels.js +46 -56
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot/utils/getVisibleLabels.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/ChartRenderer.js +223 -205
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/ChartRenderer.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/SettingsImpl.js +22 -22
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/SettingsImpl.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/colors.js +42 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/colors.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/LowerSVG.js +84 -81
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/LowerSVG.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/SVGLayer.js +11 -11
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/UpperSVG.js +15 -14
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/components/UpperSVG.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/index.js +89 -114
- package/dist/node_modules/@milaboratories/miplots4/dist/scatterplot-umap/index.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/common.js +3 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/common.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/dendro.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/dendro.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/discrete.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/discrete.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/heatmap.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/heatmap.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/histogram.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/histogram.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/scatterplot-umap.js +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/scatterplot-umap.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/types/scatterplot.js +4 -4
- package/dist/node_modules/@milaboratories/miplots4/dist/types/scatterplot.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/TextMeasurer/TextMeasurer.js +39 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/TextMeasurer/TextMeasurer.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/TextMeasurer/charToWidth.json.js +101 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/TextMeasurer/charToWidth.json.js.map +1 -0
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/arrangeLegendParts.js +4 -4
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/arrangeLegendParts.js.map +1 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/getLegendWidth.js +3 -3
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/getLegendWidth.js.map +1 -1
- package/dist/node_modules/@milaboratories/pf-plots/dist/index.js +1031 -1023
- package/dist/node_modules/@milaboratories/pf-plots/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/getCells.js +0 -91
- package/dist/node_modules/@milaboratories/miplots4/dist/bubble/getCells.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/add.js +0 -30
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/add.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/cover.js +0 -29
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/cover.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/data.js +0 -12
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/data.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/extent.js +0 -7
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/extent.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/find.js +0 -26
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/find.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/quad.js +0 -7
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/quad.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/quadtree.js +0 -51
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/quadtree.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/remove.js +0 -21
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/remove.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/root.js +0 -7
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/root.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/size.js +0 -12
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/size.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/visit.js +0 -14
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/visit.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/visitAfter.js +0 -19
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/visitAfter.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/x.js +0 -11
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/x.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/y.js +0 -11
- package/dist/node_modules/@milaboratories/miplots4/dist/node_modules/d3-quadtree/src/y.js.map +0 -1
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/TextMeasurer.js +0 -24
- package/dist/node_modules/@milaboratories/miplots4/dist/utils/TextMeasurer.js.map +0 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { getFacetStringKey as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
4
|
-
let
|
|
1
|
+
import { getFacetStringKey as S } from "../utils/getFacetStringKey.js";
|
|
2
|
+
import z from "../../node_modules/d3-array/src/sum.js";
|
|
3
|
+
function v(e, o, m, p) {
|
|
4
|
+
let t = -1 / 0;
|
|
5
5
|
return {
|
|
6
6
|
type: "logo",
|
|
7
|
-
geoms:
|
|
8
|
-
const s =
|
|
9
|
-
return
|
|
10
|
-
let
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const h =
|
|
7
|
+
geoms: o.facet.reduce((n, l) => {
|
|
8
|
+
const s = S(l);
|
|
9
|
+
return n[s] = [], o.primary.forEach((i) => {
|
|
10
|
+
let g = 0;
|
|
11
|
+
const a = {};
|
|
12
|
+
o.secondary.forEach((r) => {
|
|
13
|
+
const h = m.getRowsByGrouping([...l, i, r]);
|
|
14
14
|
if (!h.length)
|
|
15
15
|
return;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
height:
|
|
16
|
+
const f = Array.from(h).map((y) => Number(m.getColumnValue(p.value, y))), u = z(f);
|
|
17
|
+
a[String(r)] = {
|
|
18
|
+
height: u,
|
|
19
19
|
key: String(r)
|
|
20
|
-
},
|
|
20
|
+
}, g += u;
|
|
21
21
|
});
|
|
22
|
-
const c =
|
|
23
|
-
e.normalize &&
|
|
24
|
-
|
|
25
|
-
}),
|
|
22
|
+
const c = g;
|
|
23
|
+
e.normalize && o.secondary.forEach((r) => {
|
|
24
|
+
a[String(r)] && (a[String(r)].height = a[String(r)].height / c * 100);
|
|
25
|
+
}), t = Math.max(t, g), n[s].push({
|
|
26
26
|
key: `logo_${String(i)}`,
|
|
27
|
-
valuesMap:
|
|
27
|
+
valuesMap: a,
|
|
28
28
|
primaryGrouping: i,
|
|
29
29
|
boundsY: { min: 0, max: e.normalize ? c : 100 }
|
|
30
30
|
});
|
|
31
|
-
}),
|
|
31
|
+
}), n;
|
|
32
32
|
}, {}),
|
|
33
|
-
meta: { minY: 0, maxY: e.normalize ? 100 :
|
|
33
|
+
meta: { minY: 0, maxY: e.normalize ? 100 : t, normalize: e.normalize },
|
|
34
34
|
aes: e.aes
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
export {
|
|
38
|
-
|
|
38
|
+
v as getLogoData
|
|
39
39
|
};
|
|
40
40
|
//# sourceMappingURL=logo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logo.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/discrete/layers/logo.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"logo.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/discrete/layers/logo.ts"],"sourcesContent":["import { sum } from 'd3-array';\nimport type { DataFrame, GroupKey } from '../../DataFrame';\nimport type { ColumnName } from '../../types';\nimport type { LogoPlotLayer } from '../DiscreteSettingsImpl';\nimport { getFacetStringKey } from '../utils/getFacetStringKey';\nimport type { LogoPlotData } from './types';\n\ntype LetterPart = {\n height: number,\n key: string\n}\n\nexport type LogoStack = {\n key: string;\n valuesMap: Record<string, LetterPart>;\n primaryGrouping: string;\n boundsY: {\n min: number;\n max: number;\n };\n};\n\nexport function getLogoData(\n layer: LogoPlotLayer,\n groupingKeys: {\n facet: GroupKey[][],\n primary: GroupKey[],\n secondary: GroupKey[]\n },\n data: DataFrame,\n y: ColumnName,\n): LogoPlotData {\n let maxY = -Infinity;\n\n return {\n type: 'logo',\n geoms: groupingKeys.facet.reduce((res: Record<string, LogoStack[]>, facetKey) => {\n const strFacetKey = getFacetStringKey(facetKey);\n res[strFacetKey] = [];\n groupingKeys.primary.forEach(primaryKey => {\n let currentHeight = 0;\n const letterParts:Record<string, LetterPart> = {};\n groupingKeys.secondary.forEach(secondaryKey => {\n const indexes = data.getRowsByGrouping([...facetKey, primaryKey, secondaryKey]);\n if (!indexes.length) {\n return;\n }\n const values = Array.from(indexes).map(i => Number(data.getColumnValue(y.value, i)));\n const height = sum(values);\n letterParts[String(secondaryKey)] = {\n height,\n key: String(secondaryKey),\n };\n currentHeight += height;\n });\n const maxStackHeight = currentHeight;\n if (layer.normalize) { // show in percents of every stack\n groupingKeys.secondary.forEach(secondaryKey => {\n if (!letterParts[String(secondaryKey)]) {\n return;\n }\n letterParts[String(secondaryKey)].height = letterParts[String(secondaryKey)].height / maxStackHeight * 100;\n });\n }\n maxY = Math.max(maxY, currentHeight);\n res[strFacetKey].push({\n key: `logo_${String(primaryKey)}`,\n valuesMap: letterParts,\n primaryGrouping: primaryKey,\n boundsY: {min: 0, max: layer.normalize ? maxStackHeight : 100},\n } as LogoStack);\n });\n return res;\n }, {}),\n meta: {minY: 0, maxY: layer.normalize ? 100 : maxY, normalize: layer.normalize},\n aes: layer.aes,\n };\n}\n"],"names":["getLogoData","layer","groupingKeys","data","y","maxY","res","facetKey","strFacetKey","getFacetStringKey","primaryKey","currentHeight","letterParts","secondaryKey","indexes","values","i","height","sum","maxStackHeight"],"mappings":";;AAsBO,SAASA,EACZC,GACAC,GAKAC,GACAC,GACY;AACZ,MAAIC,IAAO;AAEX,SAAO;AAAA,IACH,MAAM;AAAA,IACN,OAAOH,EAAa,MAAM,OAAO,CAACI,GAAkCC,MAAa;AAC7E,YAAMC,IAAcC,EAAkBF,CAAQ;AAC9C,aAAAD,EAAIE,CAAW,IAAI,CAAA,GACnBN,EAAa,QAAQ,QAAQ,CAAAQ,MAAc;AACvC,YAAIC,IAAgB;AACpB,cAAMC,IAAyC,CAAA;AAC/CV,UAAa,UAAU,QAAQ,CAAAW,MAAgB;AAC3C,gBAAMC,IAAUX,EAAK,kBAAkB,CAAC,GAAGI,GAAUG,GAAYG,CAAY,CAAC;AAC9E,cAAI,CAACC,EAAQ;AACT;AAEJ,gBAAMC,IAAS,MAAM,KAAKD,CAAO,EAAE,IAAI,CAAAE,MAAK,OAAOb,EAAK,eAAeC,EAAE,OAAOY,CAAC,CAAC,CAAC,GAC7EC,IAASC,EAAIH,CAAM;AACzBH,UAAAA,EAAY,OAAOC,CAAY,CAAC,IAAI;AAAA,YAChC,QAAAI;AAAAA,YACA,KAAK,OAAOJ,CAAY;AAAA,UAAA,GAE5BF,KAAiBM;AAAAA,QACrB,CAAC;AACD,cAAME,IAAiBR;AACnBV,QAAAA,EAAM,aACNC,EAAa,UAAU,QAAQ,CAAAW,MAAgB;AACtCD,UAAAA,EAAY,OAAOC,CAAY,CAAC,MAGrCD,EAAY,OAAOC,CAAY,CAAC,EAAE,SAASD,EAAY,OAAOC,CAAY,CAAC,EAAE,SAAUM,IAAiB;AAAA,QAC5G,CAAC,GAELd,IAAO,KAAK,IAAIA,GAAMM,CAAa,GACnCL,EAAIE,CAAW,EAAE,KAAK;AAAA,UAClB,KAAK,QAAQ,OAAOE,CAAU,CAAC;AAAA,UAC/B,WAAWE;AAAAA,UACX,iBAAiBF;AAAAA,UACjB,SAAS,EAAC,KAAK,GAAG,KAAKT,EAAM,YAAYkB,IAAiB,IAAA;AAAA,QAAA,CAChD;AAAA,MAClB,CAAC,GACMb;AAAAA,IACX,GAAG,CAAA,CAAE;AAAA,IACL,MAAM,EAAC,MAAM,GAAG,MAAML,EAAM,YAAY,MAAMI,GAAM,WAAWJ,EAAM,UAAA;AAAA,IACrE,KAAKA,EAAM;AAAA,EAAA;AAEnB;","x_google_ignoreList":[0]}
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { l as S } from "../../node_modules/lodash/lodash.js";
|
|
2
|
+
import { getOutliersBounds as b } from "../utils/getOutliersBounds.js";
|
|
3
|
+
import "../../utils/TextMeasurer/TextMeasurer.js";
|
|
4
|
+
import { getFacetStringKey as Y } from "../utils/getFacetStringKey.js";
|
|
5
|
+
function x(o, t) {
|
|
6
|
+
if (t.length === 2)
|
|
6
7
|
return "secondary";
|
|
7
|
-
if (
|
|
8
|
+
if (o.length === 2 && t.length < 2)
|
|
8
9
|
return "primary";
|
|
9
10
|
throw Error("Too many groups for paired points layer");
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
throw Error(`Non unique keys in groups ${String(
|
|
15
|
-
if (
|
|
16
|
-
throw Error(`Keys in groups ${String(
|
|
17
|
-
const
|
|
18
|
-
let
|
|
19
|
-
const
|
|
20
|
-
let
|
|
21
|
-
const
|
|
22
|
-
return (
|
|
12
|
+
function B(o, t, m, M, $, k, y) {
|
|
13
|
+
const p = S.groupBy(m, (e) => e.link), g = S.groupBy(M, (e) => e.link), a = Object.keys(p), s = Object.keys(g);
|
|
14
|
+
if (S.uniq(a).length !== a.length || S.uniq(s).length !== s.length)
|
|
15
|
+
throw Error(`Non unique keys in groups ${String(o)}, ${String(t)} for paired points layer`);
|
|
16
|
+
if (a.length !== s.length || S.intersection(a, s).length !== a.length)
|
|
17
|
+
throw Error(`Keys in groups ${String(o)}, ${String(t)} not match for paired points layer`);
|
|
18
|
+
const h = (e) => e.y;
|
|
19
|
+
let r = 1 / 0, n = -1 / 0, d = !1;
|
|
20
|
+
const l = y === "log";
|
|
21
|
+
let v = a.map((e) => {
|
|
22
|
+
const u = p[e][0], c = g[e][0], f = h(u), i = h(c);
|
|
23
|
+
return (f === 0 || i === 0) && (d = !0), r = Math.min(r, l && f === 0 ? 1 / 0 : f, l && i === 0 ? 1 / 0 : i), n = Math.max(n, l && f === 0 ? -1 / 0 : f, l && i === 0 ? -1 / 0 : i), {
|
|
23
24
|
id: e,
|
|
24
|
-
key1: { id: `${e}_${String(
|
|
25
|
-
key2: { id: `${e}_${String(
|
|
25
|
+
key1: { id: `${e}_${String(o)}`, value: f, data: u },
|
|
26
|
+
key2: { id: `${e}_${String(t)}`, value: i, data: c }
|
|
26
27
|
};
|
|
27
28
|
});
|
|
28
|
-
if (!
|
|
29
|
-
|
|
30
|
-
const [e,
|
|
31
|
-
|
|
29
|
+
if (!k) {
|
|
30
|
+
r = 1 / 0, n = -1 / 0;
|
|
31
|
+
const [e, u] = b(m.map(h), y), [c, f] = b(M.map(h), y);
|
|
32
|
+
v = v.filter(({ key1: i, key2: w }) => i.value < e || i.value > u || w.value < c || w.value > f ? !1 : (r = Math.min(r, l && i.value === 0 ? 1 / 0 : i.value, l && w.value === 0 ? 1 / 0 : w.value), n = Math.max(n, l && i.value === 0 ? -1 / 0 : i.value, l && w.value === 0 ? -1 / 0 : w.value), !0));
|
|
32
33
|
}
|
|
33
|
-
return
|
|
34
|
-
id: `${String(
|
|
35
|
-
key1: String(
|
|
36
|
-
key2: String(
|
|
37
|
-
pairs:
|
|
34
|
+
return r = d ? r / 10 : r, n = Math.max(n, r), {
|
|
35
|
+
id: `${String(o)}_${String(t)}`,
|
|
36
|
+
key1: String(o),
|
|
37
|
+
key2: String(t),
|
|
38
|
+
pairs: v.map((e) => ({
|
|
38
39
|
...e,
|
|
39
|
-
key1: { ...e.key1, value: e.key1.value === 0 ?
|
|
40
|
-
key2: { ...e.key2, value: e.key2.value === 0 ?
|
|
40
|
+
key1: { ...e.key1, value: e.key1.value === 0 ? r : e.key1.value },
|
|
41
|
+
key2: { ...e.key2, value: e.key2.value === 0 ? r : e.key2.value }
|
|
41
42
|
})),
|
|
42
|
-
grouping:
|
|
43
|
-
boundsY: { min:
|
|
43
|
+
grouping: $,
|
|
44
|
+
boundsY: { min: r, max: n }
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
function E(o, t, m, M, $) {
|
|
48
|
+
const k = x(t.primary, t.secondary), y = (a) => ({
|
|
49
|
+
y: Number(m.getColumnValue(M.value, a)),
|
|
50
|
+
link: m.getColumnValue(o.linkColumn.value, a)
|
|
51
|
+
});
|
|
52
|
+
let p = 1 / 0, g = -1 / 0;
|
|
49
53
|
return {
|
|
50
54
|
type: "pairedPoints",
|
|
51
|
-
geoms:
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
const [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
i,
|
|
58
|
-
t,
|
|
59
|
-
n.linkColumn,
|
|
60
|
-
S,
|
|
55
|
+
geoms: t.facet.reduce((a, s) => {
|
|
56
|
+
const h = Y(s);
|
|
57
|
+
if (a[h] = [], k === "primary") {
|
|
58
|
+
const [r, n] = t.primary, d = m.getRowsByGrouping([...s, r]), l = m.getRowsByGrouping([...s, n]), v = Array.from(d).map(y), e = Array.from(l).map(y), u = B(
|
|
59
|
+
r,
|
|
60
|
+
n,
|
|
61
61
|
v,
|
|
62
|
-
|
|
62
|
+
e,
|
|
63
|
+
k,
|
|
64
|
+
o.aes.showOutliers,
|
|
63
65
|
$.scale
|
|
64
66
|
);
|
|
65
|
-
|
|
66
|
-
} else
|
|
67
|
-
const [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
v,
|
|
75
|
-
n.aes.showOutliers,
|
|
67
|
+
p = Math.min(p, u.boundsY.min), g = Math.max(g, u.boundsY.max), a[h].push(u);
|
|
68
|
+
} else k === "secondary" && t.primary.forEach((r) => {
|
|
69
|
+
const [n, d] = t.secondary, l = m.getRowsByGrouping([...s, r, n]), v = m.getRowsByGrouping([...s, r, d]), e = Array.from(l).map(y), u = Array.from(v).map(y), c = B(
|
|
70
|
+
n,
|
|
71
|
+
d,
|
|
72
|
+
e,
|
|
73
|
+
u,
|
|
74
|
+
k,
|
|
75
|
+
o.aes.showOutliers,
|
|
76
76
|
$.scale
|
|
77
77
|
);
|
|
78
|
-
|
|
78
|
+
p = Math.min(p, c.boundsY.min), g = Math.max(g, c.boundsY.max), a[h].push(c);
|
|
79
79
|
});
|
|
80
|
-
return
|
|
80
|
+
return a;
|
|
81
81
|
}, {}),
|
|
82
|
-
meta: { minY:
|
|
83
|
-
aes:
|
|
82
|
+
meta: { minY: p, maxY: g },
|
|
83
|
+
aes: o.aes
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
export {
|
|
87
|
-
|
|
87
|
+
E as getPairedPointsData
|
|
88
88
|
};
|
|
89
89
|
//# sourceMappingURL=pairedPoints.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pairedPoints.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/discrete/layers/pairedPoints.ts"],"sourcesContent":["import type {GroupKey} from '../../DataFrame';\nimport type {DataFrame} from '../../DataFrame';\nimport type {DiscreteSettingsImpl} from '../DiscreteSettingsImpl';\nimport type {PairedPointsLayer} from '../DiscreteSettingsImpl';\nimport type {PairedPointsData} from './types';\nimport {getOutliersBounds} from '../utils';\nimport {getFacetStringKey} from '../utils/getFacetStringKey';\nimport type {ColumnName, Row} from '../../types';\nimport lodash from 'lodash';\n\ntype Point = {\n id: string;\n value: number;\n data: Row;\n};\n\nexport type PairedPoints = {\n id: string;\n key1: string;\n key2: string;\n grouping: 'primary' | 'secondary';\n pairs: {key1: Point; key2: Point; id: string}[];\n boundsY: {\n min: number;\n max: number;\n };\n};\n\nfunction getGroupingType(primaryKeys: GroupKey[], secondaryKeys: GroupKey[]) {\n if (secondaryKeys.length === 2) {\n return 'secondary';\n }\n if (primaryKeys.length === 2 && secondaryKeys.length < 2) {\n return 'primary';\n }\n throw Error('Too many groups for paired points layer');\n}\n\nfunction getPairedGroup(\n key1: GroupKey,\n key2: GroupKey,\n rowsGroup1: Row[],\n rowsGroup2: Row[],\n linkColumn: ColumnName,\n yColumn: ColumnName,\n grouping: 'primary' | 'secondary',\n showOutliers: boolean,\n scale: 'linear' | 'log'\n): PairedPoints {\n const group1 = lodash.groupBy(rowsGroup1, row => row[linkColumn.value]);\n const group2 = lodash.groupBy(rowsGroup2, row => row[linkColumn.value]);\n const pointKeys1 = Object.keys(group1);\n const pointKeys2 = Object.keys(group2);\n // Sets of point ids from group 1 and group 2 must be the same and must contain unique ids\n if (lodash.uniq(pointKeys1).length !== pointKeys1.length || lodash.uniq(pointKeys2).length !== pointKeys2.length) {\n throw Error(`Non unique keys in groups ${String(key1)}, ${String(key2)} for paired points layer`);\n }\n if (\n pointKeys1.length !== pointKeys2.length ||\n lodash.intersection(pointKeys1, pointKeys2).length !== pointKeys1.length\n ) {\n throw Error(`Keys in groups ${String(key1)}, ${String(key2)} not match for paired points layer`);\n }\n\n const yGetter = (row: Row) => Number(row[yColumn.value]);\n let min = Infinity;\n let max = -Infinity;\n let hasZero = false;\n const isLog = scale === 'log';\n let pairs = pointKeys1.map(pairKey => {\n const p1 = group1[pairKey][0];\n const p2 = group2[pairKey][0];\n const v1 = yGetter(p1);\n const v2 = yGetter(p2);\n if (v1 === 0 || v2 === 0) {\n hasZero = true;\n }\n min = Math.min(min, isLog && v1 === 0 ? Infinity : v1, isLog && v2 === 0 ? Infinity : v2);\n max = Math.max(max, isLog && v1 === 0 ? -Infinity : v1, isLog && v2 === 0 ? -Infinity : v2);\n return {\n id: pairKey,\n key1: {id: `${pairKey}_${String(key1)}`, value: v1, data: p1},\n key2: {id: `${pairKey}_${String(key2)}`, value: v2, data: p2},\n };\n });\n if (!showOutliers) {\n min = Infinity;\n max = -Infinity;\n const [boundsMin1, boundMax1] = getOutliersBounds(rowsGroup1, scale, yGetter);\n const [boundsMin2, boundMax2] = getOutliersBounds(rowsGroup2, scale, yGetter);\n pairs = pairs.filter(({key1, key2}) => {\n const outlier =\n key1.value < boundsMin1 || key1.value > boundMax1 || key2.value < boundsMin2 || key2.value > boundMax2;\n if (outlier) {\n return false;\n }\n min = Math.min(min, isLog && key1.value === 0 ? Infinity : key1.value, isLog && key2.value === 0 ? Infinity : key2.value);\n max = Math.max(max, isLog && key1.value === 0 ? -Infinity : key1.value, isLog && key2.value === 0 ? -Infinity : key2.value);\n return true;\n });\n }\n min = hasZero ? min / 10 : min;\n max = Math.max(max, min);\n return {\n id: `${String(key1)}_${String(key2)}`,\n key1: String(key1),\n key2: String(key2),\n pairs: pairs.map(pair => ({\n ...pair,\n key1: {...pair.key1, value: pair.key1.value === 0 ? min : pair.key1.value},\n key2: {...pair.key2, value: pair.key2.value === 0 ? min : pair.key2.value},\n })),\n grouping,\n boundsY: {min, max},\n };\n}\n\nexport function getPairedPointsData(\n layer: PairedPointsLayer,\n groupingKeys: {\n facet: GroupKey[][],\n primary: GroupKey[],\n secondary: GroupKey[]\n },\n data: DataFrame,\n y: ColumnName,\n yAxis: DiscreteSettingsImpl['chartSettings']['yAxis']\n): PairedPointsData {\n const grouping = getGroupingType(groupingKeys.primary, groupingKeys.secondary);\n let minY = Infinity;\n let maxY = -Infinity;\n\n return {\n type: 'pairedPoints',\n geoms: groupingKeys.facet.reduce((res: Record<string, PairedPoints[]>, facetKey) => {\n const strFacetKey = getFacetStringKey(facetKey);\n res[strFacetKey] = [];\n if (grouping === 'primary') {\n const [key1, key2] = groupingKeys.primary;\n const group1 = data.getRowsByGrouping([...facetKey, key1]);\n const group2 = data.getRowsByGrouping([...facetKey, key2]);\n const pairedPointsGroup = getPairedGroup(\n key1,\n key2,\n group1,\n group2,\n layer.linkColumn,\n y,\n grouping,\n layer.aes.showOutliers,\n yAxis.scale\n );\n minY = Math.min(minY, pairedPointsGroup.boundsY.min);\n maxY = Math.max(maxY, pairedPointsGroup.boundsY.max);\n res[strFacetKey].push(pairedPointsGroup);\n } else if (grouping === 'secondary') {\n groupingKeys.primary.forEach(primaryKey => {\n const [key1, key2] = groupingKeys.secondary;\n const group1 = data.getRowsByGrouping([...facetKey, primaryKey, key1]);\n const group2 = data.getRowsByGrouping([...facetKey, primaryKey, key2]);\n const pairedPointsGroup = getPairedGroup(\n key1,\n key2,\n group1,\n group2,\n layer.linkColumn,\n y,\n grouping,\n layer.aes.showOutliers,\n yAxis.scale\n );\n minY = Math.min(minY, pairedPointsGroup.boundsY.min);\n maxY = Math.max(maxY, pairedPointsGroup.boundsY.max);\n res[strFacetKey].push(pairedPointsGroup);\n });\n }\n return res;\n }, {}),\n meta: {minY, maxY},\n aes: layer.aes,\n };\n}\n"],"names":["getGroupingType","primaryKeys","secondaryKeys","getPairedGroup","key1","key2","rowsGroup1","rowsGroup2","linkColumn","yColumn","grouping","showOutliers","scale","group1","lodash","n","row","group2","pointKeys1","pointKeys2","yGetter","min","max","hasZero","isLog","pairs","pairKey","p1","p2","v1","v2","boundsMin1","boundMax1","getOutliersBounds","boundsMin2","boundMax2","pair","getPairedPointsData","layer","groupingKeys","data","y","yAxis","minY","maxY","res","facetKey","strFacetKey","getFacetStringKey","pairedPointsGroup","primaryKey"],"mappings":";;;AA4BA,SAASA,EAAgBC,GAAyBC,GAA2B;AACzE,MAAIA,EAAc,WAAW;AACzB,WAAO;AAEX,MAAID,EAAY,WAAW,KAAKC,EAAc,SAAS;AACnD,WAAO;AAEX,QAAM,MAAM,yCAAyC;AACzD;AAEA,SAASC,EACLC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACY;AACZ,QAAMC,IAASC,EAAO,QAAQR,GAAY,CAAAS,MAAOC,EAAIR,EAAW,KAAK,CAAC,GAChES,IAASH,EAAO,QAAQP,GAAY,CAAAQ,MAAOC,EAAIR,EAAW,KAAK,CAAC,GAChEU,IAAa,OAAO,KAAKL,CAAM,GAC/BM,IAAa,OAAO,KAAKF,CAAM;AAErC,MAAIH,EAAO,KAAKI,CAAU,EAAE,WAAWA,EAAW,UAAUJ,EAAO,KAAKK,CAAU,EAAE,WAAWA,EAAW;AACtG,UAAM,MAAM,6BAA6B,OAAOf,CAAI,CAAC,KAAK,OAAOC,CAAI,CAAC,0BAA0B;AAEpG,MACIa,EAAW,WAAWC,EAAW,UACjCL,EAAO,aAAaI,GAAYC,CAAU,EAAE,WAAWD,EAAW;AAElE,UAAM,MAAM,kBAAkB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AEnB;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"pairedPoints.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/discrete/layers/pairedPoints.ts"],"sourcesContent":["import {\n groupBy,\n intersection,\n uniq\n} from 'lodash';\nimport type { DataFrame, GroupKey } from '../../DataFrame';\nimport type { ColumnName, DataValue, Row } from '../../types';\nimport type { DiscreteSettingsImpl, PairedPointsLayer } from '../DiscreteSettingsImpl';\nimport { getOutliersBounds } from '../utils';\nimport { getFacetStringKey } from '../utils/getFacetStringKey';\nimport type { PairedPointsData } from './types';\n\ntype Point = {\n id: string;\n value: number;\n data: Row;\n};\n\nexport type PairedPoints = {\n id: string;\n key1: string;\n key2: string;\n grouping: 'primary' | 'secondary';\n pairs: {key1: Point; key2: Point; id: string}[];\n boundsY: {\n min: number;\n max: number;\n };\n};\n\nfunction getGroupingType(primaryKeys: GroupKey[], secondaryKeys: GroupKey[]) {\n if (secondaryKeys.length === 2) {\n return 'secondary';\n }\n if (primaryKeys.length === 2 && secondaryKeys.length < 2) {\n return 'primary';\n }\n throw Error('Too many groups for paired points layer');\n}\n\nfunction getPairedGroup(\n key1: GroupKey,\n key2: GroupKey,\n rowsGroup1: {y: number, link: DataValue}[],\n rowsGroup2: {y: number, link: DataValue}[],\n grouping: 'primary' | 'secondary',\n showOutliers: boolean,\n scale: 'linear' | 'log'\n): PairedPoints {\n const group1 = groupBy(rowsGroup1, row => row.link);\n const group2 = groupBy(rowsGroup2, row => row.link);\n const pointKeys1 = Object.keys(group1);\n const pointKeys2 = Object.keys(group2);\n // Sets of point ids from group 1 and group 2 must be the same and must contain unique ids\n if (uniq(pointKeys1).length !== pointKeys1.length || uniq(pointKeys2).length !== pointKeys2.length) {\n throw Error(`Non unique keys in groups ${String(key1)}, ${String(key2)} for paired points layer`);\n }\n if (\n pointKeys1.length !== pointKeys2.length ||\n intersection(pointKeys1, pointKeys2).length !== pointKeys1.length\n ) {\n throw Error(`Keys in groups ${String(key1)}, ${String(key2)} not match for paired points layer`);\n }\n\n const yGetter = (value: {y: number}) => value.y;\n let min = Infinity;\n let max = -Infinity;\n let hasZero = false;\n const isLog = scale === 'log';\n let pairs = pointKeys1.map(pairKey => {\n const p1 = group1[pairKey][0];\n const p2 = group2[pairKey][0];\n const v1 = yGetter(p1);\n const v2 = yGetter(p2);\n if (v1 === 0 || v2 === 0) {\n hasZero = true;\n }\n min = Math.min(min, isLog && v1 === 0 ? Infinity : v1, isLog && v2 === 0 ? Infinity : v2);\n max = Math.max(max, isLog && v1 === 0 ? -Infinity : v1, isLog && v2 === 0 ? -Infinity : v2);\n return {\n id: pairKey,\n key1: {id: `${pairKey}_${String(key1)}`, value: v1, data: p1},\n key2: {id: `${pairKey}_${String(key2)}`, value: v2, data: p2},\n };\n });\n if (!showOutliers) {\n min = Infinity;\n max = -Infinity;\n const [boundsMin1, boundMax1] = getOutliersBounds(rowsGroup1.map(yGetter), scale);\n const [boundsMin2, boundMax2] = getOutliersBounds(rowsGroup2.map(yGetter), scale);\n pairs = pairs.filter(({key1, key2}) => {\n const outlier =\n key1.value < boundsMin1 || key1.value > boundMax1 || key2.value < boundsMin2 || key2.value > boundMax2;\n if (outlier) {\n return false;\n }\n min = Math.min(min, isLog && key1.value === 0 ? Infinity : key1.value, isLog && key2.value === 0 ? Infinity : key2.value);\n max = Math.max(max, isLog && key1.value === 0 ? -Infinity : key1.value, isLog && key2.value === 0 ? -Infinity : key2.value);\n return true;\n });\n }\n min = hasZero ? min / 10 : min;\n max = Math.max(max, min);\n return {\n id: `${String(key1)}_${String(key2)}`,\n key1: String(key1),\n key2: String(key2),\n pairs: pairs.map(pair => ({\n ...pair,\n key1: {...pair.key1, value: pair.key1.value === 0 ? min : pair.key1.value},\n key2: {...pair.key2, value: pair.key2.value === 0 ? min : pair.key2.value},\n })),\n grouping,\n boundsY: {min, max},\n };\n}\n\nexport function getPairedPointsData(\n layer: PairedPointsLayer,\n groupingKeys: {\n facet: GroupKey[][],\n primary: GroupKey[],\n secondary: GroupKey[]\n },\n data: DataFrame,\n y: ColumnName,\n yAxis: DiscreteSettingsImpl['chartSettings']['yAxis']\n): PairedPointsData {\n const grouping = getGroupingType(groupingKeys.primary, groupingKeys.secondary);\n const groupGetter = (idx: number) => {\n return {\n y: Number(data.getColumnValue(y.value, idx)),\n link: data.getColumnValue(layer.linkColumn.value, idx),\n };\n };\n let minY = Infinity;\n let maxY = -Infinity;\n\n return {\n type: 'pairedPoints',\n geoms: groupingKeys.facet.reduce((res: Record<string, PairedPoints[]>, facetKey) => {\n const strFacetKey = getFacetStringKey(facetKey);\n res[strFacetKey] = [];\n if (grouping === 'primary') {\n const [key1, key2] = groupingKeys.primary;\n const group1Indexes = data.getRowsByGrouping([...facetKey, key1]);\n const group2Indexes = data.getRowsByGrouping([...facetKey, key2]);\n\n const group1 = Array.from(group1Indexes).map(groupGetter);\n const group2 = Array.from(group2Indexes).map(groupGetter);\n const pairedPointsGroup = getPairedGroup(\n key1,\n key2,\n group1,\n group2,\n grouping,\n layer.aes.showOutliers,\n yAxis.scale\n );\n minY = Math.min(minY, pairedPointsGroup.boundsY.min);\n maxY = Math.max(maxY, pairedPointsGroup.boundsY.max);\n res[strFacetKey].push(pairedPointsGroup);\n } else if (grouping === 'secondary') {\n groupingKeys.primary.forEach(primaryKey => {\n const [key1, key2] = groupingKeys.secondary;\n const group1Indexes = data.getRowsByGrouping([...facetKey, primaryKey, key1]);\n const group2Indexes = data.getRowsByGrouping([...facetKey, primaryKey, key2]);\n const group1 = Array.from(group1Indexes).map(groupGetter);\n const group2 = Array.from(group2Indexes).map(groupGetter);\n const pairedPointsGroup = getPairedGroup(\n key1,\n key2,\n group1,\n group2,\n grouping,\n layer.aes.showOutliers,\n yAxis.scale\n );\n minY = Math.min(minY, pairedPointsGroup.boundsY.min);\n maxY = Math.max(maxY, pairedPointsGroup.boundsY.max);\n res[strFacetKey].push(pairedPointsGroup);\n });\n }\n return res;\n }, {}),\n meta: {minY, maxY},\n aes: layer.aes,\n };\n}\n"],"names":["getGroupingType","primaryKeys","secondaryKeys","getPairedGroup","key1","key2","rowsGroup1","rowsGroup2","grouping","showOutliers","scale","group1","groupBy","row","group2","pointKeys1","pointKeys2","uniq","intersection","yGetter","value","min","max","hasZero","isLog","pairs","pairKey","p1","p2","v1","v2","boundsMin1","boundMax1","getOutliersBounds","boundsMin2","boundMax2","pair","getPairedPointsData","layer","groupingKeys","data","y","yAxis","groupGetter","idx","minY","maxY","res","facetKey","strFacetKey","getFacetStringKey","group1Indexes","group2Indexes","pairedPointsGroup","primaryKey"],"mappings":";;;;AA8BA,SAASA,EAAgBC,GAAyBC,GAA2B;AACzE,MAAIA,EAAc,WAAW;AACzB,WAAO;AAEX,MAAID,EAAY,WAAW,KAAKC,EAAc,SAAS;AACnD,WAAO;AAEX,QAAM,MAAM,yCAAyC;AACzD;AAEA,SAASC,EACLC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACY;AACZ,QAAMC,IAASC,EAAAA,QAAQN,GAAY,CAAAO,MAAOA,EAAI,IAAI,GAC5CC,IAASF,EAAAA,QAAQL,GAAY,CAAAM,MAAOA,EAAI,IAAI,GAC5CE,IAAa,OAAO,KAAKJ,CAAM,GAC/BK,IAAa,OAAO,KAAKF,CAAM;AAErC,MAAIG,EAAAA,KAAKF,CAAU,EAAE,WAAWA,EAAW,UAAUE,EAAAA,KAAKD,CAAU,EAAE,WAAWA,EAAW;AACxF,UAAM,MAAM,6BAA6B,OAAOZ,CAAI,CAAC,KAAK,OAAOC,CAAI,CAAC,0BAA0B;AAEpG,MACIU,EAAW,WAAWC,EAAW,UACjCE,EAAAA,aAAaH,GAAYC,CAAU,EAAE,WAAWD,EAAW;AAE3D,UAAM,MAAM,kBAAkB,OAAOX,CAAI,CAAC,KAAK,OAAOC,CAAI,CAAC,oCAAoC;AAGnG,QAAMc,IAAU,CAACC,MAAuBA,EAAM;AAC9C,MAAIC,IAAM,OACNC,IAAM,QACNC,IAAU;AACd,QAAMC,IAAQd,MA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;AAEL,aAAON;AAAAA,IACX,GAAG,CAAA,CAAE;AAAA,IACL,MAAM,EAAC,MAAAF,GAAM,MAAAC,EAAAA;AAAAA,IACb,KAAKR,EAAM;AAAA,EAAA;AAEnB;","x_google_ignoreList":[0]}
|
|
@@ -1,96 +1,92 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import Y from "../../node_modules/lodash/lodash.js";
|
|
2
|
+
import { getOutliersBounds as v } from "../utils/getOutliersBounds.js";
|
|
3
|
+
import "../../utils/TextMeasurer/TextMeasurer.js";
|
|
4
|
+
import { getFacetStringKey as D } from "../utils/getFacetStringKey.js";
|
|
5
|
+
import G from "../../node_modules/d3-random/src/lcg.js";
|
|
5
6
|
import q from "../../node_modules/d3-scale/src/linear.js";
|
|
6
|
-
import
|
|
7
|
-
import { quantileSorted as
|
|
8
|
-
import
|
|
9
|
-
var
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
-
return function(
|
|
13
|
-
return r.map(function(
|
|
14
|
-
return
|
|
7
|
+
import E from "../../node_modules/d3-array/src/max.js";
|
|
8
|
+
import { quantileSorted as S } from "../../node_modules/d3-array/src/quantile.js";
|
|
9
|
+
import M from "../../node_modules/d3-array/src/mean.js";
|
|
10
|
+
var O = Object.defineProperty, $ = (t, r, n) => r in t ? O(t, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[r] = n, f = (t, r, n) => $(t, typeof r != "symbol" ? r + "" : r, n);
|
|
11
|
+
const B = 30;
|
|
12
|
+
function j(t, r) {
|
|
13
|
+
return function(n) {
|
|
14
|
+
return r.map(function(i) {
|
|
15
|
+
return M(n, (c) => t(i - c));
|
|
15
16
|
});
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function k(t) {
|
|
19
20
|
return function(r) {
|
|
20
21
|
return 1 / Math.sqrt(2 * Math.PI) * Math.pow(Math.E, -0.5 * Math.pow(r / t, 2));
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
const r =
|
|
25
|
-
return
|
|
24
|
+
function C(t) {
|
|
25
|
+
const r = M(t);
|
|
26
|
+
return M(t.map((n) => Math.pow(n - r, 2)));
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
return Math.sqrt(
|
|
28
|
+
function I(t) {
|
|
29
|
+
return Math.sqrt(C(t));
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
const r =
|
|
32
|
-
return 1.06 * Math.min(
|
|
31
|
+
function P(t) {
|
|
32
|
+
const r = S(t, 0.25), n = (S(t, 0.75) - r) / 1.34, i = I(t);
|
|
33
|
+
return 1.06 * Math.min(i, n) * Math.pow(t.length, -1 / 5);
|
|
33
34
|
}
|
|
34
|
-
class
|
|
35
|
-
constructor(r,
|
|
36
|
-
|
|
37
|
-
const
|
|
35
|
+
class R {
|
|
36
|
+
constructor(r, n, i, c, g) {
|
|
37
|
+
f(this, "key"), f(this, "maxDensity"), f(this, "primaryGrouping"), f(this, "secondaryGrouping"), f(this, "points"), f(this, "boundsY");
|
|
38
|
+
const y = B;
|
|
38
39
|
if (r.length === 0)
|
|
39
40
|
throw Error("Unable to calculate sina on empty data");
|
|
40
|
-
this.primaryGrouping = String(
|
|
41
|
-
const
|
|
41
|
+
this.primaryGrouping = String(i), this.secondaryGrouping = String(c), this.key = `sina_${this.primaryGrouping}_${this.secondaryGrouping}`;
|
|
42
|
+
const e = (o) => n === "log" ? Math.log10(o) : o, x = (o) => n === "log" ? Math.pow(10, o) : o, s = r.filter((o) => n === "log" && o === 0 ? (console.warn("Value = 0 on chart with log scale, it was removed from calculation"), !1) : !0).sort((o, h) => e(o) - e(h)), u = s.map(e), p = u[0], l = u[s.length - 1], d = (l - p) / y, b = P(u), m = Y.range(p + d, l, d);
|
|
42
43
|
this.boundsY = {
|
|
43
|
-
min:
|
|
44
|
-
max: l
|
|
44
|
+
min: x(p),
|
|
45
|
+
max: x(l)
|
|
45
46
|
};
|
|
46
|
-
const
|
|
47
|
-
this.maxDensity =
|
|
48
|
-
x:
|
|
49
|
-
y:
|
|
50
|
-
id: String(
|
|
51
|
-
jitter:
|
|
52
|
-
data: n
|
|
47
|
+
const a = j(k(b), m)(u), w = q().domain(m).range(a).clamp(!0);
|
|
48
|
+
this.maxDensity = E(a), this.points = s.map((o, h) => ({
|
|
49
|
+
x: o,
|
|
50
|
+
y: w(e(o)) / this.maxDensity,
|
|
51
|
+
id: String(h),
|
|
52
|
+
jitter: g()
|
|
53
53
|
}));
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
let
|
|
58
|
-
const
|
|
56
|
+
function H(t, r, n, i, c) {
|
|
57
|
+
let g = 0, y = 1 / 0, e = -1 / 0;
|
|
58
|
+
const x = G(1);
|
|
59
59
|
return {
|
|
60
60
|
type: "sina",
|
|
61
|
-
geoms: r.facet.reduce((
|
|
62
|
-
const p =
|
|
63
|
-
return
|
|
64
|
-
r.secondary.forEach((
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
61
|
+
geoms: r.facet.reduce((s, u) => {
|
|
62
|
+
const p = D(u);
|
|
63
|
+
return s[p] = [], r.primary.forEach((l) => {
|
|
64
|
+
r.secondary.forEach((d) => {
|
|
65
|
+
const b = n.getRowsByGrouping([...u, l, d]);
|
|
66
|
+
if (!b.length)
|
|
67
67
|
return;
|
|
68
|
-
let
|
|
68
|
+
let m = Array.from(b).map((w) => Number(n.getColumnValue(i.value, w)));
|
|
69
69
|
if (!t.aes.showOutliers) {
|
|
70
|
-
const w
|
|
71
|
-
|
|
72
|
-
const f = w(n);
|
|
73
|
-
return f >= M && f <= S;
|
|
74
|
-
});
|
|
70
|
+
const [w, o] = v(m, c.scale);
|
|
71
|
+
m = m.filter((h) => h >= w && h <= o);
|
|
75
72
|
}
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
c
|
|
73
|
+
const a = new R(
|
|
74
|
+
m,
|
|
75
|
+
c.scale,
|
|
76
|
+
l,
|
|
77
|
+
d,
|
|
78
|
+
x
|
|
83
79
|
);
|
|
84
|
-
|
|
80
|
+
a.maxDensity > g && (g = a.maxDensity), a.boundsY.min < y && (y = a.boundsY.min), a.boundsY.max > e && (e = a.boundsY.max), s[p].push(a);
|
|
85
81
|
});
|
|
86
|
-
}),
|
|
82
|
+
}), s;
|
|
87
83
|
}, {}),
|
|
88
|
-
meta: { maxDensity:
|
|
84
|
+
meta: { maxDensity: g, minY: y, maxY: e },
|
|
89
85
|
aes: t.aes
|
|
90
86
|
};
|
|
91
87
|
}
|
|
92
88
|
export {
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
R as Sina,
|
|
90
|
+
H as getSinaData
|
|
95
91
|
};
|
|
96
92
|
//# sourceMappingURL=sina.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sina.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/discrete/layers/sina.ts"],"sourcesContent":["import type {GroupKey, NO_GROUPED} from '../../DataFrame';\nimport type {DataFrame} from '../../DataFrame';\nimport type {DiscreteSettingsImpl, SinaLayer} from '../DiscreteSettingsImpl';\nimport type {SinaData} from './types';\nimport {getOutliersBounds} from '../utils';\nimport {getFacetStringKey} from '../utils/getFacetStringKey';\nimport type {ColumnName, DataValue, Row} from '../../types';\nimport {max, mean, quantileSorted} from 'd3-array';\nimport {randomLcg} from 'd3-random';\nimport {scaleLinear} from 'd3-scale';\nimport lodash from 'lodash';\n\nconst DEFAULT_STEPS_COUNT = 30;\n\nfunction kernelDensityEstimator(kernel: (v: number) => number, thresholds: number[]) {\n return function (arr: number[]) {\n return thresholds.map(function (x):number {\n return mean(arr, v => kernel(x - v)) as number;\n });\n };\n}\n\nfunction kernelGaussian(bandwidth: number) {\n return function (v: number) {\n return (1 / Math.sqrt(2 * Math.PI)) * Math.pow(Math.E, -0.5 * Math.pow(v / bandwidth, 2));\n };\n}\n\nfunction getVariance(arr: number[]) {\n const vMean = mean(arr) as number;\n\n return mean(arr.map(v => Math.pow(v - vMean, 2))) as number;\n}\nfunction getStandardDeviation(arr: number[]) {\n return Math.sqrt(getVariance(arr));\n}\nfunction nrdBandwidth(arr: number[]) {\n const q1 = quantileSorted(arr, 0.25) as number;\n const q3 = quantileSorted(arr, 0.75) as number;\n const iqr = q3 - q1;\n const h = iqr / 1.34;\n const sigma = getStandardDeviation(arr);\n\n return 1.06 * Math.min(sigma, h) * Math.pow(arr.length, -1 / 5);\n}\n\nexport class Sina {\n key: string;\n maxDensity: number;\n primaryGrouping: string;\n secondaryGrouping: string;\n\n points: {x: number, y: number, jitter: number, id: string, data: Row}[];\n\n boundsY: {\n min: number;\n max: number;\n };\n\n constructor(\n rowValues: Row[],\n y:ColumnName,\n scale: 'linear' | 'log',\n primaryGrouping: DataValue | typeof NO_GROUPED,\n secondaryGrouping: DataValue | typeof NO_GROUPED,\n getJitter: () => number\n ) {\n const stepsCount = DEFAULT_STEPS_COUNT;\n if (rowValues.length === 0) {\n throw Error('Unable to calculate sina on empty data');\n }\n\n this.primaryGrouping = String(primaryGrouping);\n this.secondaryGrouping = String(secondaryGrouping);\n this.key = `sina_${this.primaryGrouping}_${this.secondaryGrouping}`;\n\n const convertToScale = (v: number) => (scale === 'log' ? Math.log10(v) : v);\n const convertFromScale = (v: number) => (scale === 'log' ? Math.pow(10, v) : v);\n const getterY = (r:Row) => Number(r[y.value]);\n\n const sortedGroup = rowValues\n .filter((r:Row) => {\n if (scale === 'log' && getterY(r) === 0) {\n console.warn('Value = 0 on chart with log scale, it was removed from calculation');\n return false;\n }\n return true;\n })\n .sort((a, b) => convertToScale(getterY(a)) - convertToScale(getterY(b)));\n const sortedValues = sortedGroup.map((r) => convertToScale(getterY(r)));\n const minV = sortedValues[0];\n const maxV = sortedValues[sortedGroup.length - 1];\n const xRange = maxV - minV;\n const step = xRange / stepsCount;\n const bandwidth = nrdBandwidth(sortedValues);\n const thresholds = lodash.range(minV + step, maxV, step);\n\n this.boundsY = {\n min: convertFromScale(minV),\n max: convertFromScale(maxV),\n };\n\n const kde = kernelDensityEstimator(kernelGaussian(bandwidth), thresholds);\n const density = kde(sortedValues);\n const scaleY = scaleLinear().domain(thresholds).range(density).clamp(true);\n\n this.maxDensity = max(density) as number;\n\n this.points = sortedGroup.map((row:Row, idx) => {\n return {\n x: getterY(row),\n y: scaleY(convertToScale(getterY(row))) / this.maxDensity,\n id: String(idx),\n jitter: getJitter(),\n data: row\n };\n });\n }\n}\n\nexport function getSinaData(\n layer: SinaLayer,\n groupingKeys: {\n facet: GroupKey[][],\n primary: GroupKey[],\n secondary: GroupKey[]\n },\n data: DataFrame,\n y: DiscreteSettingsImpl['y'],\n yAxis: DiscreteSettingsImpl['chartSettings']['yAxis']\n): SinaData {\n let maxDensity = 0;\n let minY = Infinity;\n let maxY = -Infinity;\n const getJitter = randomLcg(1);\n\n const geoms = groupingKeys.facet.reduce((res: Record<string, Sina[]>, facetKey) => {\n const strFacetKey = getFacetStringKey(facetKey);\n res[strFacetKey] = [];\n groupingKeys.primary.forEach(primaryKey => {\n groupingKeys.secondary.forEach(secondaryKey => {\n const values = data.getRowsByGrouping([...facetKey, primaryKey, secondaryKey]);\n if (!values.length) {\n return;\n }\n let valuesFiltered = values;\n if (!layer.aes.showOutliers) {\n const yGetter = (r:Row) => Number(r[y.value]);\n const [boundsMin, boundMax] = getOutliersBounds(values, yAxis.scale, yGetter);\n valuesFiltered = values.filter((row: Row) => {\n const value = yGetter(row);\n return value >= boundsMin && value <= boundMax;\n });\n }\n const sina = new Sina(\n valuesFiltered,\n y,\n yAxis.scale,\n primaryKey,\n secondaryKey,\n getJitter\n );\n\n if (sina.maxDensity > maxDensity) {\n maxDensity = sina.maxDensity;\n }\n if (sina.boundsY.min < minY) {\n minY = sina.boundsY.min;\n }\n if (sina.boundsY.max > maxY) {\n maxY = sina.boundsY.max;\n }\n res[strFacetKey].push(sina);\n });\n });\n return res;\n }, {});\n\n return {\n type: 'sina',\n geoms,\n meta: {maxDensity, minY, maxY},\n aes: layer.aes,\n };\n}\n"],"names":["DEFAULT_STEPS_COUNT","kernelDensityEstimator","kernel","thresholds","arr","x","mean","v","kernelGaussian","bandwidth","getVariance","vMean","getStandardDeviation","nrdBandwidth","q1","quantileSorted","h","sigma","Sina","rowValues","y","scale","primaryGrouping","secondaryGrouping","getJitter","__publicField","stepsCount","convertToScale","convertFromScale","getterY","r","sortedGroup","a","b","sortedValues","minV","maxV","step","lodash","density","scaleY","scaleLinear","max","row","idx","getSinaData","layer","groupingKeys","data","yAxis","maxDensity","minY","maxY","randomLcg","res","facetKey","strFacetKey","getFacetStringKey","primaryKey","secondaryKey","values","valuesFiltered","yGetter","boundsMin","boundMax","getOutliersBounds","value","sina"],"mappings":";;;;;;;;;AAYA,MAAMA,IAAsB;AAE5B,SAASC,EAAuBC,GAA+BC,GAAsB;AACjF,SAAO,SAAUC,GAAe;AAC5B,WAAOD,EAAW,IAAI,SAAUE,GAAU;AACtC,aAAOC,EAAKF,GAAK,CAAAG,MAAKL,EAAOG,IAAIE,CAAC,CAAC;AAAA,IACvC,CAAC;AAAA,EACL;AACJ;AAEA,SAASC,EAAeC,GAAmB;AACvC,SAAO,SAAUF,GAAW;AACxB,WAAQ,IAAI,KAAK,KAAK,IAAI,KAAK,EAAE,IAAK,KAAK,IAAI,KAAK,GAAG,OAAO,KAAK,IAAIA,IAAIE,GAAW,CAAC,CAAC;AAAA,EAC5F;AACJ;AAEA,SAASC,EAAYN,GAAe;AAChC,QAAMO,IAAQL,EAAKF,CAAG;AAEtB,SAAOE,EAAKF,EAAI,IAAI,CAAAG,MAAK,KAAK,IAAIA,IAAII,GAAO,CAAC,CAAC,CAAC;AACpD;AACA,SAASC,EAAqBR,GAAe;AACzC,SAAO,KAAK,KAAKM,EAAYN,CAAG,CAAC;AACrC;AACA,SAASS,EAAaT,GAAe;AACjC,QAAMU,IAAKC,EAAeX,GAAK,IAAI,GAG7BY,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AQ,IAAIC,EAAkBL,GAAQX,EAAM,OAAOa,CAAO;AAC5ED,gBAAiBD,EAAO,OAAO,CAACjB,MAAa;AACzC,oBAAMuB,IAAQJ,EAAQnB,CAAG;AACzB,qBAAOuB,KAASH,KAAaG,KAASF;AAAAA,YAC1C,CAAC;AAAA,UACL;AACA,gBAAMG,IAAO,IAAIjD;AAAAA,YACb2C;AAAAA,YACAzC;AAAAA,YACA6B,EAAM;AAAA,YACNS;AAAAA,YACAC;AAAAA,YACAnC;AAAAA,UAAA;AAGA2C,UAAAA,EAAK,aAAajB,MAClBA,IAAaiB,EAAK,aAElBA,EAAK,QAAQ,MAAMhB,MACnBA,IAAOgB,EAAK,QAAQ,MAEpBA,EAAK,QAAQ,MAAMf,MACnBA,IAAOe,EAAK,QAAQ,MAExBb,EAAIE,CAAW,EAAE,KAAKW,CAAI;AAAA,QAC9B,CAAC;AAAA,MACL,CAAC,GACMb;AAAAA,IACX,GAAG,CAAA,CAAE;AAAA,IAKD,MAAM,EAAC,YAAAJ,GAAY,MAAAC,GAAM,MAAAC,EAAAA;AAAAA,IACzB,KAAKN,EAAM;AAAA,EAAA;AAEnB;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"sina.js","sources":["../../../../../../../node_modules/@milaboratories/miplots4/src/discrete/layers/sina.ts"],"sourcesContent":["import { max, mean, quantileSorted } from 'd3-array';\nimport { randomLcg } from 'd3-random';\nimport { scaleLinear } from 'd3-scale';\nimport lodash from 'lodash';\nimport type { DataFrame, GroupKey, NO_GROUPED } from '../../DataFrame';\nimport type { DataValue } from '../../types';\nimport type { DiscreteSettingsImpl, SinaLayer } from '../DiscreteSettingsImpl';\nimport { getOutliersBounds } from '../utils';\nimport { getFacetStringKey } from '../utils/getFacetStringKey';\nimport type { SinaData } from './types';\n\nconst DEFAULT_STEPS_COUNT = 30;\n\nfunction kernelDensityEstimator(kernel: (v: number) => number, thresholds: number[]) {\n return function (arr: number[]) {\n return thresholds.map(function (x):number {\n return mean(arr, v => kernel(x - v)) as number;\n });\n };\n}\n\nfunction kernelGaussian(bandwidth: number) {\n return function (v: number) {\n return (1 / Math.sqrt(2 * Math.PI)) * Math.pow(Math.E, -0.5 * Math.pow(v / bandwidth, 2));\n };\n}\n\nfunction getVariance(arr: number[]) {\n const vMean = mean(arr) as number;\n\n return mean(arr.map(v => Math.pow(v - vMean, 2))) as number;\n}\nfunction getStandardDeviation(arr: number[]) {\n return Math.sqrt(getVariance(arr));\n}\nfunction nrdBandwidth(arr: number[]) {\n const q1 = quantileSorted(arr, 0.25) as number;\n const q3 = quantileSorted(arr, 0.75) as number;\n const iqr = q3 - q1;\n const h = iqr / 1.34;\n const sigma = getStandardDeviation(arr);\n\n return 1.06 * Math.min(sigma, h) * Math.pow(arr.length, -1 / 5);\n}\n\nexport class Sina {\n key: string;\n maxDensity: number;\n primaryGrouping: string;\n secondaryGrouping: string;\n\n points: {x: number, y: number, jitter: number, id: string}[];\n\n boundsY: {\n min: number;\n max: number;\n };\n\n constructor(\n values: number[],\n scale: 'linear' | 'log',\n primaryGrouping: DataValue | typeof NO_GROUPED,\n secondaryGrouping: DataValue | typeof NO_GROUPED,\n getJitter: () => number\n ) {\n const stepsCount = DEFAULT_STEPS_COUNT;\n if (values.length === 0) {\n throw Error('Unable to calculate sina on empty data');\n }\n\n this.primaryGrouping = String(primaryGrouping);\n this.secondaryGrouping = String(secondaryGrouping);\n this.key = `sina_${this.primaryGrouping}_${this.secondaryGrouping}`;\n\n const convertToScale = (v: number) => (scale === 'log' ? Math.log10(v) : v);\n const convertFromScale = (v: number) => (scale === 'log' ? Math.pow(10, v) : v);\n\n const sortedGroup = values\n .filter((v: number) => {\n if (scale === 'log' && v === 0) {\n console.warn('Value = 0 on chart with log scale, it was removed from calculation');\n return false;\n }\n return true;\n })\n .sort((a, b) => convertToScale(a) - convertToScale(b));\n const sortedValues = sortedGroup.map(convertToScale);\n const minV = sortedValues[0];\n const maxV = sortedValues[sortedGroup.length - 1];\n const xRange = maxV - minV;\n const step = xRange / stepsCount;\n const bandwidth = nrdBandwidth(sortedValues);\n const thresholds = lodash.range(minV + step, maxV, step);\n\n this.boundsY = {\n min: convertFromScale(minV),\n max: convertFromScale(maxV),\n };\n\n const kde = kernelDensityEstimator(kernelGaussian(bandwidth), thresholds);\n const density = kde(sortedValues);\n const scaleY = scaleLinear().domain(thresholds).range(density).clamp(true);\n\n this.maxDensity = max(density) as number;\n\n this.points = sortedGroup.map((y:number, idx) => {\n return {\n x: y,\n y: scaleY(convertToScale(y)) / this.maxDensity,\n id: String(idx),\n jitter: getJitter(),\n };\n });\n }\n}\n\nexport function getSinaData(\n layer: SinaLayer,\n groupingKeys: {\n facet: GroupKey[][],\n primary: GroupKey[],\n secondary: GroupKey[]\n },\n data: DataFrame,\n y: DiscreteSettingsImpl['y'],\n yAxis: DiscreteSettingsImpl['chartSettings']['yAxis']\n): SinaData {\n let maxDensity = 0;\n let minY = Infinity;\n let maxY = -Infinity;\n const getJitter = randomLcg(1);\n\n const geoms = groupingKeys.facet.reduce((res: Record<string, Sina[]>, facetKey) => {\n const strFacetKey = getFacetStringKey(facetKey);\n res[strFacetKey] = [];\n groupingKeys.primary.forEach(primaryKey => {\n groupingKeys.secondary.forEach(secondaryKey => {\n const indexes = data.getRowsByGrouping([...facetKey, primaryKey, secondaryKey]);\n if (!indexes.length) {\n return;\n }\n let valuesFiltered = Array.from(indexes).map(idx => Number(data.getColumnValue(y.value, idx)));\n if (!layer.aes.showOutliers) {\n const [boundsMin, boundMax] = getOutliersBounds(valuesFiltered, yAxis.scale);\n valuesFiltered = valuesFiltered.filter((value: number) => {\n return value >= boundsMin && value <= boundMax;\n });\n }\n const sina = new Sina(\n valuesFiltered,\n yAxis.scale,\n primaryKey,\n secondaryKey,\n getJitter\n );\n\n if (sina.maxDensity > maxDensity) {\n maxDensity = sina.maxDensity;\n }\n if (sina.boundsY.min < minY) {\n minY = sina.boundsY.min;\n }\n if (sina.boundsY.max > maxY) {\n maxY = sina.boundsY.max;\n }\n res[strFacetKey].push(sina);\n });\n });\n return res;\n }, {});\n\n return {\n type: 'sina',\n geoms,\n meta: {maxDensity, minY, maxY},\n aes: layer.aes,\n };\n}\n"],"names":["DEFAULT_STEPS_COUNT","kernelDensityEstimator","kernel","thresholds","arr","x","mean","v","kernelGaussian","bandwidth","getVariance","vMean","getStandardDeviation","nrdBandwidth","q1","quantileSorted","h","sigma","Sina","values","scale","primaryGrouping","secondaryGrouping","getJitter","__publicField","stepsCount","convertToScale","convertFromScale","sortedGroup","a","b","sortedValues","minV","maxV","step","lodash","density","scaleY","scaleLinear","max","y","idx","getSinaData","layer","groupingKeys","data","yAxis","maxDensity","minY","maxY","randomLcg","res","facetKey","strFacetKey","getFacetStringKey","primaryKey","secondaryKey","indexes","valuesFiltered","boundsMin","boundMax","getOutliersBounds","value","sina"],"mappings":";;;;;;;;;;AAWA,MAAMA,IAAsB;AAE5B,SAASC,EAAuBC,GAA+BC,GAAsB;AACjF,SAAO,SAAUC,GAAe;AAC5B,WAAOD,EAAW,IAAI,SAAUE,GAAU;AACtC,aAAOC,EAAKF,GAAK,CAAAG,MAAKL,EAAOG,IAAIE,CAAC,CAAC;AAAA,IACvC,CAAC;AAAA,EACL;AACJ;AAEA,SAASC,EAAeC,GAAmB;AACvC,SAAO,SAAUF,GAAW;AACxB,WAAQ,IAAI,KAAK,KAAK,IAAI,KAAK,EAAE,IAAK,KAAK,IAAI,KAAK,GAAG,OAAO,KAAK,IAAIA,IAAIE,GAAW,CAAC,CAAC;AAAA,EAC5F;AACJ;AAEA,SAASC,EAAYN,GAAe;AAChC,QAAMO,IAAQL,EAAKF,CAAG;AAEtB,SAAOE,EAAKF,EAAI,IAAI,CAAAG,MAAK,KAAK,IAAIA,IAAII,GAAO,CAAC,CAAC,CAAC;AACpD;AACA,SAASC,EAAqBR,GAAe;AACzC,SAAO,KAAK,KAAKM,EAAYN,CAAG,CAAC;AACrC;AACA,SAASS,EAAaT,GAAe;AACjC,QAAMU,IAAKC,EAAe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AACA,gBAAMG,IAAO,IAAI7C;AAAAA,YACbwC;AAAAA,YACAZ,EAAM;AAAA,YACNS;AAAAA,YACAC;AAAAA,YACAjC;AAAAA,UAAA;AAGAwC,YAAK,aAAahB,MAClBA,IAAagB,EAAK,aAElBA,EAAK,QAAQ,MAAMf,MACnBA,IAAOe,EAAK,QAAQ,MAEpBA,EAAK,QAAQ,MAAMd,MACnBA,IAAOc,EAAK,QAAQ,MAExBZ,EAAIE,CAAW,EAAE,KAAKU,CAAI;AAAA,QAC9B,CAAC;AAAA,MACL,CAAC,GACMZ;AAAAA,IACX,GAAG,CAAA,CAAE;AAAA,IAKD,MAAM,EAAC,YAAAJ,GAAY,MAAAC,GAAM,MAAAC,EAAAA;AAAAA,IACzB,KAAKN,EAAM;AAAA,EAAA;AAEnB;","x_google_ignoreList":[0]}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { NO_GROUPED as y } from "../../DataFrame.js";
|
|
2
|
-
import { getFacetStringKey as
|
|
2
|
+
import { getFacetStringKey as k } from "../utils/getFacetStringKey.js";
|
|
3
3
|
import E from "../../node_modules/d3-array/src/sum.js";
|
|
4
|
-
function G(
|
|
4
|
+
function G(e, o, c, x) {
|
|
5
5
|
let m = -1 / 0, i = 1 / 0;
|
|
6
6
|
return {
|
|
7
7
|
type: "stackedBar",
|
|
8
|
-
geoms: o.facet.reduce((s,
|
|
9
|
-
const u =
|
|
10
|
-
return s[u] = [], o.primary.forEach((
|
|
8
|
+
geoms: o.facet.reduce((s, g) => {
|
|
9
|
+
const u = k(g);
|
|
10
|
+
return s[u] = [], o.primary.forEach((l) => {
|
|
11
11
|
let n = 0;
|
|
12
12
|
const t = {};
|
|
13
|
-
o.secondary.forEach((
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
13
|
+
o.secondary.forEach((a) => {
|
|
14
|
+
const r = a === y ? "null" : a, f = c.getRowsByGrouping([...g, l, a]);
|
|
15
|
+
if (!f.length)
|
|
16
16
|
return;
|
|
17
|
-
const
|
|
18
|
-
t[
|
|
19
|
-
height:
|
|
20
|
-
key: String(
|
|
21
|
-
}, n +=
|
|
17
|
+
const d = E(f, (z) => Number(c.getColumnValue(x.value, z)));
|
|
18
|
+
t[r] = {
|
|
19
|
+
height: d,
|
|
20
|
+
key: String(r)
|
|
21
|
+
}, n += d;
|
|
22
22
|
});
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
t[
|
|
23
|
+
const h = n;
|
|
24
|
+
e.normalize && o.secondary.forEach((a) => {
|
|
25
|
+
const r = a === y ? "null" : a;
|
|
26
|
+
t[r] && (t[r].height = t[r].height / h * 100);
|
|
27
27
|
}), m = Math.max(m, 0, n), i = Math.min(i, 0, n);
|
|
28
|
-
const
|
|
28
|
+
const p = e.normalize ? 100 : h;
|
|
29
29
|
s[u].push({
|
|
30
|
-
key: `stackedBar_${String(
|
|
30
|
+
key: `stackedBar_${String(l)}`,
|
|
31
31
|
valuesMap: t,
|
|
32
|
-
primaryGrouping:
|
|
33
|
-
boundsY: { min: Math.min(
|
|
32
|
+
primaryGrouping: l,
|
|
33
|
+
boundsY: { min: Math.min(p, 0), max: Math.max(p, 0) }
|
|
34
34
|
});
|
|
35
35
|
}), s;
|
|
36
36
|
}, {}),
|
|
37
|
-
meta: { minY:
|
|
38
|
-
aes:
|
|
37
|
+
meta: { minY: e.normalize ? 0 : i, maxY: e.normalize ? 100 : m, normalize: e.normalize },
|
|
38
|
+
aes: e.aes
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
export {
|