@milaboratories/miplots4 1.0.162 → 1.0.164
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/_virtual/index10.js +5 -2
- package/dist/_virtual/index10.js.map +1 -1
- package/dist/_virtual/index5.js +2 -5
- package/dist/_virtual/index5.js.map +1 -1
- package/dist/_virtual/index6.js +4 -4
- package/dist/_virtual/index7.js +1 -1
- package/dist/_virtual/index8.js +4 -4
- package/dist/_virtual/index9.js +3 -3
- package/dist/common/BandAxis.d.ts +2 -1
- package/dist/common/BandAxis.js +19 -18
- package/dist/common/BandAxis.js.map +1 -1
- package/dist/common/ContinuousAxis.js +20 -20
- package/dist/common/ContinuousAxis.js.map +1 -1
- package/dist/common/Legend.js +3 -3
- package/dist/common/Legend.js.map +1 -1
- package/dist/discrete/DiscreteSettingsImpl.d.ts +6 -4
- package/dist/discrete/DiscreteSettingsImpl.js +9 -9
- package/dist/discrete/DiscreteSettingsImpl.js.map +1 -1
- package/dist/discrete/constants.d.ts +1 -1
- package/dist/discrete/constants.js +1 -1
- package/dist/discrete/constants.js.map +1 -1
- package/dist/discrete/index.js +107 -106
- package/dist/discrete/index.js.map +1 -1
- package/dist/discrete/layers/bar.js +25 -22
- package/dist/discrete/layers/bar.js.map +1 -1
- package/dist/discrete/layers/errorbars.js +57 -48
- package/dist/discrete/layers/errorbars.js.map +1 -1
- package/dist/discrete/layers/lines.js +40 -31
- package/dist/discrete/layers/lines.js.map +1 -1
- package/dist/discrete/layers/stackedBar.js.map +1 -1
- package/dist/discrete/layers/stats/pValueCalculation.js +5 -5
- package/dist/heatmap/fillCellsData.js +49 -46
- package/dist/heatmap/fillCellsData.js.map +1 -1
- package/dist/histogram/ChartRenderer.js +57 -54
- package/dist/histogram/ChartRenderer.js.map +1 -1
- package/dist/histogram/constants.d.ts +1 -1
- package/dist/histogram/constants.js.map +1 -1
- package/dist/histogram/index.js +58 -51
- package/dist/histogram/index.js.map +1 -1
- package/dist/node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/index.js +1 -1
- package/dist/scatterplot/ChartRenderer.js +89 -89
- package/dist/scatterplot/ChartRenderer.js.map +1 -1
- package/dist/scatterplot/components/ChartAxis.js +30 -30
- package/dist/scatterplot/components/ChartAxis.js.map +1 -1
- package/dist/scatterplot/components/ChartAxisTitles.js +22 -22
- package/dist/scatterplot/components/ChartAxisTitles.js.map +1 -1
- package/dist/scatterplot/constants.d.ts +1 -1
- package/dist/scatterplot/constants.js +1 -1
- package/dist/scatterplot/constants.js.map +1 -1
- package/dist/scatterplot/dots.d.ts +1 -1
- package/dist/scatterplot/dots.js +14 -14
- package/dist/scatterplot/dots.js.map +1 -1
- package/dist/scatterplot/index.js +94 -79
- package/dist/scatterplot/index.js.map +1 -1
- package/dist/scatterplot-umap/ChartRenderer.d.ts +1 -1
- package/dist/scatterplot-umap/ChartRenderer.js +14 -14
- package/dist/scatterplot-umap/ChartRenderer.js.map +1 -1
- package/dist/scatterplot-umap/components/LowerSVG.js +38 -38
- package/dist/scatterplot-umap/components/LowerSVG.js.map +1 -1
- package/dist/types/bubble.d.ts +5 -5
- package/dist/types/bubble.js +40 -40
- package/dist/types/bubble.js.map +1 -1
- package/dist/types/common.d.ts +25 -2
- package/dist/types/common.js +16 -15
- package/dist/types/common.js.map +1 -1
- package/dist/types/discrete.d.ts +66 -56
- package/dist/types/discrete.js +40 -38
- package/dist/types/discrete.js.map +1 -1
- package/dist/types/heatmap.d.ts +5 -6
- package/dist/types/heatmap.js +29 -29
- package/dist/types/heatmap.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/histogram/index.ts"],"sourcesContent":["import {\n intersection\n} from 'lodash';\nimport { renderToString } from 'react-dom/server';\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame } from '../DataFrame';\nimport { type Category, type ColumnName, type ErrorInfoFacets, getUnknownErrorInfo, type HistogramEventHandlers, type HistogramSettings, isErrorInfo } from '../types';\nimport { getKeysCombinations } from '../utils/getKeysCombination';\nimport ChartRenderer from './ChartRenderer';\nimport type { HistogramLegendInfo } from './components/types';\nimport type { GroupedHistogramData } from './getHistogramData';\nimport { createHistogramDataByFacets } from './getHistogramData';\nimport { HistogramSettingsImpl } from './HistogramSettingsImpl';\nimport { MAX_FACETS_COUNT } from '../constants';\n\nfunction getLegendInfo(\n data: DataFrame,\n grouping: ColumnName[],\n inheritedAes: HistogramSettingsImpl['inheritedAes']\n): HistogramLegendInfo {\n return grouping.reduce((res: HistogramLegendInfo, column) => {\n const categories = data.getColumnCategories(column.value, false);\n const getValueLabel = (category: Category) => (column.valueLabels\n ? String(data.getColumnValue(\n column.valueLabels,\n data.getColumnCategoryRowIndex(column.value, category)\n ))\n : category\n );\n const labels = categories.reduce((res: Record<string, string>, category) => {\n res[category] = getValueLabel(category);\n return res;\n }, {});\n res[column.value] = {\n values: categories.sort((a, b) => labels[a].localeCompare(labels[b], 'en', {numeric: true})),\n aesMap: inheritedAes[column.value],\n labels,\n };\n return res;\n }, {});\n}\n\nexport class ChartHistogram extends AbstractChart {\n settings: HistogramSettingsImpl;\n chartRenderer = new ChartRenderer();\n\n onTooltipHintSwitch: (v:boolean) => void = () => undefined;\n calculatedData: {\n facetKeys: string[];\n facetKeysCombinations: string[][];\n histogramDataByFacets: Record<string, GroupedHistogramData>\n legendInfo: HistogramLegendInfo\n } | null = null;\n\n constructor(data: DataFrame, settings: HistogramSettings, eventHandlers?: HistogramEventHandlers) {\n super(data, settings);\n\n this.settings = new HistogramSettingsImpl(settings);\n if (eventHandlers) {\n this.onTooltipHintSwitch = eventHandlers[0];\n }\n }\n\n mount(node: HTMLElement) {\n try {\n this.chartRenderer.init(node);\n this._updateData();\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n unmount() {\n this.chartRenderer.clear();\n }\n\n updateSettingsAndData(data: DataFrame, settings: HistogramSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new HistogramSettingsImpl(settings);\n this.data = data;\n if (\n this._needUpdateCalculatedDataBySettings(previousSettings, this.settings) ||\n this._needUpdateCalculatedDataByData(previousData, this.data)\n ) {\n this._updateData();\n } else {\n this._updateAesInData();\n }\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n updateChartState(_field: string, _value: unknown) {\n console.warn('no chart state for histogram');\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: HistogramSettingsImpl, settings: HistogramSettingsImpl) {\n return (\n prevSettings.valueColumn.value !== settings.valueColumn.value ||\n prevSettings.facetBy.some((el, idx) => el.value !== settings.facetBy[idx]?.value) ||\n prevSettings.grouping?.value !== settings.grouping?.value ||\n prevSettings.layers.length !== settings.layers.length ||\n prevSettings.layers.some((l, idx) => l.type !== settings.layers[idx].type) ||\n prevSettings.binsCount !== settings.binsCount ||\n prevSettings.chartSettings.xAxis.scale !== settings.chartSettings.xAxis.scale ||\n prevSettings.groupingOrder?.some((key, idx) => key !== settings.groupingOrder?.[idx]) ||\n settings.groupingOrder?.some((key, idx) => key !== prevSettings.groupingOrder?.[idx])\n );\n }\n\n _needUpdateCalculatedDataByData(prevData: DataFrame, data: DataFrame) {\n const prevKeys = Object.keys(prevData.data);\n const keys = Object.keys(data.data);\n return (\n prevData.id !== data.id ||\n prevKeys.length !== keys.length ||\n prevKeys.some(key => prevData.data[key].length !== data.data[key]?.length)\n );\n }\n\n _updateData() {\n const {valueColumn, facetBy, grouping, binsCount, chartSettings, inheritedAes, groupingOrder} = this.settings;\n\n const facetKeysLists = facetBy.map(column => this.data.getColumnCategories(column.value));\n const facetKeysCombinations = facetKeysLists.length ? getKeysCombinations([...facetKeysLists]) : [['null']];\n\n if (facetKeysCombinations.length > MAX_FACETS_COUNT) {\n const errorInfo: ErrorInfoFacets = {\n type: 'tooManyFacets',\n info: {count: facetKeysCombinations.length, maxCount: MAX_FACETS_COUNT}\n };\n throw Error(errorInfo.type, {cause: errorInfo});\n }\n\n const facetGroupingValues = facetBy.map(column => column.value) ?? null;\n const groupingValues = grouping ? [grouping.value] : [];\n let groupingKeys = grouping ? this.data.getColumnCategories(grouping.value) : ['null'];\n if (groupingOrder) {\n groupingKeys = intersection(groupingOrder, groupingKeys);\n }\n\n this.data.setGrouping([...facetGroupingValues, ...groupingValues]);\n const histogramDataByFacets = createHistogramDataByFacets(this.data, facetKeysCombinations, groupingKeys, valueColumn, binsCount, chartSettings.xAxis.scale);\n\n this.calculatedData = {\n facetKeys: facetKeysCombinations.map(v => v.join(', ')),\n facetKeysCombinations,\n histogramDataByFacets,\n legendInfo: getLegendInfo(this.data, grouping ? [grouping] : [], inheritedAes)\n };\n }\n\n _updateAesInData() {\n const calculated = this.calculatedData;\n if (!calculated) {\n return;\n }\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {id, chartSettings, facetSettings, inheritedAes, layers, grouping, groupingDirection, groupingStack} = this.settings;\n this.chartRenderer.render(\n this.data,\n id,\n chartSettings,\n facetSettings,\n this.calculatedData.facetKeys,\n this.calculatedData.facetKeysCombinations, //for titles, if facet by more than 1 column\n this.calculatedData.histogramDataByFacets,\n this.calculatedData.legendInfo,\n layers,\n inheritedAes,\n grouping,\n groupingStack,\n groupingDirection,\n this.onTooltipHintSwitch\n );\n }\n}\n"],"names":["getLegendInfo","data","grouping","inheritedAes","res","column","categories","getValueLabel","category","labels","a","b","ChartHistogram","AbstractChart","settings","eventHandlers","__publicField","ChartRenderer","HistogramSettingsImpl","node","err","isErrorInfo","getUnknownErrorInfo","previousSettings","previousData","_field","_value","renderToString","prevSettings","el","idx","_a","_b","l","_c","key","_d","prevData","prevKeys","keys","valueColumn","facetBy","binsCount","chartSettings","groupingOrder","facetKeysLists","facetKeysCombinations","getKeysCombinations","MAX_FACETS_COUNT","errorInfo","facetGroupingValues","groupingValues","groupingKeys","intersection","histogramDataByFacets","createHistogramDataByFacets","v","id","facetSettings","layers","groupingDirection","groupingStack"],"mappings":";;;;;;;;;;;;;;;;;;AAeA,SAASA,EACLC,GACAC,GACAC,GACmB;AACnB,SAAOD,EAAS,OAAO,CAACE,GAA0BC,MAAW;AACzD,UAAMC,IAAaL,EAAK,oBAAoBI,EAAO,OAAO,EAAK,GACzDE,IAAgB,CAACC,MAAwBH,EAAO,cAChD,OAAOJ,EAAK;AAAA,MACVI,EAAO;AAAA,MACPJ,EAAK,0BAA0BI,EAAO,OAAOG,CAAQ;AAAA,IAAA,CACxD,IACCA,GAEAC,IAASH,EAAW,OAAO,CAACF,GAA6BI,OAC3DJ,EAAII,CAAQ,IAAID,EAAcC,CAAQ,GAC/BJ,IACR,CAAA,CAAE;AACL,WAAAA,EAAIC,EAAO,KAAK,IAAI;AAAA,MAChB,QAAQC,EAAW,KAAK,CAACI,GAAGC,MAAMF,EAAOC,CAAC,EAAE,cAAcD,EAAOE,CAAC,GAAG,MAAM,EAAC,SAAS,GAAA,CAAK,CAAC;AAAA,MAC3F,QAAQR,EAAaE,EAAO,KAAK;AAAA,MACjC,QAAAI;AAAA,IAAA,GAEGL;AAAA,EACX,GAAG,CAAA,CAAE;AACT;AAEO,MAAMQ,UAAuBC,EAAc;AAAA,EAY9C,YAAYZ,GAAiBa,GAA6BC,GAAwC;AAC9F,UAAMd,GAAMa,CAAQ;AAZxB,IAAAE,EAAA;AACA,IAAAA,EAAA,uBAAgB,IAAIC,EAAA;AAEpB,IAAAD,EAAA,6BAA2C,MAAA;AAAA;AAC3C,IAAAA,EAAA,wBAKW;A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AAAzD,GAAU,mBAAA0D,GAAmB,eAAAC,EAAA,IAAiB,KAAK;AAClH,SAAK,cAAc;AAAA,MACf,KAAK;AAAA,MACLJ;AAAA,MACAd;AAAA,MACAe;AAAA,MACA,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpBC;AAAA,MACAxD;AAAA,MACAD;AAAA,MACA2D;AAAA,MACAD;AAAA,MACA,KAAK;AAAA,IAAA;AAAA,EAEb;AACJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/histogram/index.ts"],"sourcesContent":["import {\n intersection\n} from 'lodash';\nimport { renderToString } from 'react-dom/server';\nimport { AbstractChart } from '../AbstractChart';\nimport type { DataFrame } from '../DataFrame';\nimport type { ErrorInfoHistogramGroups} from '../types';\nimport { type Category, type ColumnName, type ErrorInfoFacets, getUnknownErrorInfo, type HistogramEventHandlers, type HistogramSettings, isErrorInfo } from '../types';\nimport { getKeysCombinations } from '../utils/getKeysCombination';\nimport ChartRenderer from './ChartRenderer';\nimport type { HistogramLegendInfo } from './components/types';\nimport type { GroupedHistogramData } from './getHistogramData';\nimport { createHistogramDataByFacets } from './getHistogramData';\nimport { HistogramSettingsImpl } from './HistogramSettingsImpl';\nimport { MAX_FACETS_COUNT, MAX_GROUPS_COUNT } from '../constants';\n\nfunction getLegendInfo(\n data: DataFrame,\n grouping: ColumnName[],\n inheritedAes: HistogramSettingsImpl['inheritedAes']\n): HistogramLegendInfo {\n return grouping.reduce((res: HistogramLegendInfo, column) => {\n const categories = data.getColumnCategories(column.value, false);\n const getValueLabel = (category: Category) => (column.valueLabels\n ? String(data.getColumnValue(\n column.valueLabels,\n data.getColumnCategoryRowIndex(column.value, category)\n ))\n : category\n );\n const labels = categories.reduce((res: Record<string, string>, category) => {\n res[category] = getValueLabel(category);\n return res;\n }, {});\n res[column.value] = {\n values: categories.sort((a, b) => labels[a].localeCompare(labels[b], 'en', {numeric: true})),\n aesMap: inheritedAes[column.value],\n labels,\n };\n return res;\n }, {});\n}\n\nexport class ChartHistogram extends AbstractChart {\n settings: HistogramSettingsImpl;\n chartRenderer = new ChartRenderer();\n\n onTooltipHintSwitch: (v:boolean) => void = () => undefined;\n calculatedData: {\n facetKeys: string[];\n facetKeysCombinations: string[][];\n histogramDataByFacets: Record<string, GroupedHistogramData>\n legendInfo: HistogramLegendInfo\n } | null = null;\n\n constructor(data: DataFrame, settings: HistogramSettings, eventHandlers?: HistogramEventHandlers) {\n super(data, settings);\n\n this.settings = new HistogramSettingsImpl(settings);\n if (eventHandlers) {\n this.onTooltipHintSwitch = eventHandlers[0];\n }\n }\n\n mount(node: HTMLElement) {\n try {\n this.chartRenderer.init(node);\n this._updateData();\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n unmount() {\n this.chartRenderer.clear();\n }\n\n updateSettingsAndData(data: DataFrame, settings: HistogramSettings) {\n try {\n const previousSettings = this.settings;\n const previousData = this.data;\n this.settings = new HistogramSettingsImpl(settings);\n this.data = data;\n if (\n this._needUpdateCalculatedDataBySettings(previousSettings, this.settings) ||\n this._needUpdateCalculatedDataByData(previousData, this.data)\n ) {\n this._updateData();\n } else {\n this._updateAesInData();\n }\n this._updateChart();\n this.hasError = false;\n this.errorInfo = null;\n } catch (err) {\n this.hasError = true;\n if (err instanceof Error) {\n this.errorInfo = isErrorInfo(err.cause) ? err.cause : getUnknownErrorInfo(err);\n this.chartRenderer.renderError(err.message as string);\n console.error(err);\n }\n }\n }\n\n updateChartState(_field: string, _value: unknown) {\n console.warn('no chart state for histogram');\n }\n\n export(): string {\n this._updateChart();\n return renderToString(this.chartRenderer.component);\n }\n\n _needUpdateCalculatedDataBySettings(prevSettings: HistogramSettingsImpl, settings: HistogramSettingsImpl) {\n return (\n prevSettings.valueColumn.value !== settings.valueColumn.value ||\n prevSettings.facetBy.some((el, idx) => el.value !== settings.facetBy[idx]?.value) ||\n prevSettings.grouping?.value !== settings.grouping?.value ||\n prevSettings.layers.length !== settings.layers.length ||\n prevSettings.layers.some((l, idx) => l.type !== settings.layers[idx].type) ||\n prevSettings.binsCount !== settings.binsCount ||\n prevSettings.chartSettings.xAxis.scale !== settings.chartSettings.xAxis.scale ||\n prevSettings.groupingOrder?.some((key, idx) => key !== settings.groupingOrder?.[idx]) ||\n settings.groupingOrder?.some((key, idx) => key !== prevSettings.groupingOrder?.[idx])\n );\n }\n\n _needUpdateCalculatedDataByData(prevData: DataFrame, data: DataFrame) {\n const prevKeys = Object.keys(prevData.data);\n const keys = Object.keys(data.data);\n return (\n prevData.id !== data.id ||\n prevKeys.length !== keys.length ||\n prevKeys.some(key => prevData.data[key].length !== data.data[key]?.length)\n );\n }\n\n _updateData() {\n const {valueColumn, facetBy, grouping, binsCount, chartSettings, inheritedAes, groupingOrder} = this.settings;\n\n const facetKeysLists = facetBy.map(column => this.data.getColumnCategories(column.value));\n const facetKeysCombinations = facetKeysLists.length ? getKeysCombinations([...facetKeysLists]) : [['null']];\n\n if (facetKeysCombinations.length > MAX_FACETS_COUNT) {\n const errorInfo: ErrorInfoFacets = {\n type: 'tooManyFacets',\n info: {count: facetKeysCombinations.length, maxCount: MAX_FACETS_COUNT}\n };\n throw Error(errorInfo.type, {cause: errorInfo});\n }\n\n const facetGroupingValues = facetBy.map(column => column.value) ?? null;\n const groupingValues = grouping ? [grouping.value] : [];\n let groupingKeys = grouping ? this.data.getColumnCategories(grouping.value) : ['null'];\n if (groupingKeys.length > MAX_GROUPS_COUNT) {\n const errorInfo: ErrorInfoHistogramGroups = {\n type: 'tooManyHistogramGroups',\n info: {count: groupingKeys.length, maxCount: MAX_GROUPS_COUNT}\n };\n throw Error(errorInfo.type, {cause: errorInfo});\n }\n if (groupingOrder) {\n groupingKeys = intersection(groupingOrder, groupingKeys);\n }\n\n this.data.setGrouping([...facetGroupingValues, ...groupingValues]);\n const histogramDataByFacets = createHistogramDataByFacets(this.data, facetKeysCombinations, groupingKeys, valueColumn, binsCount, chartSettings.xAxis.scale);\n\n this.calculatedData = {\n facetKeys: facetKeysCombinations.map(v => v.join(', ')),\n facetKeysCombinations,\n histogramDataByFacets,\n legendInfo: getLegendInfo(this.data, grouping ? [grouping] : [], inheritedAes)\n };\n }\n\n _updateAesInData() {\n const calculated = this.calculatedData;\n if (!calculated) {\n return;\n }\n }\n\n _updateChart() {\n if (!this.calculatedData) {\n return;\n }\n const {id, chartSettings, facetSettings, inheritedAes, layers, grouping, groupingDirection, groupingStack} = this.settings;\n this.calculatedData.legendInfo = getLegendInfo(this.data, grouping ? [grouping] : [], inheritedAes);\n this.chartRenderer.render(\n this.data,\n id,\n chartSettings,\n facetSettings,\n this.calculatedData.facetKeys,\n this.calculatedData.facetKeysCombinations, //for titles, if facet by more than 1 column\n this.calculatedData.histogramDataByFacets,\n this.calculatedData.legendInfo,\n layers,\n inheritedAes,\n grouping,\n groupingStack,\n groupingDirection,\n this.onTooltipHintSwitch\n );\n }\n}\n"],"names":["getLegendInfo","data","grouping","inheritedAes","res","column","categories","getValueLabel","category","labels","a","b","ChartHistogram","AbstractChart","settings","eventHandlers","__publicField","ChartRenderer","HistogramSettingsImpl","node","err","isErrorInfo","getUnknownErrorInfo","previousSettings","previousData","_field","_value","renderToString","prevSettings","el","idx","_a","_b","l","_c","key","_d","prevData","prevKeys","keys","valueColumn","facetBy","binsCount","chartSettings","groupingOrder","facetKeysLists","facetKeysCombinations","getKeysCombinations","MAX_FACETS_COUNT","errorInfo","facetGroupingValues","groupingValues","groupingKeys","MAX_GROUPS_COUNT","intersection","histogramDataByFacets","createHistogramDataByFacets","v","id","facetSettings","layers","groupingDirection","groupingStack"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,SAASA,EACLC,GACAC,GACAC,GACmB;AACnB,SAAOD,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A,MACf,KAAK;AAAA,MACLuD;AAAA,MACAf;AAAA,MACAgB;AAAA,MACA,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA;AAAA,MACpB,KAAK,eAAe;AAAA,MACpB,KAAK,eAAe;AAAA,MACpBC;AAAA,MACAzD;AAAA,MACAD;AAAA,MACA4D;AAAA,MACAD;AAAA,MACA,KAAK;AAAA,IAAA;AAAA,EAEb;AACJ;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as e } from "../../../../../_virtual/
|
|
1
|
+
import { __module as e } from "../../../../../_virtual/index5.js";
|
|
2
2
|
import { __require as o } from "./cjs/scheduler.production.min.js";
|
|
3
3
|
import { __require as u } from "./cjs/scheduler.development.js";
|
|
4
4
|
var r;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var st = Object.defineProperty;
|
|
2
2
|
var ot = (a, t, i) => t in a ? st(a, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[t] = i;
|
|
3
|
-
var
|
|
3
|
+
var b = (a, t, i) => ot(a, typeof t != "symbol" ? t + "" : t, i);
|
|
4
4
|
import { j as v } from "../_virtual/jsx-runtime.js";
|
|
5
5
|
import { c as nt } from "../_virtual/client.js";
|
|
6
6
|
import { Error as at } from "../common/Error.js";
|
|
@@ -20,18 +20,18 @@ import { getContinuousColorScale as gt } from "../utils/getContinuousColorScale.
|
|
|
20
20
|
import { getContinuousLegendTicks as ft } from "../utils/getContinuousLegendTicks.js";
|
|
21
21
|
import { TextMeasurer as Tt } from "../utils/TextMeasurer/TextMeasurer.js";
|
|
22
22
|
import { ChartsGroup as Ct } from "./components/ChartsGroup.js";
|
|
23
|
-
import { MIN_MARGIN as D, PADDINGS as P, DEFAULT_DOT_AES as
|
|
24
|
-
import { createAesGetter as
|
|
25
|
-
import { getTicksAndFormat as
|
|
23
|
+
import { MIN_MARGIN as D, PADDINGS as P, DEFAULT_DOT_AES as A, LEGEND_OFFSET as Mt, TICK_OFFSET as F, DEFAULT_TICKS_SIZE as Q, MIN_PADDING as U, FACET_TITLE_OFFSET as Et, TITLE_LINE as O, FACET_AXIS_OFFSET as Z } from "./constants.js";
|
|
24
|
+
import { createAesGetter as Y } from "./utils/createAesGetter.js";
|
|
25
|
+
import { getTicksAndFormat as St } from "./utils/getTicksAndFormat.js";
|
|
26
26
|
import { isContinuousAxis as $ } from "./utils/isNumericScale.js";
|
|
27
27
|
import { createMultilineDiscreteLabels as J } from "../utils/createMultilineDiscreteLabels.js";
|
|
28
28
|
import { measureMultilineDiscreteLabels as k } from "../utils/measureMultilineDiscreteLabels.js";
|
|
29
29
|
import B from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/linear.js";
|
|
30
30
|
import { point as y } from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/band.js";
|
|
31
31
|
import K from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/log.js";
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import { sqrt as
|
|
32
|
+
import bt from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js";
|
|
33
|
+
import xt from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/symlog.js";
|
|
34
|
+
import { sqrt as Nt } from "../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/pow.js";
|
|
35
35
|
function tt(a, t) {
|
|
36
36
|
if (a === void 0)
|
|
37
37
|
return !0;
|
|
@@ -42,17 +42,17 @@ function tt(a, t) {
|
|
|
42
42
|
}
|
|
43
43
|
return !1;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function zt(a, t, i, s) {
|
|
46
46
|
const e = [];
|
|
47
47
|
return a % i === i - 1 && e.push("right"), a % i === 0 && e.push("left"), a < i && e.push("top"), (Math.ceil((a + 1) / i) === s || Math.ceil((a + 1) / i) === s - 1 && a % i > (t - 1) % i) && e.push("bottom"), e;
|
|
48
48
|
}
|
|
49
|
-
function wt(a, t, i, s, e, o, f, T,
|
|
50
|
-
const
|
|
49
|
+
function wt(a, t, i, s, e, o, f, T, S, d) {
|
|
50
|
+
const z = a.scale === "discrete", W = t.scale === "discrete", h = o.includes("left") || !(d != null && d.sharedY), n = o.includes("left") && t.title !== "", r = o.includes("bottom") || !(d != null && d.sharedX), g = o.includes("bottom") && a.title !== "", M = t.hiddenLabels ? 0 : W ? i.leftAxisCaptionsWidthByColumns[T] + 2 * F : i.yAxisCaptionsWidth + 2 * F, l = (t.showTicks ? Q : 0) + F, m = n ? O : 0, C = a.hiddenLabels ? 0 : z ? i.bottomAxisCaptionsWidthByRows[f] + 2 * F : i.xAxisCaptionsWidth + 2 * F, E = a.showTicks ? Q : 0, R = g ? O : 0, p = M + l + m + Z, c = C + E + R + Z, I = Math.max(...s.map((u) => e[u].length));
|
|
51
51
|
return {
|
|
52
|
-
left: h ? p :
|
|
52
|
+
left: h ? p : U,
|
|
53
53
|
top: I === 0 ? 0 : Et * 2 + I * pt,
|
|
54
|
-
bottom: r ? c + 8 :
|
|
55
|
-
right:
|
|
54
|
+
bottom: r ? c + 8 : U,
|
|
55
|
+
right: S ? 0 : U
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
function Wt(a, t, i) {
|
|
@@ -65,35 +65,35 @@ function It(a, t) {
|
|
|
65
65
|
const i = Math.floor(a / t), s = a - i * t;
|
|
66
66
|
return [i, s];
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function Lt(a, t, i, s) {
|
|
69
69
|
const e = i.find((f) => f.type === "dots"), o = i.find((f) => f.type === "curve");
|
|
70
70
|
return {
|
|
71
|
-
dotShape:
|
|
72
|
-
dotColor:
|
|
73
|
-
dotSize:
|
|
74
|
-
lineShape:
|
|
75
|
-
lineColor:
|
|
76
|
-
trendColor:
|
|
71
|
+
dotShape: Y(a, t, (e == null ? void 0 : e.aes.dotShape) ?? A.shape, "dotShape"),
|
|
72
|
+
dotColor: Y(a, t, (e == null ? void 0 : e.aes.dotFill) ?? A.color, "dotFill"),
|
|
73
|
+
dotSize: Y(a, t, (e == null ? void 0 : e.aes.dotSize) ?? A.size, "dotSize"),
|
|
74
|
+
lineShape: Y(a, t, (o == null ? void 0 : o.aes.lineShape) ?? "solid", "lineShape"),
|
|
75
|
+
lineColor: Y(a, t, (o == null ? void 0 : o.aes.lineColor) ?? et, "lineColor"),
|
|
76
|
+
trendColor: Y(a, t, (s == null ? void 0 : s.color) ?? A.color, "fillColor")
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
const _t = Math.cos(Math.PI / 4), Ht = 5;
|
|
80
80
|
function it(a, t) {
|
|
81
|
-
return t.scale === "discrete" ? t.labelsPosition === "90deg" ? a : t.labelsPosition === "45deg" ? a * _t + (a > 0 ? 2 * Ht : 0) :
|
|
81
|
+
return t.scale === "discrete" ? t.labelsPosition === "90deg" ? a : t.labelsPosition === "45deg" ? a * _t + (a > 0 ? 2 * Ht : 0) : O : Math.max(a, O);
|
|
82
82
|
}
|
|
83
83
|
class ci {
|
|
84
84
|
constructor() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
b(this, "reactRoot", null);
|
|
86
|
+
b(this, "parentNode", null);
|
|
87
|
+
b(this, "rootNode", null);
|
|
88
|
+
b(this, "component", /* @__PURE__ */ v.jsx(v.Fragment, {}));
|
|
89
|
+
b(this, "margins", {
|
|
90
90
|
top: D,
|
|
91
91
|
bottom: D,
|
|
92
92
|
left: D,
|
|
93
93
|
right: D
|
|
94
94
|
});
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
b(this, "chartsDimensions", {});
|
|
96
|
+
b(this, "chartSizes", {
|
|
97
97
|
chartWidth: G,
|
|
98
98
|
// width of single chart
|
|
99
99
|
chartHeight: X,
|
|
@@ -107,13 +107,13 @@ class ci {
|
|
|
107
107
|
totalHeight: X
|
|
108
108
|
// width of all charts in charts height, plus bottom axis, plus top title
|
|
109
109
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
b(this, "columnsCount", 1);
|
|
111
|
+
b(this, "rowsCount", 1);
|
|
112
|
+
b(this, "scales", {
|
|
113
113
|
x: { null: B().domain([0, 1]).range([0, G]) },
|
|
114
114
|
y: { null: B().domain([0, 1]).range([X, 0]) }
|
|
115
115
|
});
|
|
116
|
-
|
|
116
|
+
b(this, "captionsSizes", {
|
|
117
117
|
xAxisCaptionsWidth: 30,
|
|
118
118
|
yAxisCaptionsWidth: 100,
|
|
119
119
|
bottomAxisCaptionsWidthByRows: [],
|
|
@@ -121,13 +121,13 @@ class ci {
|
|
|
121
121
|
bottomCaptionsTail: 0,
|
|
122
122
|
leftCaptionsTail: 0
|
|
123
123
|
});
|
|
124
|
-
|
|
124
|
+
b(this, "facetTitles", {});
|
|
125
125
|
// can be multiline
|
|
126
|
-
|
|
126
|
+
b(this, "mainTitle", []);
|
|
127
127
|
// can be multiline
|
|
128
|
-
|
|
128
|
+
b(this, "discreteAxesLabels", { x: {}, y: {} });
|
|
129
129
|
// only for discrete axes, by facets, can be multiline
|
|
130
|
-
|
|
130
|
+
b(this, "legend", { width: 0, height: 0, items: [] });
|
|
131
131
|
}
|
|
132
132
|
clear() {
|
|
133
133
|
var t;
|
|
@@ -144,10 +144,10 @@ class ci {
|
|
|
144
144
|
}
|
|
145
145
|
updateChartDimensions(t, i, s, e) {
|
|
146
146
|
const { chartWidth: o, chartHeight: f } = this.chartSizes;
|
|
147
|
-
let T = 0,
|
|
147
|
+
let T = 0, S = 0;
|
|
148
148
|
const d = Wt(t, this.rowsCount, this.columnsCount);
|
|
149
149
|
this.chartsDimensions = t.reduce((h, n, r) => {
|
|
150
|
-
const [g,
|
|
150
|
+
const [g, M] = It(r, this.columnsCount), l = zt(r, t.length, this.columnsCount, this.rowsCount), m = wt(
|
|
151
151
|
s,
|
|
152
152
|
e,
|
|
153
153
|
this.captionsSizes,
|
|
@@ -155,33 +155,33 @@ class ci {
|
|
|
155
155
|
this.facetTitles,
|
|
156
156
|
l,
|
|
157
157
|
g,
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
M,
|
|
159
|
+
M === this.columnsCount - 1,
|
|
160
160
|
i
|
|
161
161
|
), C = o + m.left + m.right, E = f + m.top + m.bottom;
|
|
162
162
|
return h[n] = {
|
|
163
163
|
left: T,
|
|
164
|
-
top:
|
|
164
|
+
top: S,
|
|
165
165
|
chartEdgeSides: l,
|
|
166
166
|
padding: m,
|
|
167
167
|
inner: { width: o, height: f },
|
|
168
168
|
outer: { width: C, height: E }
|
|
169
|
-
}, T += C,
|
|
169
|
+
}, T += C, M === this.columnsCount - 1 && (T = 0, S += E), h;
|
|
170
170
|
}, {});
|
|
171
|
-
const
|
|
171
|
+
const z = Math.max(
|
|
172
172
|
...t.map((h) => this.chartsDimensions[h].outer.width + this.chartsDimensions[h].left)
|
|
173
173
|
), W = Math.max(
|
|
174
174
|
...t.map((h) => this.chartsDimensions[h].outer.height + this.chartsDimensions[h].top)
|
|
175
175
|
);
|
|
176
|
-
this.chartSizes.chartsWidth =
|
|
176
|
+
this.chartSizes.chartsWidth = z, this.chartSizes.chartsHeight = W;
|
|
177
177
|
}
|
|
178
|
-
updateViewport(t, i, s, e, o, f, T,
|
|
179
|
-
const d = t.length,
|
|
180
|
-
this.columnsCount = i.nRows ? Math.ceil(d /
|
|
178
|
+
updateViewport(t, i, s, e, o, f, T, S) {
|
|
179
|
+
const d = t.length, z = Math.min(i.nRows ?? d, d), W = Math.min(i.nCols ?? d, d);
|
|
180
|
+
this.columnsCount = i.nRows ? Math.ceil(d / z) : W, this.rowsCount = Math.ceil(d / this.columnsCount);
|
|
181
181
|
let [h, n] = [1 / 0, -1 / 0], [r, g] = [1 / 0, -1 / 0];
|
|
182
|
-
const
|
|
183
|
-
const I = T[c], { minX: u, minY:
|
|
184
|
-
return h = Math.min(h, u), r = Math.min(r,
|
|
182
|
+
const M = t.reduce((p, c) => {
|
|
183
|
+
const I = T[c], { minX: u, minY: x, maxX: N, maxY: w } = I;
|
|
184
|
+
return h = Math.min(h, u), r = Math.min(r, x), n = Math.max(n, N), g = Math.max(g, w), p[c] = { minX: u, maxX: N, minY: x, maxY: w }, p;
|
|
185
185
|
}, {}), l = {}, m = {};
|
|
186
186
|
let C = !1, E = !1;
|
|
187
187
|
t.forEach((p) => {
|
|
@@ -190,27 +190,27 @@ class ci {
|
|
|
190
190
|
c = y().range([0, this.chartSizes.chartWidth]).domain(o.keys ?? []).padding(0.5);
|
|
191
191
|
else {
|
|
192
192
|
c = s.scale === "log" ? K() : B();
|
|
193
|
-
const u =
|
|
194
|
-
let
|
|
193
|
+
const u = M[p];
|
|
194
|
+
let x = s.lowerValue ? Number(s.lowerValue) : i.sharedX ? h : u.minX, N = s.upperValue ? Number(s.upperValue) : i.sharedX ? n : u.maxX;
|
|
195
195
|
if (typeof s.symmetricRange < "u") {
|
|
196
196
|
const _ = s.symmetricRange;
|
|
197
|
-
if (_ >=
|
|
198
|
-
const H = Math.max(_ -
|
|
199
|
-
|
|
197
|
+
if (_ >= x && _ <= N) {
|
|
198
|
+
const H = Math.max(_ - x, N - _);
|
|
199
|
+
x = _ - H, N = _ + H;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
const w = [0, this.chartSizes.chartWidth],
|
|
203
|
-
c.domain([
|
|
202
|
+
const w = [0, this.chartSizes.chartWidth], L = c.copy().domain([x, N]).range([P.LEFT, this.chartSizes.chartWidth - P.RIGHT]);
|
|
203
|
+
c.domain([L.invert(0), L.invert(this.chartSizes.chartWidth)]).range(w).nice();
|
|
204
204
|
}
|
|
205
205
|
const I = this.scales.x[p];
|
|
206
206
|
l[p] = c, C = C || tt(I, c);
|
|
207
207
|
});
|
|
208
208
|
const R = t.reduce((p, c) => {
|
|
209
|
-
const I =
|
|
209
|
+
const I = S ? S[c] : [];
|
|
210
210
|
return p[c] = I.reduce(
|
|
211
|
-
(u,
|
|
212
|
-
const
|
|
213
|
-
return u.minY = Math.min(u.minY, isNaN(w.left) ? u.minY : w.left, isNaN(
|
|
211
|
+
(u, x) => {
|
|
212
|
+
const N = x.bounded ? x.xBounds : this.scales.x[c].domain(), w = x.getInterval(N[0]), L = x.getInterval(N[1]);
|
|
213
|
+
return u.minY = Math.min(u.minY, isNaN(w.left) ? u.minY : w.left, isNaN(L.left) ? u.minY : L.left), u.maxY = Math.max(u.maxY, isNaN(w.right) ? u.maxY : w.right, isNaN(L.right) ? u.maxY : L.right), u;
|
|
214
214
|
},
|
|
215
215
|
{ minY: 1 / 0, maxY: -1 / 0 }
|
|
216
216
|
), r = Math.min(r, p[c].minY), g = Math.max(g, p[c].maxY), p;
|
|
@@ -221,17 +221,17 @@ class ci {
|
|
|
221
221
|
c = y().range([this.chartSizes.chartHeight, 0]).domain(f.keys ?? []).padding(0.5);
|
|
222
222
|
else {
|
|
223
223
|
c = e.scale === "log" ? K() : B();
|
|
224
|
-
const u =
|
|
225
|
-
let
|
|
224
|
+
const u = M[p], x = R[p];
|
|
225
|
+
let N = e.lowerValue ? Number(e.lowerValue) : i.sharedY ? r : Math.min(u.minY, x.minY), w = e.upperValue ? Number(e.upperValue) : i.sharedY ? g : Math.max(u.maxY, x.maxY);
|
|
226
226
|
if (typeof e.symmetricRange < "u") {
|
|
227
227
|
const H = e.symmetricRange;
|
|
228
|
-
if (H >=
|
|
229
|
-
const j = Math.max(H -
|
|
230
|
-
|
|
228
|
+
if (H >= N && H <= w) {
|
|
229
|
+
const j = Math.max(H - N, w - H);
|
|
230
|
+
N = H - j, w = H + j;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
const
|
|
234
|
-
c.domain([_.invert(this.chartSizes.chartHeight), _.invert(0)]).range(
|
|
233
|
+
const L = [this.chartSizes.chartHeight, 0], _ = c.copy().domain([N, w]).range([this.chartSizes.chartHeight - P.BOTTOM, P.TOP]);
|
|
234
|
+
c.domain([_.invert(this.chartSizes.chartHeight), _.invert(0)]).range(L).nice();
|
|
235
235
|
}
|
|
236
236
|
const I = this.scales.y[p];
|
|
237
237
|
m[p] = c, E = E || tt(I, c);
|
|
@@ -242,7 +242,7 @@ class ci {
|
|
|
242
242
|
function f(n) {
|
|
243
243
|
return Math.max(...n.map((r) => o.getTextWidth(r)));
|
|
244
244
|
}
|
|
245
|
-
let T = 0,
|
|
245
|
+
let T = 0, S = 0, d = [], z = [], W = 0, h = 0;
|
|
246
246
|
if (i.scale === "discrete") {
|
|
247
247
|
const n = k(
|
|
248
248
|
t,
|
|
@@ -266,19 +266,19 @@ class ci {
|
|
|
266
266
|
"horizontal",
|
|
267
267
|
this.scales.y
|
|
268
268
|
);
|
|
269
|
-
|
|
269
|
+
S = n.yTail, z = n.axisCaptionsWidthByColumns;
|
|
270
270
|
} else
|
|
271
271
|
Object.values(this.scales.y).forEach((n) => {
|
|
272
|
-
const { ticks: r, format: g } =
|
|
272
|
+
const { ticks: r, format: g } = St(n, e);
|
|
273
273
|
h = Math.max(h, f(r.map(g)));
|
|
274
274
|
});
|
|
275
275
|
this.captionsSizes = {
|
|
276
|
-
xAxisCaptionsWidth: it(W, i),
|
|
277
|
-
yAxisCaptionsWidth: it(h, s),
|
|
276
|
+
xAxisCaptionsWidth: i.hiddenLabels ? 0 : it(W, i),
|
|
277
|
+
yAxisCaptionsWidth: s.hiddenLabels ? 0 : it(h, s),
|
|
278
278
|
bottomAxisCaptionsWidthByRows: d,
|
|
279
|
-
leftAxisCaptionsWidthByColumns:
|
|
279
|
+
leftAxisCaptionsWidthByColumns: z,
|
|
280
280
|
bottomCaptionsTail: T,
|
|
281
|
-
leftCaptionsTail:
|
|
281
|
+
leftCaptionsTail: S
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
createMainTitle(t, i) {
|
|
@@ -329,7 +329,7 @@ class ci {
|
|
|
329
329
|
const o = [], f = { width: 0, height: 0, left: 0, top: 0 }, T = Math.min(
|
|
330
330
|
Math.max(this.chartSizes.chartHeight, lt),
|
|
331
331
|
ct
|
|
332
|
-
),
|
|
332
|
+
), S = Math.max(this.chartSizes.chartHeight, T);
|
|
333
333
|
if (s.forEach((h) => {
|
|
334
334
|
const n = i[h.value];
|
|
335
335
|
if (n.usedAes.length === 0 || !n.aesMap)
|
|
@@ -340,36 +340,36 @@ class ci {
|
|
|
340
340
|
}
|
|
341
341
|
const r = {};
|
|
342
342
|
n.values.forEach((l) => {
|
|
343
|
-
r[l] || (r[l] = { ...
|
|
343
|
+
r[l] || (r[l] = { ...A }), n.usedAes.forEach((m) => {
|
|
344
344
|
(m === "dotFill" || m === "lineColor") && (r[l].color = n.aesMap(l, m) ?? et), m === "dotShape" && (r[l].shape = n.aesMap(l, m) ?? "21"), m === "dotSize" && (r[l].size = n.aesMap(l, m) ?? 3);
|
|
345
345
|
});
|
|
346
346
|
});
|
|
347
|
-
const g = h.label ?? h.value,
|
|
348
|
-
o.push({ ...f, id: h.value, type: "dots", title: g, scale:
|
|
347
|
+
const g = h.label ?? h.value, M = bt().domain(n.values).range(n.values.map((l) => r[l])).unknown(A);
|
|
348
|
+
o.push({ ...f, id: h.value, type: "dots", title: g, scale: M, values: n.values, labels: n.labels });
|
|
349
349
|
}), e.forEach((h) => {
|
|
350
350
|
if (h.type === "dots" && q(h.aes.dotFill)) {
|
|
351
|
-
const { domain: n, range: r, columnName: g, type:
|
|
351
|
+
const { domain: n, range: r, columnName: g, type: M = "linear" } = h.aes.dotFill, l = g.label ?? g.value, m = gt(r, n, "linear"), C = (M === "log" ? xt() : B()).domain(n).range([T, 0]), E = ft(C, n);
|
|
352
352
|
o.push({ ...f, id: "dotFill", type: "continuous", title: l, scale: m, tickPositionScale: C, values: E });
|
|
353
353
|
}
|
|
354
354
|
if (h.type === "dots" && q(h.aes.dotSize)) {
|
|
355
|
-
const { columnName: n, domain: r, range: g } = h.aes.dotSize,
|
|
356
|
-
o.push({ ...f, id: n.value, type: "size", title:
|
|
355
|
+
const { columnName: n, domain: r, range: g } = h.aes.dotSize, M = n.label ?? n.value, l = Nt(r, g), m = l.ticks(3), C = l.tickFormat(3), E = m.reduce((R, p) => (R[String(p)] = C(p), R), {});
|
|
356
|
+
o.push({ ...f, id: n.value, type: "size", title: M, scale: l, values: m, labels: E });
|
|
357
357
|
}
|
|
358
358
|
}), !o.length) {
|
|
359
359
|
this.legend = { width: 0, height: 0, items: [] };
|
|
360
360
|
return;
|
|
361
361
|
}
|
|
362
|
-
const d = ut(o,
|
|
362
|
+
const d = ut(o, S, T), z = d[d.length - 1], W = z.left + z.width + Mt;
|
|
363
363
|
this.legend = {
|
|
364
364
|
width: W,
|
|
365
|
-
height:
|
|
365
|
+
height: S,
|
|
366
366
|
items: d
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
|
-
render(t, i, s, e, o, f, T,
|
|
369
|
+
render(t, i, s, e, o, f, T, S, d, z, W, h, n, r, g, M, l, m) {
|
|
370
370
|
var u;
|
|
371
371
|
const { xAxis: C, yAxis: E, size: R, title: p, legend: c } = s;
|
|
372
|
-
this.updateChartSizes(R), this.updateViewport(o, e, C, E,
|
|
372
|
+
this.updateChartSizes(R), this.updateViewport(o, e, C, E, M, l, T, S), this.createAxisLabels(o, C, E, M, l), this.updateCaptionsSize(o, C, E, z.y), this.createFacetTitles(o, f), this.updateChartDimensions(o, e, C, E), this.updateLegendSize(c, W, n, r), this.createMainTitle(o, p), this.updateMargins(o);
|
|
373
373
|
const I = /* @__PURE__ */ v.jsx(ht, { dataFrame: t, children: /* @__PURE__ */ v.jsx(
|
|
374
374
|
Ct,
|
|
375
375
|
{
|
|
@@ -381,7 +381,7 @@ class ci {
|
|
|
381
381
|
chartsDimensions: this.chartsDimensions,
|
|
382
382
|
scales: this.scales,
|
|
383
383
|
groupedDots: T,
|
|
384
|
-
trendsData:
|
|
384
|
+
trendsData: S,
|
|
385
385
|
legendData: this.legend,
|
|
386
386
|
columnsCount: this.columnsCount,
|
|
387
387
|
margins: this.margins,
|
|
@@ -389,9 +389,9 @@ class ci {
|
|
|
389
389
|
mainTitle: this.mainTitle,
|
|
390
390
|
facetTitles: this.facetTitles,
|
|
391
391
|
captionsSizes: this.captionsSizes,
|
|
392
|
-
onlyPositive:
|
|
392
|
+
onlyPositive: z,
|
|
393
393
|
layersData: h,
|
|
394
|
-
aesGetters:
|
|
394
|
+
aesGetters: Lt(t, W, r, g),
|
|
395
395
|
onTooltipHintSwitch: m,
|
|
396
396
|
discreteAxesLabels: this.discreteAxesLabels
|
|
397
397
|
}
|