@visactor/vseed 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/dist/cjs/index.cjs +2 -2
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/esm/builder/register/all.js +3 -1
  4. package/dist/esm/builder/register/all.js.map +1 -1
  5. package/dist/esm/builder/register/chartType/hierarchySankey.d.ts +4 -0
  6. package/dist/esm/builder/register/chartType/hierarchySankey.js +9 -0
  7. package/dist/esm/builder/register/chartType/hierarchySankey.js.map +1 -0
  8. package/dist/esm/builder/register/chartType/index.d.ts +2 -0
  9. package/dist/esm/builder/register/chartType/index.js +2 -0
  10. package/dist/esm/builder/register/chartType/sankey.d.ts +1 -0
  11. package/dist/esm/builder/register/chartType/sankey.js +9 -0
  12. package/dist/esm/builder/register/chartType/sankey.js.map +1 -0
  13. package/dist/esm/dataReshape/constant.d.ts +2 -0
  14. package/dist/esm/dataReshape/constant.js +3 -1
  15. package/dist/esm/dataReshape/constant.js.map +1 -1
  16. package/dist/esm/dataReshape/unfoldDimensions.js +8 -2
  17. package/dist/esm/dataReshape/unfoldDimensions.js.map +1 -1
  18. package/dist/esm/index.d.ts +1 -1
  19. package/dist/esm/index.js +1 -1
  20. package/dist/esm/pipeline/advanced/chart/pipeline/hierarchySankey.d.ts +2 -0
  21. package/dist/esm/pipeline/advanced/chart/pipeline/hierarchySankey.js +33 -0
  22. package/dist/esm/pipeline/advanced/chart/pipeline/hierarchySankey.js.map +1 -0
  23. package/dist/esm/pipeline/advanced/chart/pipeline/index.d.ts +2 -0
  24. package/dist/esm/pipeline/advanced/chart/pipeline/index.js +2 -0
  25. package/dist/esm/pipeline/advanced/chart/pipeline/sankey.d.ts +2 -0
  26. package/dist/esm/pipeline/advanced/chart/pipeline/sankey.js +33 -0
  27. package/dist/esm/pipeline/advanced/chart/pipeline/sankey.js.map +1 -0
  28. package/dist/esm/pipeline/advanced/chart/pipes/config/hierarchySankey.d.ts +2 -0
  29. package/dist/esm/pipeline/advanced/chart/pipes/config/hierarchySankey.js +27 -0
  30. package/dist/esm/pipeline/advanced/chart/pipes/config/hierarchySankey.js.map +1 -0
  31. package/dist/esm/pipeline/advanced/chart/pipes/config/index.d.ts +2 -0
  32. package/dist/esm/pipeline/advanced/chart/pipes/config/index.js +2 -0
  33. package/dist/esm/pipeline/advanced/chart/pipes/config/index.js.map +1 -1
  34. package/dist/esm/pipeline/advanced/chart/pipes/config/sankey.d.ts +2 -0
  35. package/dist/esm/pipeline/advanced/chart/pipes/config/sankey.js +27 -0
  36. package/dist/esm/pipeline/advanced/chart/pipes/config/sankey.js.map +1 -0
  37. package/dist/esm/pipeline/advanced/chart/pipes/encoding/index.d.ts +1 -0
  38. package/dist/esm/pipeline/advanced/chart/pipes/encoding/index.js +1 -0
  39. package/dist/esm/pipeline/advanced/chart/pipes/encoding/sankey.d.ts +3 -0
  40. package/dist/esm/pipeline/advanced/chart/pipes/encoding/sankey.js +83 -0
  41. package/dist/esm/pipeline/advanced/chart/pipes/encoding/sankey.js.map +1 -0
  42. package/dist/esm/pipeline/spec/chart/pipeline/hierarchySankey.d.ts +1 -0
  43. package/dist/esm/pipeline/spec/chart/pipeline/hierarchySankey.js +39 -0
  44. package/dist/esm/pipeline/spec/chart/pipeline/hierarchySankey.js.map +1 -0
  45. package/dist/esm/pipeline/spec/chart/pipeline/index.d.ts +2 -0
  46. package/dist/esm/pipeline/spec/chart/pipeline/index.js +2 -0
  47. package/dist/esm/pipeline/spec/chart/pipeline/sankey.d.ts +1 -0
  48. package/dist/esm/pipeline/spec/chart/pipeline/sankey.js +39 -0
  49. package/dist/esm/pipeline/spec/chart/pipeline/sankey.js.map +1 -0
  50. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.js +11 -2
  51. package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationPointOfDualAxis.js.map +1 -1
  52. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchy.js +5 -2
  53. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchy.js.map +1 -1
  54. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchySankey.d.ts +4 -0
  55. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchySankey.js +136 -0
  56. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetHierarchySankey.js.map +1 -0
  57. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchy.d.ts +1 -0
  58. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchy.js +1 -1
  59. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchy.js.map +1 -1
  60. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchySankey.d.ts +2 -0
  61. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchySankey.js +44 -0
  62. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotHierarchySankey.js.map +1 -0
  63. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotSankey.d.ts +2 -0
  64. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotSankey.js +50 -0
  65. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetPivotSankey.js.map +1 -0
  66. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetSankey.d.ts +16 -0
  67. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetSankey.js +97 -0
  68. package/dist/esm/pipeline/spec/chart/pipes/dataset/datasetSankey.js.map +1 -0
  69. package/dist/esm/pipeline/spec/chart/pipes/dataset/index.d.ts +4 -0
  70. package/dist/esm/pipeline/spec/chart/pipes/dataset/index.js +4 -0
  71. package/dist/esm/pipeline/spec/chart/pipes/init/circlePacking.js +1 -1
  72. package/dist/esm/pipeline/spec/chart/pipes/init/circlePacking.js.map +1 -1
  73. package/dist/esm/pipeline/spec/chart/pipes/init/hierarchySankey.d.ts +2 -0
  74. package/dist/esm/pipeline/spec/chart/pipes/init/hierarchySankey.js +32 -0
  75. package/dist/esm/pipeline/spec/chart/pipes/init/hierarchySankey.js.map +1 -0
  76. package/dist/esm/pipeline/spec/chart/pipes/init/index.d.ts +2 -0
  77. package/dist/esm/pipeline/spec/chart/pipes/init/index.js +2 -0
  78. package/dist/esm/pipeline/spec/chart/pipes/init/sankey.d.ts +2 -0
  79. package/dist/esm/pipeline/spec/chart/pipes/init/sankey.js +33 -0
  80. package/dist/esm/pipeline/spec/chart/pipes/init/sankey.js.map +1 -0
  81. package/dist/esm/pipeline/spec/chart/pipes/init/sunburst.js +1 -1
  82. package/dist/esm/pipeline/spec/chart/pipes/init/sunburst.js.map +1 -1
  83. package/dist/esm/pipeline/spec/chart/pipes/init/treeMap.js +1 -1
  84. package/dist/esm/pipeline/spec/chart/pipes/init/treeMap.js.map +1 -1
  85. package/dist/esm/pipeline/spec/chart/pipes/label/index.d.ts +2 -0
  86. package/dist/esm/pipeline/spec/chart/pipes/label/index.js +2 -0
  87. package/dist/esm/pipeline/spec/chart/pipes/label/label.js.map +1 -1
  88. package/dist/esm/pipeline/spec/chart/pipes/label/labelHierarchySankey.d.ts +17 -0
  89. package/dist/esm/pipeline/spec/chart/pipes/label/labelHierarchySankey.js +92 -0
  90. package/dist/esm/pipeline/spec/chart/pipes/label/labelHierarchySankey.js.map +1 -0
  91. package/dist/esm/pipeline/spec/chart/pipes/label/labelSankey.d.ts +2 -0
  92. package/dist/esm/pipeline/spec/chart/pipes/label/labelSankey.js +78 -0
  93. package/dist/esm/pipeline/spec/chart/pipes/label/labelSankey.js.map +1 -0
  94. package/dist/esm/pipeline/spec/chart/pipes/label/labelTreeMapLeaf.js +4 -4
  95. package/dist/esm/pipeline/spec/chart/pipes/label/labelTreeMapLeaf.js.map +1 -1
  96. package/dist/esm/pipeline/spec/chart/pipes/legend/pivotColorLegend.js +1 -1
  97. package/dist/esm/pipeline/spec/chart/pipes/legend/pivotColorLegend.js.map +1 -1
  98. package/dist/esm/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js +1 -1
  99. package/dist/esm/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js.map +1 -1
  100. package/dist/esm/pipeline/spec/chart/pipes/markStyle/index.d.ts +1 -0
  101. package/dist/esm/pipeline/spec/chart/pipes/markStyle/index.js +1 -0
  102. package/dist/esm/pipeline/spec/chart/pipes/markStyle/sankeyInteractive.d.ts +2 -0
  103. package/dist/esm/pipeline/spec/chart/pipes/markStyle/sankeyInteractive.js +33 -0
  104. package/dist/esm/pipeline/spec/chart/pipes/markStyle/sankeyInteractive.js.map +1 -0
  105. package/dist/esm/pipeline/spec/chart/pipes/tooltip/index.d.ts +2 -0
  106. package/dist/esm/pipeline/spec/chart/pipes/tooltip/index.js +2 -0
  107. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.d.ts +2 -0
  108. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.js +150 -0
  109. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.js.map +1 -0
  110. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipSankey.d.ts +2 -0
  111. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipSankey.js +75 -0
  112. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipSankey.js.map +1 -0
  113. package/dist/esm/pipeline/utils/chatType.d.ts +2 -0
  114. package/dist/esm/pipeline/utils/chatType.js +3 -1
  115. package/dist/esm/pipeline/utils/chatType.js.map +1 -1
  116. package/dist/esm/pipeline/utils/constant.d.ts +2 -0
  117. package/dist/esm/pipeline/utils/constant.js +2 -0
  118. package/dist/esm/pipeline/utils/constant.js.map +1 -1
  119. package/dist/esm/pipeline/utils/measures/typeGuard.js +1 -1
  120. package/dist/esm/pipeline/utils/measures/typeGuard.js.map +1 -1
  121. package/dist/esm/theme/dark/dark.js +3 -1
  122. package/dist/esm/theme/dark/dark.js.map +1 -1
  123. package/dist/esm/theme/dark/hierarchy.d.ts +132 -0
  124. package/dist/esm/theme/dark/hierarchy.js +3 -1
  125. package/dist/esm/theme/dark/hierarchy.js.map +1 -1
  126. package/dist/esm/theme/light/hierarchy.d.ts +132 -0
  127. package/dist/esm/theme/light/hierarchy.js +3 -1
  128. package/dist/esm/theme/light/hierarchy.js.map +1 -1
  129. package/dist/esm/theme/light/light.js +3 -1
  130. package/dist/esm/theme/light/light.js.map +1 -1
  131. package/dist/esm/types/chartType/area/zArea.d.ts +4 -0
  132. package/dist/esm/types/chartType/areaPercent/zAreaPercent.d.ts +4 -0
  133. package/dist/esm/types/chartType/bar/zBar.d.ts +4 -0
  134. package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +4 -0
  135. package/dist/esm/types/chartType/barPercent/zBarPercent.d.ts +4 -0
  136. package/dist/esm/types/chartType/boxPlot/zBoxPlot.d.ts +4 -0
  137. package/dist/esm/types/chartType/circlePacking/zCirclePacking.d.ts +2 -0
  138. package/dist/esm/types/chartType/column/zColumn.d.ts +4 -0
  139. package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +4 -0
  140. package/dist/esm/types/chartType/columnPercent/zColumnPercent.d.ts +4 -0
  141. package/dist/esm/types/chartType/donut/zDonut.d.ts +4 -0
  142. package/dist/esm/types/chartType/dualAxis/zDualAxis.d.ts +2 -0
  143. package/dist/esm/types/chartType/funnel/zFunnel.d.ts +4 -0
  144. package/dist/esm/types/chartType/heatmap/zHeatmap.d.ts +2 -0
  145. package/dist/esm/types/chartType/hierarchySankey/hierarchySankey.d.ts +92 -0
  146. package/dist/esm/types/chartType/hierarchySankey/hierarchySankey.js +0 -0
  147. package/dist/esm/types/chartType/hierarchySankey/index.d.ts +2 -0
  148. package/dist/esm/types/chartType/hierarchySankey/index.js +1 -0
  149. package/dist/esm/types/chartType/hierarchySankey/zHierarchySankey.d.ts +422 -0
  150. package/dist/esm/types/chartType/hierarchySankey/zHierarchySankey.js +20 -0
  151. package/dist/esm/types/chartType/hierarchySankey/zHierarchySankey.js.map +1 -0
  152. package/dist/esm/types/chartType/histogram/zHistogram.d.ts +4 -0
  153. package/dist/esm/types/chartType/index.d.ts +2 -0
  154. package/dist/esm/types/chartType/index.js +2 -0
  155. package/dist/esm/types/chartType/line/zLine.d.ts +4 -0
  156. package/dist/esm/types/chartType/pie/zPie.d.ts +4 -0
  157. package/dist/esm/types/chartType/pivotTable/zPivotTable.d.ts +2 -0
  158. package/dist/esm/types/chartType/raceBar/zRaceBar.d.ts +4 -0
  159. package/dist/esm/types/chartType/raceColumn/zRaceColumn.d.ts +4 -0
  160. package/dist/esm/types/chartType/raceDonut/zRaceDonut.d.ts +4 -0
  161. package/dist/esm/types/chartType/raceLine/zRaceLine.d.ts +4 -0
  162. package/dist/esm/types/chartType/racePie/zRacePie.d.ts +4 -0
  163. package/dist/esm/types/chartType/raceScatter/zRaceScatter.d.ts +4 -0
  164. package/dist/esm/types/chartType/radar/zRadar.d.ts +4 -0
  165. package/dist/esm/types/chartType/rose/zRose.d.ts +4 -0
  166. package/dist/esm/types/chartType/roseParallel/zRoseParallel.d.ts +4 -0
  167. package/dist/esm/types/chartType/sankey/index.d.ts +2 -0
  168. package/dist/esm/types/chartType/sankey/index.js +1 -0
  169. package/dist/esm/types/chartType/sankey/sankey.d.ts +91 -0
  170. package/dist/esm/types/chartType/sankey/sankey.js +0 -0
  171. package/dist/esm/types/chartType/sankey/zSankey.d.ts +422 -0
  172. package/dist/esm/types/chartType/sankey/zSankey.js +20 -0
  173. package/dist/esm/types/chartType/sankey/zSankey.js.map +1 -0
  174. package/dist/esm/types/chartType/scatter/zScatter.d.ts +4 -0
  175. package/dist/esm/types/chartType/sunburst/zSunburst.d.ts +2 -0
  176. package/dist/esm/types/chartType/table/zTable.d.ts +2 -0
  177. package/dist/esm/types/chartType/treeMap/zTreeMap.d.ts +2 -0
  178. package/dist/esm/types/properties/chartType/chartType.d.ts +3 -1
  179. package/dist/esm/types/properties/chartType/chartType.js +2 -0
  180. package/dist/esm/types/properties/chartType/chartType.js.map +1 -1
  181. package/dist/esm/types/properties/config/config.d.ts +602 -0
  182. package/dist/esm/types/properties/config/config.js +4 -0
  183. package/dist/esm/types/properties/config/config.js.map +1 -1
  184. package/dist/esm/types/properties/config/hierarchySankey.d.ts +303 -0
  185. package/dist/esm/types/properties/config/hierarchySankey.js +18 -0
  186. package/dist/esm/types/properties/config/hierarchySankey.js.map +1 -0
  187. package/dist/esm/types/properties/config/index.d.ts +2 -0
  188. package/dist/esm/types/properties/config/index.js +2 -0
  189. package/dist/esm/types/properties/config/sankey.d.ts +303 -0
  190. package/dist/esm/types/properties/config/sankey.js +18 -0
  191. package/dist/esm/types/properties/config/sankey.js.map +1 -0
  192. package/dist/esm/types/properties/datasetReshapeInfo/datasetReshapeInfo.d.ts +2 -0
  193. package/dist/esm/types/properties/datasetReshapeInfo/zDatasetReshapeInfo.d.ts +4 -0
  194. package/dist/esm/types/properties/datasetReshapeInfo/zDatasetReshapeInfo.js +2 -0
  195. package/dist/esm/types/properties/datasetReshapeInfo/zDatasetReshapeInfo.js.map +1 -1
  196. package/dist/esm/types/properties/dimensions/index.d.ts +1 -0
  197. package/dist/esm/types/properties/dimensions/sankeyDimension.d.ts +15 -0
  198. package/dist/esm/types/properties/dimensions/sankeyDimension.js +0 -0
  199. package/dist/esm/types/properties/dimensions/zDimensions.d.ts +6 -0
  200. package/dist/esm/types/properties/encoding/dimensionEncoding.d.ts +3 -1
  201. package/dist/esm/types/properties/encoding/encoding.d.ts +8 -0
  202. package/dist/esm/types/properties/encoding/zDimensionEncoding.d.ts +4 -0
  203. package/dist/esm/types/properties/encoding/zDimensionEncoding.js +6 -2
  204. package/dist/esm/types/properties/encoding/zDimensionEncoding.js.map +1 -1
  205. package/dist/esm/types/properties/encoding/zEncoding.d.ts +4 -0
  206. package/dist/esm/types/properties/encoding/zEncoding.js +5 -1
  207. package/dist/esm/types/properties/encoding/zEncoding.js.map +1 -1
  208. package/dist/esm/types/properties/measures/index.d.ts +1 -0
  209. package/dist/esm/types/properties/measures/sankeyMeasure.d.ts +11 -0
  210. package/dist/esm/types/properties/measures/sankeyMeasure.js +0 -0
  211. package/dist/esm/types/properties/theme/customTheme.d.ts +3752 -2548
  212. package/dist/esm/types/vseed.d.ts +2 -2
  213. package/dist/esm/types/zVseed.js +3 -1
  214. package/dist/esm/types/zVseed.js.map +1 -1
  215. package/dist/umd/index.js +1309 -182
  216. package/dist/umd/index.js.map +1 -1
  217. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/label/labelSankey.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/label/labelSankey.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport { isNumber, merge } from 'remeda'\nimport { selector, selectorWithDynamicFilter } from 'src/dataSelector'\nimport { DATUM_HIDE_KEY, createFormatter, findMeasureById } from 'src/pipeline/utils'\nimport type { Datum, FoldInfo, SankeyMeasure, Label, NumFormat, VChartSpecPipe } from 'src/types'\nimport { generateMeasurePercent, generateMeasureValue } from './label'\n\nexport const labelSankey: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as ILineChartSpec\n const { advancedVSeed, vseed } = context\n const { datasetReshapeInfo, chartType, encoding } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { label?: Label }\n const foldInfo = datasetReshapeInfo[0].foldInfo as FoldInfo\n const label = baseConfig?.label\n\n if (!label) {\n return result as any\n }\n\n result.label = buildLabel(\n label,\n (vseed.measures || advancedVSeed.measures || []) as SankeyMeasure[],\n (advancedVSeed.measures || []) as SankeyMeasure[],\n (encoding.label || []) as string[],\n foldInfo,\n ) as unknown as ILineChartSpec['label']\n\n return result\n}\n\nconst buildLabel = (\n label: Label,\n vseedMeasures: SankeyMeasure[],\n advancedVSeedMeasures: SankeyMeasure[],\n labelEncodingIds: string[],\n foldInfo: Pick<FoldInfo, 'measureId' | 'measureValue'> & Partial<Pick<FoldInfo, 'statistics'>>,\n) => {\n const {\n enable,\n wrap,\n showValue,\n showValuePercent,\n showDimension,\n labelOverlap,\n labelColorSmartInvert,\n labelStroke,\n labelColor,\n labelFontSize,\n labelFontWeight,\n labelBackgroundColor,\n labelPosition,\n autoFormat,\n numFormat = {},\n } = label\n\n const hasMeasureLabelEncoding = vseedMeasures.some((item) => labelEncodingIds.includes(item.id))\n const labelMeasures = hasMeasureLabelEncoding\n ? vseedMeasures.filter((item) => labelEncodingIds.includes(item.id))\n : []\n\n const percentFormat: NumFormat = merge(numFormat, {\n type: 'percent',\n } as NumFormat)\n const percentFormatter = createFormatter(percentFormat)\n\n const result = {\n visible: enable,\n dataFilter: (data: Datum[]) => {\n return data.filter((entry) => {\n if (entry.data?.[DATUM_HIDE_KEY]) {\n return false\n }\n const shouldApply = label.dynamicFilter\n ? selectorWithDynamicFilter(entry.data as Datum, label.dynamicFilter, label.selector)\n : selector(entry.data as Datum, label.selector, 'Or')\n return shouldApply\n })\n },\n formatMethod: (_: unknown, datum: Datum) => {\n const parts: string[] = []\n\n if (showDimension && datum?.nodeName) {\n parts.push(String(datum.nodeName))\n }\n\n if (showValue) {\n const { measureId, measureValue } = foldInfo\n const measure = findMeasureById(advancedVSeedMeasures, datum[measureId] as string)\n if (measure && datum[measureValue] !== undefined && datum[measureValue] !== null) {\n parts.push(generateMeasureValue(datum[measureValue] as number | string, measure, autoFormat, numFormat))\n } else if (datum.value !== undefined && datum.value !== null) {\n const fallbackMeasure =\n findMeasureById(advancedVSeedMeasures, foldInfo.measureId) ||\n findMeasureById(vseedMeasures, foldInfo.measureId) ||\n advancedVSeedMeasures[0]\n if (fallbackMeasure) {\n parts.push(generateMeasureValue(datum.value as number | string, fallbackMeasure, autoFormat, numFormat))\n } else {\n parts.push(String(datum.value))\n }\n }\n }\n\n if (showValuePercent) {\n const ratioValue = datum['__VCHART_ARC_RATIO']\n if (isNumber(ratioValue)) {\n parts.push(generateMeasurePercent(ratioValue, 1, percentFormatter))\n } else if (\n foldInfo.statistics &&\n isNumber(foldInfo.statistics.sum) &&\n datum[foldInfo.measureValue] !== undefined &&\n datum[foldInfo.measureValue] !== null\n ) {\n parts.push(\n generateMeasurePercent(\n datum[foldInfo.measureValue] as number | string,\n foldInfo.statistics.sum,\n percentFormatter,\n ),\n )\n }\n }\n\n labelMeasures.forEach((measure) => {\n const rawValue = datum[measure.id]\n if (rawValue === undefined || rawValue === null || rawValue === '') {\n return\n }\n parts.push(generateMeasureValue(rawValue as number | string, measure, autoFormat, numFormat))\n })\n\n return wrap ? parts : parts.join(' ')\n },\n syncState: true,\n position: labelPosition,\n style: {\n stroke: labelStroke,\n fill: labelColor,\n fontSize: labelFontSize,\n fontWeight: labelFontWeight,\n background: labelBackgroundColor,\n },\n smartInvert: labelColorSmartInvert,\n }\n\n if (labelColorSmartInvert) {\n ;(result.style as any).lineWidth = 2\n }\n\n if (labelOverlap) {\n ;(result as any).overlap = {\n hideOnHit: true,\n clampForce: true,\n }\n }\n\n return result\n}\n"],"names":["labelSankey","spec","context","result","advancedVSeed","vseed","datasetReshapeInfo","chartType","encoding","baseConfig","foldInfo","label","buildLabel","vseedMeasures","advancedVSeedMeasures","labelEncodingIds","enable","wrap","showValue","showValuePercent","showDimension","labelOverlap","labelColorSmartInvert","labelStroke","labelColor","labelFontSize","labelFontWeight","labelBackgroundColor","labelPosition","autoFormat","numFormat","hasMeasureLabelEncoding","item","labelMeasures","percentFormat","merge","percentFormatter","createFormatter","data","entry","DATUM_HIDE_KEY","shouldApply","selectorWithDynamicFilter","selector","_","datum","parts","String","measureId","measureValue","measure","findMeasureById","undefined","generateMeasureValue","fallbackMeasure","ratioValue","isNumber","generateMeasurePercent","rawValue"],"mappings":";;;;AAOO,MAAMA,cAA8B,CAACC,MAAMC;IAChD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,kBAAkB,EAAEC,SAAS,EAAEC,QAAQ,EAAE,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R;YAEAH,cAAc,OAAO,CAAC,CAACiB;gBACrB,MAAMQ,WAAWb,KAAK,CAACK,QAAQ,EAAE,CAAC;gBAClC,IAAIQ,QAAAA,YAA+CA,AAAa,OAAbA,UACjD;gBAEFZ,MAAM,IAAI,CAACO,qBAAqBK,UAA6BR,SAASrB,YAAYC;YACpF;YAEA,OAAOb,OAAO6B,QAAQA,MAAM,IAAI,CAAC;QACnC;QACA,WAAW;QACX,UAAUlB;QACV,OAAO;YACL,QAAQL;YACR,MAAMC;YACN,UAAUC;YACV,YAAYC;YACZ,YAAYC;QACd;QACA,aAAaL;IACf;IAEA,IAAIA,uBACAnB,OAAO,KAAK,CAAS,SAAS,GAAG;IAGrC,IAAIkB,cACAlB,OAAe,OAAO,GAAG;QACzB,WAAW;QACX,YAAY;IACd;IAGF,OAAOA;AACT"}
@@ -22,14 +22,14 @@ const labelTreeMapLeaf = (spec, context)=>{
22
22
  });
23
23
  const percentFormatter = createFormatter(percentFormat);
24
24
  if (result.label) result.label.formatMethod = (_, datum)=>{
25
- const nodeName = datum.name;
25
+ const nodeName = datum.value;
26
26
  const dataArray = datum.datum;
27
27
  if (!dataArray || !Array.isArray(dataArray)) return '';
28
- const findDataNode = (nodes, name)=>{
28
+ const findDataNode = (nodes, value)=>{
29
29
  for (const node of nodes){
30
- if (node.name === name) return node;
30
+ if (node.value === value) return node;
31
31
  if (node.children) {
32
- const found = findDataNode(node.children, name);
32
+ const found = findDataNode(node.children, value);
33
33
  if (found) return found;
34
34
  }
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/spec/chart/pipes/label/labelTreeMapLeaf.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/label/labelTreeMapLeaf.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport { createFormatter, createFormatterByDimension, findMeasureById } from '../../../../utils'\nimport type { Datum, Dimension, FoldInfo, Label, Measure, NumFormat, VChartSpecPipe } from 'src/types'\nimport { isNumber, merge, uniqueBy } from 'remeda'\nimport { MeasureId } from 'src/dataReshape/constant'\nimport { label as commonLabel, generateMeasurePercent, generateMeasureValue } from './label'\n\nexport const labelTreeMapLeaf: VChartSpecPipe = (spec, context) => {\n const result = commonLabel(spec, context) as ILineChartSpec\n const { advancedVSeed, vseed } = context\n const { datasetReshapeInfo } = advancedVSeed\n const { chartType, encoding } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { label: Label }\n const foldInfoList = [datasetReshapeInfo[0].foldInfo as FoldInfo]\n\n const { label } = baseConfig\n if (!label.enable) {\n return result\n }\n\n const { showValue, showValuePercent, showDimension, autoFormat, numFormat = {}, wrap } = label\n\n const hasDimLabelEncoding = vseed.dimensions?.some((item) => encoding.label?.includes(item.id))\n\n const labelDims = uniqueBy(\n hasDimLabelEncoding\n ? vseed.dimensions?.filter((item) => encoding.label?.includes(item.id)) || []\n : showDimension\n ? advancedVSeed.dimensions!.filter((d) => d.id !== MeasureId && d.encoding !== 'row' && d.encoding !== 'column')\n : [],\n (item: Dimension) => item.id,\n )\n\n const labelMeas = uniqueBy(\n vseed.measures?.filter((item) => encoding.label?.includes(item.id)) || [],\n (item: Measure) => item.id,\n )\n\n const percentFormat: NumFormat = merge(numFormat, {\n type: 'percent',\n } as NumFormat)\n\n const percentFormatter = createFormatter(percentFormat)\n\n if (result.label) {\n ;(result.label as any).formatMethod = (_: unknown, datum: Datum) => {\n // TreeMap returns a nested structure where `datum` is an array of children.\n // We need to find the specific data item that matches the current node's name.\n // The current node's name is usually available in the top-level datum object (which is `datum` here).\n // However, VChart's TreeMap datum structure is a bit complex.\n // Based on the user provided example:\n // datum: { name: \"Stapler\", datum: [...], ... }\n\n const nodeName = datum.name\n const dataArray = datum.datum as any[]\n\n if (!dataArray || !Array.isArray(dataArray)) {\n return ''\n }\n\n // Helper to find the matching data node recursively\n const findDataNode = (nodes: any[], name: string): any => {\n for (const node of nodes) {\n if (node.name === name) {\n return node\n }\n if (node.children) {\n const found = findDataNode(node.children, name)\n if (found) return found\n }\n }\n return null\n }\n\n // The structure seems to be that `datum` (the array) contains the root(s) of the hierarchy relevant to this node?\n // Or simply the data array we passed in.\n // Let's try to find the node with the matching name.\n const realDatum = findDataNode(dataArray, nodeName as string)\n\n if (!realDatum) {\n return ''\n }\n\n const resultText: string[] = []\n\n // 1. Dimension Labels\n const dimLabels = labelDims\n .map((item: Dimension) => {\n const id = item.id\n const rawValue = (realDatum[id] ?? realDatum.__OriginalData__?.[id]) as number | string\n const formatter = createFormatterByDimension(item, advancedVSeed.locale)\n return formatter(rawValue)\n })\n .filter((v) => v !== undefined && v !== null && v !== '')\n\n resultText.push(...(dimLabels as string[]))\n\n // 2. Measure Labels (from label encoding)\n const meaLabels = labelMeas.map((item: Measure) =>\n generateMeasureValue(\n (realDatum[item.id] ?? realDatum.__OriginalData__?.[item.id]) as number | string,\n item,\n autoFormat,\n numFormat,\n ),\n )\n resultText.push(...meaLabels)\n\n // 3. Value and Percent (default/implicit)\n foldInfoList.forEach((foldInfo) => {\n const { measureId, measureValue, statistics } = foldInfo\n // The measure ID might be in __MeaId__ or we look it up from the datum\n const currentMeasureId = (realDatum[measureId] ?? realDatum.__MeaId__) as string\n const measure = findMeasureById(advancedVSeed.measures!, currentMeasureId)\n\n if (measure) {\n const val = (realDatum[measureValue] ?? realDatum.__MeaValue__ ?? realDatum.value) as number | string\n\n const measureValueLabel = generateMeasureValue(val, measure, autoFormat, numFormat)\n\n if (showValue) {\n resultText.push(measureValueLabel)\n }\n if (showValuePercent) {\n // For TreeMap, percentage usually implies % of parent or total.\n // If we have statistics.sum (total), we can calculate it.\n if (statistics && isNumber(statistics.sum)) {\n resultText.push(generateMeasurePercent(val, statistics.sum, percentFormatter))\n }\n }\n }\n })\n\n if (wrap) {\n return resultText\n }\n return resultText.join(' ')\n }\n }\n\n return result\n}\n"],"names":["labelTreeMapLeaf","spec","context","result","commonLabel","advancedVSeed","vseed","datasetReshapeInfo","chartType","encoding","baseConfig","foldInfoList","label","showValue","showValuePercent","showDimension","autoFormat","numFormat","wrap","hasDimLabelEncoding","item","labelDims","uniqueBy","d","MeasureId","labelMeas","percentFormat","merge","percentFormatter","createFormatter","_","datum","nodeName","dataArray","Array","findDataNode","nodes","name","node","found","realDatum","resultText","dimLabels","id","rawValue","formatter","createFormatterByDimension","v","meaLabels","generateMeasureValue","foldInfo","measureId","measureValue","statistics","currentMeasureId","measure","findMeasureById","val","measureValueLabel","isNumber","generateMeasurePercent"],"mappings":";;;;AAOO,MAAMA,mBAAmC,CAACC,MAAMC;IACrD,MAAMC,SAASC,wBAAYH,MAAMC;IACjC,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGJ;IACjC,MAAM,EAAEK,kBAAkB,EAAE,GAAGF;IAC/B,MAAM,EAAEG,SAAS,EAAEC,QAAQ,EAAE,GAAGJ;IAChC,MAAMK,aAAaL,cAAc,MAAM,CAACG,UAAU;IAClD,MAAMG,eAAe;QAACJ,kBAAkB,CAAC,EAAE,CAAC,QAAQ;KAAa;IAEjE,MAAM,EAAEK,KAAK,EAAE,GAAGF;IAClB,IAAI,CAACE,MAAM,MAAM,EACf,OAAOT;IAGT,MAAM,EAAEU,SAAS,EAAEC,gBAAgB,EAAEC,aAAa,EAAEC,UAAU,EAAEC,YAAY,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAGN;IAEzF,MAAMO,sBAAsBb,MAAM,UAAU,EAAE,KAAK,CAACc,OAASX,SAAS,KAAK,EAAE,SAASW,KAAK,EAAE;IAE7F,MAAMC,YAAYC,SAChBH,sBACIb,MAAM,UAAU,EAAE,OAAO,CAACc,OAASX,SAAS,KAAK,EAAE,SAASW,KAAK,EAAE,MAAM,EAAE,GAC3EL,gBACEV,cAAc,UAAU,CAAE,MAAM,CAAC,CAACkB,IAAMA,EAAE,EAAE,KAAKC,aAAaD,AAAe,UAAfA,EAAE,QAAQ,IAAcA,AAAe,aAAfA,EAAE,QAAQ,IAChG,EAAE,EACR,CAACH,OAAoBA,KAAK,EAAE;IAG9B,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AAK,EAAE,CAAC,EAC5DA,MACAJ,YACAC;QAGJwB,WAAW,IAAI,IAAIO;QAGnBrC,aAAa,OAAO,CAAC,CAACuC;YACpB,MAAM,EAAEC,SAAS,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGH;YAEhD,MAAMI,mBAAoBd,SAAS,CAACW,UAAU,IAAIX,UAAU,SAAS;YACrE,MAAMe,UAAUC,gBAAgBnD,cAAc,QAAQ,EAAGiD;YAEzD,IAAIC,SAAS;gBACX,MAAME,MAAOjB,SAAS,CAACY,aAAa,IAAIZ,UAAU,YAAY,IAAIA,UAAU,KAAK;gBAEjF,MAAMkB,oBAAoBT,qBAAqBQ,KAAKF,SAASvC,YAAYC;gBAEzE,IAAIJ,WACF4B,WAAW,IAAI,CAACiB;gBAElB,IAAI5C,kBAGF;oBAAA,IAAIuC,cAAcM,SAASN,WAAW,GAAG,GACvCZ,WAAW,IAAI,CAACmB,uBAAuBH,KAAKJ,WAAW,GAAG,EAAEzB;gBAC9D;YAEJ;QACF;QAEA,IAAIV,MACF,OAAOuB;QAET,OAAOA,WAAW,IAAI,CAAC;IACzB;IAGF,OAAOtC;AACT"}
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/label/labelTreeMapLeaf.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/label/labelTreeMapLeaf.ts"],"sourcesContent":["import type { ILineChartSpec } from '@visactor/vchart'\nimport { createFormatter, createFormatterByDimension, findMeasureById } from '../../../../utils'\nimport type { Datum, Dimension, FoldInfo, Label, Measure, NumFormat, VChartSpecPipe } from 'src/types'\nimport { isNumber, merge, uniqueBy } from 'remeda'\nimport { MeasureId } from 'src/dataReshape/constant'\nimport { label as commonLabel, generateMeasurePercent, generateMeasureValue } from './label'\n\nexport const labelTreeMapLeaf: VChartSpecPipe = (spec, context) => {\n const result = commonLabel(spec, context) as ILineChartSpec\n const { advancedVSeed, vseed } = context\n const { datasetReshapeInfo } = advancedVSeed\n const { chartType, encoding } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { label: Label }\n const foldInfoList = [datasetReshapeInfo[0].foldInfo as FoldInfo]\n\n const { label } = baseConfig\n if (!label.enable) {\n return result\n }\n\n const { showValue, showValuePercent, showDimension, autoFormat, numFormat = {}, wrap } = label\n\n const hasDimLabelEncoding = vseed.dimensions?.some((item) => encoding.label?.includes(item.id))\n\n const labelDims = uniqueBy(\n hasDimLabelEncoding\n ? vseed.dimensions?.filter((item) => encoding.label?.includes(item.id)) || []\n : showDimension\n ? advancedVSeed.dimensions!.filter((d) => d.id !== MeasureId && d.encoding !== 'row' && d.encoding !== 'column')\n : [],\n (item: Dimension) => item.id,\n )\n\n const labelMeas = uniqueBy(\n vseed.measures?.filter((item) => encoding.label?.includes(item.id)) || [],\n (item: Measure) => item.id,\n )\n\n const percentFormat: NumFormat = merge(numFormat, {\n type: 'percent',\n } as NumFormat)\n\n const percentFormatter = createFormatter(percentFormat)\n\n if (result.label) {\n ;(result.label as any).formatMethod = (_: unknown, datum: Datum) => {\n // TreeMap returns a nested structure where `datum` is an array of children.\n // We need to find the specific data item that matches the current node's name.\n // The current node's name is usually available in the top-level datum object (which is `datum` here).\n // However, VChart's TreeMap datum structure is a bit complex.\n // Based on the user provided example:\n // datum: { name: \"Stapler\", datum: [...], ... }\n const nodeName = datum.value\n const dataArray = datum.datum as any[]\n\n if (!dataArray || !Array.isArray(dataArray)) {\n return ''\n }\n\n // Helper to find the matching data node recursively\n const findDataNode = (nodes: any[], value: string): any => {\n for (const node of nodes) {\n if (node.value === value) {\n return node\n }\n if (node.children) {\n const found = findDataNode(node.children, value)\n if (found) return found\n }\n }\n return null\n }\n\n // The structure seems to be that `datum` (the array) contains the root(s) of the hierarchy relevant to this node?\n // Or simply the data array we passed in.\n // Let's try to find the node with the matching name.\n const realDatum = findDataNode(dataArray, nodeName as string)\n\n if (!realDatum) {\n return ''\n }\n\n const resultText: string[] = []\n\n // 1. Dimension Labels\n const dimLabels = labelDims\n .map((item: Dimension) => {\n const id = item.id\n const rawValue = (realDatum[id] ?? realDatum.__OriginalData__?.[id]) as number | string\n const formatter = createFormatterByDimension(item, advancedVSeed.locale)\n return formatter(rawValue)\n })\n .filter((v) => v !== undefined && v !== null && v !== '')\n\n resultText.push(...(dimLabels as string[]))\n\n // 2. Measure Labels (from label encoding)\n const meaLabels = labelMeas.map((item: Measure) =>\n generateMeasureValue(\n (realDatum[item.id] ?? realDatum.__OriginalData__?.[item.id]) as number | string,\n item,\n autoFormat,\n numFormat,\n ),\n )\n resultText.push(...meaLabels)\n\n // 3. Value and Percent (default/implicit)\n foldInfoList.forEach((foldInfo) => {\n const { measureId, measureValue, statistics } = foldInfo\n // The measure ID might be in __MeaId__ or we look it up from the datum\n const currentMeasureId = (realDatum[measureId] ?? realDatum.__MeaId__) as string\n const measure = findMeasureById(advancedVSeed.measures!, currentMeasureId)\n\n if (measure) {\n const val = (realDatum[measureValue] ?? realDatum.__MeaValue__ ?? realDatum.value) as number | string\n\n const measureValueLabel = generateMeasureValue(val, measure, autoFormat, numFormat)\n\n if (showValue) {\n resultText.push(measureValueLabel)\n }\n if (showValuePercent) {\n // For TreeMap, percentage usually implies % of parent or total.\n // If we have statistics.sum (total), we can calculate it.\n if (statistics && isNumber(statistics.sum)) {\n resultText.push(generateMeasurePercent(val, statistics.sum, percentFormatter))\n }\n }\n }\n })\n\n if (wrap) {\n return resultText\n }\n return resultText.join(' ')\n }\n }\n\n return result\n}\n"],"names":["labelTreeMapLeaf","spec","context","result","commonLabel","advancedVSeed","vseed","datasetReshapeInfo","chartType","encoding","baseConfig","foldInfoList","label","showValue","showValuePercent","showDimension","autoFormat","numFormat","wrap","hasDimLabelEncoding","item","labelDims","uniqueBy","d","MeasureId","labelMeas","percentFormat","merge","percentFormatter","createFormatter","_","datum","nodeName","dataArray","Array","findDataNode","nodes","value","node","found","realDatum","resultText","dimLabels","id","rawValue","formatter","createFormatterByDimension","v","meaLabels","generateMeasureValue","foldInfo","measureId","measureValue","statistics","currentMeasureId","measure","findM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,UAAUC,gBAAgBnD,cAAc,QAAQ,EAAGiD;YAEzD,IAAIC,SAAS;gBACX,MAAME,MAAOjB,SAAS,CAACY,aAAa,IAAIZ,UAAU,YAAY,IAAIA,UAAU,KAAK;gBAEjF,MAAMkB,oBAAoBT,qBAAqBQ,KAAKF,SAASvC,YAAYC;gBAEzE,IAAIJ,WACF4B,WAAW,IAAI,CAACiB;gBAElB,IAAI5C,kBAGF;oBAAA,IAAIuC,cAAcM,SAASN,WAAW,GAAG,GACvCZ,WAAW,IAAI,CAACmB,uBAAuBH,KAAKJ,WAAW,GAAG,EAAEzB;gBAC9D;YAEJ;QACF;QAEA,IAAIV,MACF,OAAOuB;QAET,OAAOA,WAAW,IAAI,CAAC;IACzB;IAGF,OAAOtC;AACT"}
@@ -5,7 +5,7 @@ const pivotColorLegend = (spec, context)=>{
5
5
  const { advancedVSeed } = context;
6
6
  const { chartType } = advancedVSeed;
7
7
  const baseConfig = advancedVSeed.config[chartType];
8
- if (!baseConfig || !baseConfig.legend) return result;
8
+ if (!baseConfig || !baseConfig.legend || !baseConfig.color) return result;
9
9
  const { datasetReshapeInfo } = advancedVSeed;
10
10
  const max = Math.max(...datasetReshapeInfo.map((d)=>d.foldInfo.statistics.colorMax));
11
11
  const min = Math.min(...datasetReshapeInfo.map((d)=>d.foldInfo.statistics.colorMin));
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/spec/chart/pipes/legend/pivotColorLegend.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/legend/pivotColorLegend.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport type { Color, Legend, PivotChartSpecPipe } from 'src/types'\n\nexport const pivotColorLegend: PivotChartSpecPipe = (spec, context) => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { chartType } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { legend: Legend; color: Color }\n\n if (!baseConfig || !baseConfig.legend) {\n return result\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n const max = Math.max(...datasetReshapeInfo.map((d) => d.foldInfo.statistics.colorMax))\n const min = Math.min(...datasetReshapeInfo.map((d) => d.foldInfo.statistics.colorMin))\n const { legend, color } = baseConfig\n const { colorScheme, linearColorScheme } = color\n\n const {\n enable,\n position = 'bottom',\n labelFontColor,\n labelColor,\n labelFontSize = 12,\n labelFontWeight = 400,\n } = legend || {}\n\n const orient = ['bottom', 'bottomLeft', 'bottomRight', 'bl', 'br'].includes(position)\n ? 'bottom'\n : ['top', 'topLeft', 'topRight', 'tl', 'tr'].includes(position)\n ? 'top'\n : ['left', 'leftTop', 'leftBottom', 'lt', 'lb'].includes(position)\n ? 'left'\n : 'right'\n\n const legendPosition = ['topLeft', 'bottomLeft', 'leftTop', 'rightTop', 'lt', 'rt', 'tl', 'bl'].includes(position)\n ? 'start'\n : ['topRight', 'bottomRight', 'leftBottom', 'rightBottom', 'lb', 'rb', 'rt', 'br'].includes(position)\n ? 'end'\n : 'middle'\n\n const legends = {\n visible: enable,\n type: 'color',\n orient,\n position: legendPosition,\n\n colors: linearColorScheme || colorScheme || [],\n value: [min, max],\n min: min,\n max: max,\n\n maxWidth: '30%',\n handlerText: {\n visible: true,\n style: {\n fill: labelColor || labelFontColor,\n fontSize: labelFontSize,\n fontWeight: labelFontWeight,\n },\n },\n } as unknown\n return { ...result, legends } as Partial<PivotChartConstructorOptions>\n}\n"],"names":["pivotColorLegend","spec","context","result","advancedVSeed","chartType","baseConfig","datasetReshapeInfo","max","Math","d","min","legend","color","colorScheme","linearColorScheme","enable","position","labelFontColor","labelColor","labelFontSize","labelFontWeight","orient","legendPosition","legends"],"mappings":"AAGO,MAAMA,mBAAuC,CAACC,MAAMC;IACzD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,SAAS,EAAE,GAAGD;IACtB,MAAME,aAAaF,cAAc,MAAM,CAACC,UAAU;IAElD,IA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AO;QAAE,GAAGlB,MAAM;QAAEqB;IAAQ;AAC9B"}
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/legend/pivotColorLegend.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/legend/pivotColorLegend.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport type { Color, Legend, PivotChartSpecPipe } from 'src/types'\n\nexport const pivotColorLegend: PivotChartSpecPipe = (spec, context) => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { chartType } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { legend?: Legend; color?: Color }\n\n if (!baseConfig || !baseConfig.legend || !baseConfig.color) {\n return result\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n const max = Math.max(...datasetReshapeInfo.map((d) => d.foldInfo.statistics.colorMax))\n const min = Math.min(...datasetReshapeInfo.map((d) => d.foldInfo.statistics.colorMin))\n const { legend, color } = baseConfig\n const { colorScheme, linearColorScheme } = color\n\n const {\n enable,\n position = 'bottom',\n labelFontColor,\n labelColor,\n labelFontSize = 12,\n labelFontWeight = 400,\n } = legend || {}\n\n const orient = ['bottom', 'bottomLeft', 'bottomRight', 'bl', 'br'].includes(position)\n ? 'bottom'\n : ['top', 'topLeft', 'topRight', 'tl', 'tr'].includes(position)\n ? 'top'\n : ['left', 'leftTop', 'leftBottom', 'lt', 'lb'].includes(position)\n ? 'left'\n : 'right'\n\n const legendPosition = ['topLeft', 'bottomLeft', 'leftTop', 'rightTop', 'lt', 'rt', 'tl', 'bl'].includes(position)\n ? 'start'\n : ['topRight', 'bottomRight', 'leftBottom', 'rightBottom', 'lb', 'rb', 'rt', 'br'].includes(position)\n ? 'end'\n : 'middle'\n\n const legends = {\n visible: enable,\n type: 'color',\n orient,\n position: legendPosition,\n\n colors: linearColorScheme || colorScheme || [],\n value: [min, max],\n min: min,\n max: max,\n\n maxWidth: '30%',\n handlerText: {\n visible: true,\n style: {\n fill: labelColor || labelFontColor,\n fontSize: labelFontSize,\n fontWeight: labelFontWeight,\n },\n },\n } as unknown\n return { ...result, legends } as Partial<PivotChartConstructorOptions>\n}\n"],"names":["pivotColorLegend","spec","context","result","advancedVSeed","chartType","baseConfig","datasetReshapeInfo","max","Math","d","min","legend","color","colorScheme","linearColorScheme","enable","position","labelFontColor","labelColor","labelFontSize","labelFontWeight","orient","legendPosition","legends"],"mappings":"AAGO,MAAMA,mBAAuC,CAACC,MAAMC;IACzD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,SAAS,EAAE,GAAGD;IACtB,MAAME,aAAaF,cAAc,MAAM,CAACC,UAAU;IAElD,IAAI,CAACC,cAAc,CAACA,WAAW,MAAM,IAAI,CAACA,WAAW,KAAK,EACxD,OAAOH;IAGT,MAAM,EAAEI,kBAAkB,EAAE,GAAGH;IAC/B,MAAMI,MAAMC,KAAK,GAAG,IAAIF,mBAAmB,GAAG,CAAC,CAACG,IAAMA,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ;IACpF,MAAMC,MAAMF,KAAK,GAAG,IAAIF,mBAAmB,GAAG,CAAC,CAACG,IAAMA,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ;IACpF,MAAM,EAAEE,MAAM,EAAEC,KAAK,EAAE,GAAGP;IAC1B,MAAM,EAAEQ,WAAW,EAAEC,iBAAiB,EAAE,GAAGF;IAE3C,MAAM,EACJG,MAAM,EACNC,WAAW,QAAQ,EACnBC,cAAc,EACdC,UAAU,EACVC,gBAAgB,EAAE,EAClBC,kBAAkB,GAAG,EACtB,GAAGT,UAAU,CAAC;IAEf,MAAMU,SAAS;QAAC;QAAU;QAAc;QAAe;QAAM;KAAK,CAAC,QAAQ,CAACL,YACxE,WACA;QAAC;QAAO;QAAW;QAAY;QAAM;KAAK,CAAC,QAAQ,CAACA,YAClD,QACA;QAAC;QAAQ;QAAW;QAAc;QAAM;KAAK,CAAC,QAAQ,CAACA,YACrD,SACA;IAER,MAAMM,iBAAiB;QAAC;QAAW;QAAc;QAAW;QAAY;QAAM;QAAM;QAAM;KAAK,CAAC,QAAQ,CAACN,YACrG,UACA;QAAC;QAAY;QAAe;QAAc;QAAe;QAAM;QAAM;QAAM;KAAK,CAAC,QAAQ,CAACA,YACxF,QACA;IAEN,MAAMO,UAAU;QACd,SAASR;QACT,MAAM;QACNM;QACA,UAAUC;QAEV,QAAQR,qBAAqBD,eAAe,EAAE;QAC9C,OAAO;YAACH;YAAKH;SAAI;QACjB,KAAKG;QACL,KAAKH;QAEL,UAAU;QACV,aAAa;YACX,SAAS;YACT,OAAO;gBACL,MAAMW,cAAcD;gBACpB,UAAUE;gBACV,YAAYC;YACd;QACF;IACF;IACA,OAAO;QAAE,GAAGlB,MAAM;QAAEqB;IAAQ;AAC9B"}
@@ -7,7 +7,7 @@ const pivotDiscreteLegend = (spec, context)=>{
7
7
  const { advancedVSeed } = context;
8
8
  const { chartType } = advancedVSeed;
9
9
  const baseConfig = advancedVSeed.config[chartType];
10
- if (!baseConfig || !baseConfig.legend) return result;
10
+ if (!baseConfig || !baseConfig.legend || !baseConfig.color) return result;
11
11
  const { datasetReshapeInfo } = advancedVSeed;
12
12
  const colorItems = unique(datasetReshapeInfo.flatMap((d)=>d.unfoldInfo.colorItems));
13
13
  const colorIdMap = datasetReshapeInfo.reduce((prev, cur)=>({
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { unique } from 'remeda'\nimport type { Color, Legend, PivotChartSpecPipe } from 'src/types'\nimport { createSpecifiedForColorMapping } from '../color/color'\n\nexport const pivotDiscreteLegend: PivotChartSpecPipe = (spec, context): Partial<PivotChartConstructorOptions> => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { chartType } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { legend: Legend; color: Color }\n\n if (!baseConfig || !baseConfig.legend) {\n return result\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n\n const colorItems = unique(\n datasetReshapeInfo.flatMap((d) => {\n return d.unfoldInfo.colorItems\n }),\n )\n\n const colorIdMap = datasetReshapeInfo.reduce<Record<string, { id: string; alias: string }>>((prev, cur) => {\n return { ...prev, ...cur.unfoldInfo.colorIdMap }\n }, {})\n\n const { legend, color } = baseConfig\n const { colorScheme, colorMapping } = color\n\n const colorSpecified = createSpecifiedForColorMapping(colorMapping, colorIdMap, colorItems)\n\n const {\n enable,\n position = 'bottom',\n labelFontColor,\n labelColor,\n labelFontSize = 12,\n labelFontWeight = 400,\n maxSize = 1,\n border,\n shapeType = 'rectRound',\n } = legend || {}\n\n const orient = ['bottom', 'bottomLeft', 'bottomRight', 'bl', 'br'].includes(position)\n ? 'bottom'\n : ['top', 'topLeft', 'topRight', 'tl', 'tr'].includes(position)\n ? 'top'\n : ['left', 'leftTop', 'leftBottom', 'lt', 'lb'].includes(position)\n ? 'left'\n : 'right'\n\n const legendPosition = ['topLeft', 'bottomLeft', 'leftTop', 'rightTop', 'lt', 'rt', 'tl', 'bl'].includes(position)\n ? 'start'\n : ['topRight', 'bottomRight', 'leftBottom', 'rightBottom', 'lb', 'rb', 'rt', 'br'].includes(position)\n ? 'end'\n : 'middle'\n\n const legends = {\n padding: 0,\n visible: enable,\n type: 'discrete',\n orient,\n position: legendPosition,\n maxCol: Math.max(1, maxSize),\n maxRow: Math.max(1, maxSize),\n data: colorItems.map((d: string, index: number) => {\n const color = colorSpecified?.[d] ?? colorScheme?.[index % colorScheme.length]\n return {\n label: d,\n shape: {\n outerBorder: border\n ? {\n stroke: color,\n distance: 3,\n lineWidth: 1,\n }\n : undefined,\n fill: color,\n },\n }\n }),\n\n item: {\n focus: true,\n maxWidth: '30%',\n focusIconStyle: {\n size: labelFontSize + 2,\n fill: labelColor || labelFontColor,\n fontWeight: labelFontWeight,\n },\n shape: {\n space: border ? 6 : 4,\n style: {\n symbolType: shapeType,\n size: border ? 8 : 10,\n },\n },\n label: {\n formatMethod: (value: string) => {\n return colorIdMap[value]?.alias ?? value\n },\n style: {\n fontSize: labelFontSize,\n fill: labelColor || labelFontColor,\n fontWeight: labelFontWeight,\n },\n },\n background: {\n state: {\n selectedHover: {\n fill: labelColor || labelFontColor,\n fillOpacity: 0.05,\n },\n },\n },\n },\n }\n return { ...result, legends } as Partial<PivotChartConstructorOptions>\n}\n"],"names":["pivotDiscreteLegend","spec","context","result","advancedVSeed","chartType","baseConfig","datasetReshapeInfo","colorItems","unique","d","colorIdMap","prev","cur","legend","color","colorScheme","colorMapping","colorSpecified","createSpecifiedForColorMapping","enable","position","labelFontColor","labelColor","labelFontSize","labelFontWeight","maxSize","border","shapeType","orient","legendPosition","legends","Math","index","undefined","value"],"mappings":";;AAKO,MAAMA,sBAA0C,CAACC,MAAMC;IAC5D,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,SAAS,EAAE,GAAGD;IACtB,MAAME,aAAaF,cAAc,MAAM,CAACC,UAAU;IAElD,IAAI,CAACC,cAAc,CAACA,WAAW,MAAM,EACnC,OAAOH;IAGT,MAAM,EAAEI,kBAAkB,EAAE,GAAGH;IAE/B,MAAMI,aAAaC,OACjBF,mBAAmB,OAAO,CAAC,CAACG,IACnBA,EAAE,UAAU,CAAC,UAAU;IAIlC,MAAMC,aAAaJ,mBAAmB,MAAM,CAAgD,CAACK,MAAMC,MAC1F;YAAE,GAAGD,IAAI;YAAE,GAAGC,IAAI,UAAU,CAAC,UAAU;QAAC,IAC9C,CAAC;IAEJ,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGT;IAC1B,MAAM,EAAEU,WAAW,EAAEC,YAAY,EAAE,GAAGF;IAEtC,MAAMG,iBAAi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SAAS,IAAI;gBACrB;YACF;YACA,OAAO;gBACL,cAAc,CAACQ,QACNxB,UAAU,CAACwB,MAAM,EAAE,SAASA;gBAErC,OAAO;oBACL,UAAUX;oBACV,MAAMD,cAAcD;oBACpB,YAAYG;gBACd;YACF;YACA,YAAY;gBACV,OAAO;oBACL,eAAe;wBACb,MAAMF,cAAcD;wBACpB,aAAa;oBACf;gBACF;YACF;QACF;IACF;IACA,OAAO;QAAE,GAAGnB,MAAM;QAAE4B;IAAQ;AAC9B"}
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/legend/pivotDiscreteLegend.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { unique } from 'remeda'\nimport type { Color, Legend, PivotChartSpecPipe } from 'src/types'\nimport { createSpecifiedForColorMapping } from '../color/color'\n\nexport const pivotDiscreteLegend: PivotChartSpecPipe = (spec, context): Partial<PivotChartConstructorOptions> => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { chartType } = advancedVSeed\n const baseConfig = advancedVSeed.config[chartType] as { legend?: Legend; color?: Color }\n\n if (!baseConfig || !baseConfig.legend || !baseConfig.color) {\n return result\n }\n\n const { datasetReshapeInfo } = advancedVSeed\n\n const colorItems = unique(\n datasetReshapeInfo.flatMap((d) => {\n return d.unfoldInfo.colorItems\n }),\n )\n\n const colorIdMap = datasetReshapeInfo.reduce<Record<string, { id: string; alias: string }>>((prev, cur) => {\n return { ...prev, ...cur.unfoldInfo.colorIdMap }\n }, {})\n\n const { legend, color } = baseConfig\n const { colorScheme, colorMapping } = color\n\n const colorSpecified = createSpecifiedForColorMapping(colorMapping, colorIdMap, colorItems)\n\n const {\n enable,\n position = 'bottom',\n labelFontColor,\n labelColor,\n labelFontSize = 12,\n labelFontWeight = 400,\n maxSize = 1,\n border,\n shapeType = 'rectRound',\n } = legend || {}\n\n const orient = ['bottom', 'bottomLeft', 'bottomRight', 'bl', 'br'].includes(position)\n ? 'bottom'\n : ['top', 'topLeft', 'topRight', 'tl', 'tr'].includes(position)\n ? 'top'\n : ['left', 'leftTop', 'leftBottom', 'lt', 'lb'].includes(position)\n ? 'left'\n : 'right'\n\n const legendPosition = ['topLeft', 'bottomLeft', 'leftTop', 'rightTop', 'lt', 'rt', 'tl', 'bl'].includes(position)\n ? 'start'\n : ['topRight', 'bottomRight', 'leftBottom', 'rightBottom', 'lb', 'rb', 'rt', 'br'].includes(position)\n ? 'end'\n : 'middle'\n\n const legends = {\n padding: 0,\n visible: enable,\n type: 'discrete',\n orient,\n position: legendPosition,\n maxCol: Math.max(1, maxSize),\n maxRow: Math.max(1, maxSize),\n data: colorItems.map((d: string, index: number) => {\n const color = colorSpecified?.[d] ?? colorScheme?.[index % colorScheme.length]\n return {\n label: d,\n shape: {\n outerBorder: border\n ? {\n stroke: color,\n distance: 3,\n lineWidth: 1,\n }\n : undefined,\n fill: color,\n },\n }\n }),\n\n item: {\n focus: true,\n maxWidth: '30%',\n focusIconStyle: {\n size: labelFontSize + 2,\n fill: labelColor || labelFontColor,\n fontWeight: labelFontWeight,\n },\n shape: {\n space: border ? 6 : 4,\n style: {\n symbolType: shapeType,\n size: border ? 8 : 10,\n },\n },\n label: {\n formatMethod: (value: string) => {\n return colorIdMap[value]?.alias ?? value\n },\n style: {\n fontSize: labelFontSize,\n fill: labelColor || labelFontColor,\n fontWeight: labelFontWeight,\n },\n },\n background: {\n state: {\n selectedHover: {\n fill: labelColor || labelFontColor,\n fillOpacity: 0.05,\n },\n },\n },\n },\n }\n return { ...result, legends } as Partial<PivotChartConstructorOptions>\n}\n"],"names":["pivotDiscreteLegend","spec","context","result","advancedVSeed","chartType","baseConfig","datasetReshapeInfo","colorItems","unique","d","colorIdMap","prev","cur","legend","color","colorScheme","colorMapping","colorSpecified","createSpecifiedForColorMapping","enable","position","labelFontColor","labelColor","labelFontSize","labelFontWeight","maxSize","border","shapeType","orient","legendPosition","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rG,UACA;QAAC;QAAY;QAAe;QAAc;QAAe;QAAM;QAAM;QAAM;KAAK,CAAC,QAAQ,CAACA,YACxF,QACA;IAEN,MAAMU,UAAU;QACd,SAAS;QACT,SAASX;QACT,MAAM;QACNS;QACA,UAAUC;QACV,QAAQE,KAAK,GAAG,CAAC,GAAGN;QACpB,QAAQM,KAAK,GAAG,CAAC,GAAGN;QACpB,MAAMlB,WAAW,GAAG,CAAC,CAACE,GAAWuB;YAC/B,MAAMlB,QAAQG,gBAAgB,CAACR,EAAE,IAAIM,aAAa,CAACiB,QAAQjB,YAAY,MAAM,CAAC;YAC9E,OAAO;gBACL,OAAON;gBACP,OAAO;oBACL,aAAaiB,SACT;wBACE,QAAQZ;wBACR,UAAU;wBACV,WAAW;oBACb,IACAmB;oBACJ,MAAMnB;gBACR;YACF;QACF;QAEA,MAAM;YACJ,OAAO;YACP,UAAU;YACV,gBAAgB;gBACd,MAAMS,gBAAgB;gBACtB,MAAMD,cAAcD;gBACpB,YAAYG;YACd;YACA,OAAO;gBACL,OAAOE,SAAS,IAAI;gBACpB,OAAO;oBACL,YAAYC;oBACZ,MAAMD,SAAS,IAAI;gBACrB;YACF;YACA,OAAO;gBACL,cAAc,CAACQ,QACNxB,UAAU,CAACwB,MAAM,EAAE,SAASA;gBAErC,OAAO;oBACL,UAAUX;oBACV,MAAMD,cAAcD;oBACpB,YAAYG;gBACd;YACF;YACA,YAAY;gBACV,OAAO;oBACL,eAAe;wBACb,MAAMF,cAAcD;wBACpB,aAAa;oBACf;gBACF;YACF;QACF;IACF;IACA,OAAO;QAAE,GAAGnB,MAAM;QAAE4B;IAAQ;AAC9B"}
@@ -10,3 +10,4 @@ export { roseStyle } from './roseStyle';
10
10
  export { funnelTransformStyle } from './funnelTransformStyle';
11
11
  export { boxPlotStyle } from './boxPlotStyle';
12
12
  export { outlierStyle } from './outlierStyle';
13
+ export { sankeyInteractive } from './sankeyInteractive';
@@ -10,3 +10,4 @@ export { roseStyle } from "./roseStyle.js";
10
10
  export { funnelTransformStyle } from "./funnelTransformStyle.js";
11
11
  export { boxPlotStyle } from "./boxPlotStyle.js";
12
12
  export { outlierStyle } from "./outlierStyle.js";
13
+ export { sankeyInteractive } from "./sankeyInteractive.js";
@@ -0,0 +1,2 @@
1
+ import type { VChartSpecPipe } from '../../../../../types';
2
+ export declare const sankeyInteractive: VChartSpecPipe;
@@ -0,0 +1,33 @@
1
+ import { isSankey } from "../../../../utils/index.js";
2
+ const sankeyInteractive = (spec, context)=>{
3
+ const result = {
4
+ ...spec
5
+ };
6
+ const { vseed } = context;
7
+ result.emphasis = {
8
+ enable: true,
9
+ effect: isSankey(vseed) ? 'adjacency' : 'related'
10
+ };
11
+ result.node = {
12
+ ...result.node || {},
13
+ state: {
14
+ ...result.node?.state || {},
15
+ blur: {
16
+ opacity: 0.2
17
+ }
18
+ }
19
+ };
20
+ result.link = {
21
+ ...result.link || {},
22
+ state: {
23
+ ...result.link?.state || {},
24
+ blur: {
25
+ opacity: 0.05
26
+ }
27
+ }
28
+ };
29
+ return result;
30
+ };
31
+ export { sankeyInteractive };
32
+
33
+ //# sourceMappingURL=sankeyInteractive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/markStyle/sankeyInteractive.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/markStyle/sankeyInteractive.ts"],"sourcesContent":["import { isSankey } from 'src/pipeline/utils'\nimport type { VChartSpecPipe } from 'src/types'\n\nexport const sankeyInteractive: VChartSpecPipe = (spec, context) => {\n const result = { ...spec } as Record<string, any>\n const { vseed } = context\n result.emphasis = {\n enable: true,\n effect: isSankey(vseed) ? 'adjacency' : 'related',\n }\n\n result.node = {\n ...(result.node || {}),\n state: {\n ...(result.node?.state || {}),\n blur: {\n opacity: 0.2,\n },\n },\n }\n\n result.link = {\n ...(result.link || {}),\n state: {\n ...(result.link?.state || {}),\n blur: {\n opacity: 0.05,\n },\n },\n }\n\n return result as any\n}\n"],"names":["sankeyInteractive","spec","context","result","vseed","isSankey"],"mappings":";AAGO,MAAMA,oBAAoC,CAACC,MAAMC;IACtD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,KAAK,EAAE,GAAGF;IAClBC,OAAO,QAAQ,GAAG;QAChB,QAAQ;QACR,QAAQE,SAASD,SAAS,cAAc;IAC1C;IAEAD,OAAO,IAAI,GAAG;QACZ,GAAIA,OAAO,IAAI,IAAI,CAAC,CAAC;QACrB,OAAO;YACL,GAAIA,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC;YAC5B,MAAM;gBACJ,SAAS;YACX;QACF;IACF;IAEAA,OAAO,IAAI,GAAG;QACZ,GAAIA,OAAO,IAAI,IAAI,CAAC,CAAC;QACrB,OAAO;YACL,GAAIA,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC;YAC5B,MAAM;gBACJ,SAAS;YACX;QACF;IACF;IAEA,OAAOA;AACT"}
@@ -5,3 +5,5 @@ export { tooltipHeatmap } from './tooltipHeatmap';
5
5
  export { tooltipBoxplot } from './tooltipBoxplot';
6
6
  export { tooltipHistogram } from './tooltipHistogram';
7
7
  export { tooltipHierarchy } from './tooltipHierarchy';
8
+ export { tooltipHierarchySankey } from './tooltipHierarchySankey';
9
+ export { tooltipSankey } from './tooltipSankey';
@@ -5,3 +5,5 @@ export { tooltipHeatmap } from "./tooltipHeatmap.js";
5
5
  export { tooltipBoxplot } from "./tooltipBoxplot.js";
6
6
  export { tooltipHistogram } from "./tooltipHistogram.js";
7
7
  export { tooltipHierarchy } from "./tooltipHierarchy.js";
8
+ export { tooltipHierarchySankey } from "./tooltipHierarchySankey.js";
9
+ export { tooltipSankey } from "./tooltipSankey.js";
@@ -0,0 +1,2 @@
1
+ import type { VChartSpecPipe } from '../../../../../types';
2
+ export declare const tooltipHierarchySankey: VChartSpecPipe;
@@ -0,0 +1,150 @@
1
+ import { pipe, uniqueBy } from "remeda";
2
+ import { createFormatterByDimension, createFormatterByMeasure, findMeasureById } from "../../../../utils/index.js";
3
+ import { tooltip as external_tooltip_js_tooltip } from "./tooltip.js";
4
+ import { getHierarchySankeyNodesFromSpec } from "../dataset/datasetHierarchySankey.js";
5
+ const tooltipHierarchySankey = (spec, context)=>{
6
+ const result = external_tooltip_js_tooltip()(spec, context);
7
+ const { advancedVSeed, vseed } = context;
8
+ const { datasetReshapeInfo, dimensions = [], encoding, dataset = [] } = advancedVSeed;
9
+ const { foldInfo, unfoldInfo } = datasetReshapeInfo[0];
10
+ const hierarchyDataset = getHierarchySankeyNodesFromSpec(result, dataset);
11
+ if (result.tooltip) result.tooltip.mark = {
12
+ title: {
13
+ visible: true,
14
+ value: (value)=>createTitle(value, dimensions, hierarchyDataset, advancedVSeed.locale)
15
+ },
16
+ content: createMarkContent(encoding.tooltip || [], dimensions, vseed.measures, hierarchyDataset, foldInfo, unfoldInfo, advancedVSeed.locale)
17
+ };
18
+ return result;
19
+ };
20
+ const flattenHierarchyNodes = (nodes = [], depth = 0)=>nodes.flatMap((node)=>[
21
+ {
22
+ datum: node,
23
+ depth
24
+ },
25
+ ...flattenHierarchyNodes(node.children || [], depth + 1)
26
+ ]);
27
+ const createNodeMetaMap = (dataset = [])=>flattenHierarchyNodes(dataset).reduce((prev, item)=>{
28
+ const key = String(item.datum.key ?? '');
29
+ if (key) prev[key] = item;
30
+ return prev;
31
+ }, {});
32
+ const isLinkDatum = (value)=>{
33
+ const datum = value;
34
+ return !!datum && void 0 !== datum.source && void 0 !== datum.target;
35
+ };
36
+ const getHierarchyPath = (value)=>{
37
+ const datum = value;
38
+ if (!datum) return [];
39
+ if (Array.isArray(datum.datum)) return datum.datum;
40
+ if (datum.datum && Array.isArray(datum.datum.datum)) return datum.datum.datum;
41
+ if (datum.datum && 'object' == typeof datum.datum) return [
42
+ datum.datum
43
+ ];
44
+ return [
45
+ datum
46
+ ];
47
+ };
48
+ const getHierarchyDatum = (value)=>{
49
+ const path = getHierarchyPath(value);
50
+ if (!path.length) return;
51
+ const datum = value;
52
+ if ('number' == typeof datum?.depth && path[datum.depth]) return path[datum.depth];
53
+ return path[path.length - 1];
54
+ };
55
+ const createTitle = (value, dimensions = [], dataset = [], locale)=>{
56
+ if (isLinkDatum(value)) {
57
+ const nodeMetaMap = createNodeMetaMap(dataset);
58
+ const datum = value;
59
+ const source = nodeMetaMap[String(datum.source ?? '')]?.datum;
60
+ const target = nodeMetaMap[String(datum.target ?? '')]?.datum;
61
+ return [
62
+ source?.name,
63
+ target?.name
64
+ ].filter(Boolean).join(' -> ');
65
+ }
66
+ const path = getHierarchyPath(value);
67
+ if (!path.length) return '';
68
+ return path.map((item, index)=>{
69
+ const dim = dimensions[index];
70
+ const formatter = createFormatterByDimension(dim, locale);
71
+ return formatter(String(item?.name ?? ''));
72
+ }).join(' / ');
73
+ };
74
+ const createMarkContent = (tooltip, dimensions = [], measures = [], dataset = [], foldInfo, _unfoldInfo, locale)=>{
75
+ const nodeMetaMap = createNodeMetaMap(dataset);
76
+ const dims = pipe(dimensions.filter((item)=>tooltip.includes(item.id)), uniqueBy((item)=>item.id), uniqueBy((item)=>item.alias));
77
+ const meas = pipe(measures.filter((item)=>tooltip.includes(item.id)), uniqueBy((item)=>item.id), uniqueBy((item)=>item.alias));
78
+ const dimContent = dims.map((item)=>({
79
+ visible: (value)=>{
80
+ if (isLinkDatum(value)) return false;
81
+ const datum = getHierarchyDatum(value);
82
+ return datum?.[item.id] !== void 0 && datum?.[item.id] !== null;
83
+ },
84
+ hasShape: true,
85
+ shapeType: 'rectRound',
86
+ key: item.alias || item.id,
87
+ value: (value)=>{
88
+ const datum = getHierarchyDatum(value);
89
+ const formatter = createFormatterByDimension(item, locale);
90
+ return datum ? formatter(datum[item.id]) : '';
91
+ }
92
+ }));
93
+ const measureContent = meas.map((item)=>({
94
+ visible: (value)=>!isLinkDatum(value),
95
+ hasShape: true,
96
+ shapeType: 'rectRound',
97
+ key: item.alias || item.id,
98
+ value: (value)=>{
99
+ const datum = getHierarchyDatum(value);
100
+ if (!datum) return '';
101
+ const measure = findMeasureById(measures, item.id);
102
+ const formatter = createFormatterByMeasure(measure);
103
+ const measureValue = datum[item.id] ?? datum[foldInfo.measureValue];
104
+ return formatter(measureValue);
105
+ }
106
+ }));
107
+ const linkDimensionContent = dims.map((item)=>({
108
+ visible: (value)=>{
109
+ if (!isLinkDatum(value)) return false;
110
+ const datum = value;
111
+ const sourceMeta = nodeMetaMap[String(datum.source ?? '')];
112
+ const targetMeta = nodeMetaMap[String(datum.target ?? '')];
113
+ return sourceMeta?.datum?.[item.id] !== void 0 || targetMeta?.datum?.[item.id] !== void 0;
114
+ },
115
+ hasShape: true,
116
+ shapeType: 'rectRound',
117
+ key: item.alias || item.id,
118
+ value: (value)=>{
119
+ const datum = value;
120
+ const sourceMeta = nodeMetaMap[String(datum.source ?? '')];
121
+ const targetMeta = nodeMetaMap[String(datum.target ?? '')];
122
+ const matchedNode = sourceMeta?.depth !== void 0 && dimensions[sourceMeta.depth]?.id === item.id ? sourceMeta.datum : targetMeta?.depth !== void 0 && dimensions[targetMeta.depth]?.id === item.id ? targetMeta.datum : sourceMeta?.datum?.[item.id] !== void 0 ? sourceMeta.datum : targetMeta?.datum;
123
+ const formatter = createFormatterByDimension(item, locale);
124
+ const rawValue = matchedNode?.[item.id] ?? matchedNode?.name;
125
+ return null != rawValue ? formatter(rawValue) : '';
126
+ }
127
+ }));
128
+ const linkMeasureContent = meas.map((item)=>({
129
+ visible: (value)=>isLinkDatum(value),
130
+ hasShape: true,
131
+ shapeType: 'rectRound',
132
+ key: item.alias || item.id,
133
+ value: (value)=>{
134
+ const datum = value;
135
+ const measure = findMeasureById(measures, item.id);
136
+ const formatter = createFormatterByMeasure(measure);
137
+ const measureValue = datum[item.id] ?? datum[foldInfo.measureValue] ?? datum.value;
138
+ return formatter(measureValue);
139
+ }
140
+ }));
141
+ return [
142
+ ...dimContent,
143
+ ...linkDimensionContent,
144
+ ...measureContent,
145
+ ...linkMeasureContent
146
+ ];
147
+ };
148
+ export { tooltipHierarchySankey };
149
+
150
+ //# sourceMappingURL=tooltipHierarchySankey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/tooltip/tooltipHierarchySankey.ts"],"sourcesContent":["import { pipe, uniqueBy } from 'remeda'\nimport { createFormatterByDimension, createFormatterByMeasure, findMeasureById } from 'src/pipeline/utils'\nimport type {\n Datum,\n FoldInfo,\n HierarchyDimension,\n HierarchyMeasure,\n Locale,\n UnfoldInfo,\n VChartSpecPipe,\n} from 'src/types'\nimport { tooltip as commonTooltip } from './tooltip'\nimport { getHierarchySankeyNodesFromSpec } from '../dataset/datasetHierarchySankey'\n\nexport const tooltipHierarchySankey: VChartSpecPipe = (spec, context) => {\n const result = commonTooltip()(spec, context)\n const { advancedVSeed, vseed } = context\n const { datasetReshapeInfo, dimensions = [], encoding, dataset = [] } = advancedVSeed\n const { foldInfo, unfoldInfo } = datasetReshapeInfo[0]\n const hierarchyDataset = getHierarchySankeyNodesFromSpec(result as Record<string, any>, dataset as Datum[])\n\n if (result.tooltip) {\n result.tooltip.mark = {\n title: {\n visible: true,\n value: (value: unknown) =>\n createTitle(value, dimensions as HierarchyDimension[], hierarchyDataset, advancedVSeed.locale),\n },\n content: createMarkContent(\n encoding.tooltip || [],\n dimensions as HierarchyDimension[],\n vseed.measures as HierarchyMeasure[],\n hierarchyDataset,\n foldInfo,\n unfoldInfo,\n advancedVSeed.locale,\n ),\n }\n }\n\n return result\n}\n\ntype NodeMeta = {\n datum: Datum\n depth: number\n}\n\nconst flattenHierarchyNodes = (nodes: Datum[] = [], depth = 0): NodeMeta[] => {\n return nodes.flatMap((node) => [\n { datum: node, depth },\n ...flattenHierarchyNodes((node.children as Datum[]) || [], depth + 1),\n ])\n}\n\nconst createNodeMetaMap = (dataset: Datum[] = []) => {\n return flattenHierarchyNodes(dataset).reduce(\n (prev, item) => {\n const key = String(item.datum.key ?? '')\n if (key) {\n prev[key] = item\n }\n return prev\n },\n {} as Record<string, NodeMeta>,\n )\n}\n\nconst isLinkDatum = (value: unknown): boolean => {\n const datum = value as Datum\n return !!datum && datum.source !== undefined && datum.target !== undefined\n}\n\nconst getHierarchyPath = (value: unknown): Datum[] => {\n const datum = value as Datum\n if (!datum) {\n return []\n }\n\n if (Array.isArray(datum.datum)) {\n return datum.datum as Datum[]\n }\n\n if (datum.datum && Array.isArray((datum.datum as Datum).datum)) {\n return (datum.datum as Datum).datum as Datum[]\n }\n\n if (datum.datum && typeof datum.datum === 'object') {\n return [datum.datum as Datum]\n }\n\n return [datum]\n}\n\nconst getHierarchyDatum = (value: unknown): Datum | undefined => {\n const path = getHierarchyPath(value)\n if (!path.length) {\n return undefined\n }\n\n const datum = value as Datum\n if (typeof datum?.depth === 'number' && path[datum.depth]) {\n return path[datum.depth] as Datum\n }\n\n return path[path.length - 1] as Datum\n}\n\nconst createTitle = (value: unknown, dimensions: HierarchyDimension[] = [], dataset: Datum[] = [], locale?: Locale) => {\n if (isLinkDatum(value)) {\n const nodeMetaMap = createNodeMetaMap(dataset)\n const datum = value as Datum\n const source = nodeMetaMap[String(datum.source ?? '')]?.datum\n const target = nodeMetaMap[String(datum.target ?? '')]?.datum\n\n return [source?.name, target?.name].filter(Boolean).join(' -> ')\n }\n\n const path = getHierarchyPath(value)\n if (!path.length) {\n return ''\n }\n\n return path\n .map((item, index) => {\n const dim = dimensions[index]\n const formatter = createFormatterByDimension(dim, locale)\n return formatter(String(item?.name ?? ''))\n })\n .join(' / ')\n}\n\nconst createMarkContent = (\n tooltip: string[],\n dimensions: HierarchyDimension[] = [],\n measures: HierarchyMeasure[] = [],\n dataset: Datum[] = [],\n foldInfo: FoldInfo,\n _unfoldInfo: UnfoldInfo,\n locale?: Locale,\n) => {\n const nodeMetaMap = createNodeMetaMap(dataset)\n const dims = pipe(\n dimensions.filter((item) => tooltip.includes(item.id)),\n uniqueBy((item: HierarchyDimension) => item.id),\n uniqueBy((item: HierarchyDimension) => item.alias),\n )\n const meas = pipe(\n measures.filter((item) => tooltip.includes(item.id)),\n uniqueBy((item: HierarchyMeasure) => item.id),\n uniqueBy((item: HierarchyMeasure) => item.alias),\n )\n\n const dimContent = dims.map((item: HierarchyDimension) => ({\n visible: (value: unknown) => {\n if (isLinkDatum(value)) {\n return false\n }\n const datum = getHierarchyDatum(value)\n return datum?.[item.id] !== undefined && datum?.[item.id] !== null\n },\n hasShape: true,\n shapeType: 'rectRound',\n key: item.alias || item.id,\n value: (value: unknown) => {\n const datum = getHierarchyDatum(value)\n const formatter = createFormatterByDimension(item, locale)\n return datum ? formatter(datum[item.id] as string | number) : ''\n },\n }))\n\n const measureContent = meas.map((item: HierarchyMeasure) => ({\n visible: (value: unknown) => !isLinkDatum(value),\n hasShape: true,\n shapeType: 'rectRound',\n key: item.alias || item.id,\n value: (value: unknown) => {\n const datum = getHierarchyDatum(value)\n if (!datum) {\n return ''\n }\n\n const measure = findMeasureById(measures, item.id)\n const formatter = createFormatterByMeasure(measure)\n const measureValue = (datum[item.id] ?? datum[foldInfo.measureValue]) as string | number\n return formatter(measureValue)\n },\n }))\n\n const linkDimensionContent = dims.map((item: HierarchyDimension) => ({\n visible: (value: unknown) => {\n if (!isLinkDatum(value)) {\n return false\n }\n\n const datum = value as Datum\n const sourceMeta = nodeMetaMap[String(datum.source ?? '')]\n const targetMeta = nodeMetaMap[String(datum.target ?? '')]\n return sourceMeta?.datum?.[item.id] !== undefined || targetMeta?.datum?.[item.id] !== undefined\n },\n hasShape: true,\n shapeType: 'rectRound',\n key: item.alias || item.id,\n value: (value: unknown) => {\n const datum = value as Datum\n const sourceMeta = nodeMetaMap[String(datum.source ?? '')]\n const targetMeta = nodeMetaMap[String(datum.target ?? '')]\n\n const matchedNode =\n sourceMeta?.depth !== undefined && dimensions[sourceMeta.depth]?.id === item.id\n ? sourceMeta.datum\n : targetMeta?.depth !== undefined && dimensions[targetMeta.depth]?.id === item.id\n ? targetMeta.datum\n : sourceMeta?.datum?.[item.id] !== undefined\n ? sourceMeta.datum\n : targetMeta?.datum\n\n const formatter = createFormatterByDimension(item, locale)\n const rawValue = matchedNode?.[item.id] ?? matchedNode?.name\n return rawValue !== undefined && rawValue !== null ? formatter(rawValue as string | number) : ''\n },\n }))\n\n const linkMeasureContent = meas.map((item: HierarchyMeasure) => ({\n visible: (value: unknown) => isLinkDatum(value),\n hasShape: true,\n shapeType: 'rectRound',\n key: item.alias || item.id,\n value: (value: unknown) => {\n const datum = value as Datum\n const measure = findMeasureById(measures, item.id)\n const formatter = createFormatterByMeasure(measure)\n const measureValue = (datum[item.id] ?? datum[foldInfo.measureValue] ?? datum.value) as string | number\n return formatter(measureValue)\n },\n }))\n\n return [...dimContent, ...linkDimensionContent, ...measureContent, ...linkMeasureContent]\n}\n"],"names":["tooltipHierarchySankey","spec","context","result","commonTooltip","advancedVSeed","vseed","datasetReshapeInfo","dimensions","encoding","dataset","foldInfo","unfoldInfo","hierarchyDataset","getHierarchySankeyNodesFromSpec","value","createTitle","createMarkContent","flattenHierarchyNodes","nodes","depth","node","createNodeMetaMap","prev","item","key","String","isLinkDatum","datum","undefined","getHierarchyPath","Array","getHierarchyDatum","path","locale","nodeMetaMap","source","target","Boolean","index","dim","formatter","createFormatterByDimension","tooltip","measures","_unfoldInfo","dims","pipe","uniqueBy","meas","dimContent","measureContent","measure","findMeasureById","createFormatterByMeasure","measureValue","linkDimensionContent","sourceMeta","targetMeta","matchedNode","rawValue","linkMeasureContent"],"mappings":";;;;AAcO,MAAMA,yBAAyC,CAACC,MAAMC;IAC3D,MAAMC,SAASC,8BAAgBH,MAAMC;IACrC,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGJ;IACjC,MAAM,EAAEK,kBAAkB,EAAEC,aAAa,EAAE,EAAEC,QAAQ,EAAEC,UAAU,EAAE,EAAE,GAAGL;IACxE,MAAM,EAAEM,QAAQ,EAAEC,UAAU,EAAE,GAAGL,kBAAkB,CAAC,EAAE;IACtD,MAAMM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K,EAAE;YAC1B,OAAO,CAACT;gBACN,MAAMa,QAAQb;gBACd,MAAMqC,UAAUC,gBAAgBT,UAAUpB,KAAK,EAAE;gBACjD,MAAMiB,YAAYa,yBAAyBF;gBAC3C,MAAMG,eAAgB3B,KAAK,CAACJ,KAAK,EAAE,CAAC,IAAII,KAAK,CAACjB,SAAS,YAAY,CAAC,IAAIiB,MAAM,KAAK;gBACnF,OAAOa,UAAUc;YACnB;QACF;IAEA,OAAO;WAAIL;WAAeM;WAAyBL;WAAmBU;KAAmB;AAC3F"}
@@ -0,0 +1,2 @@
1
+ import type { VChartSpecPipe } from '../../../../../types';
2
+ export declare const tooltipSankey: VChartSpecPipe;
@@ -0,0 +1,75 @@
1
+ import { createFormatterByMeasure, findMeasureById } from "../../../../utils/index.js";
2
+ import { tooltip } from "./tooltip.js";
3
+ const isLinkDatum = (value)=>{
4
+ const datum = value;
5
+ return !!datum && void 0 !== datum.source && void 0 !== datum.target;
6
+ };
7
+ const getNodes = (spec)=>((spec.data || [])[0]?.values || [])[0]?.nodes || [];
8
+ const getNodeNameByIndex = (nodes, index)=>{
9
+ const node = nodes[Number(index)];
10
+ return node?.nodeName ?? '';
11
+ };
12
+ const getWrappedDatum = (value)=>{
13
+ const datum = value;
14
+ const wrappedDatum = datum?.datum;
15
+ if (Array.isArray(wrappedDatum)) return wrappedDatum[wrappedDatum.length - 1] || datum;
16
+ if (wrappedDatum && 'object' == typeof wrappedDatum) return wrappedDatum;
17
+ return datum;
18
+ };
19
+ const getNodeTitle = (value)=>{
20
+ const datum = getWrappedDatum(value);
21
+ return String(datum?.nodeName ?? datum?.name ?? datum?.id ?? '');
22
+ };
23
+ const getEncodingAlias = (dimensions, encodedIds, fallback, measureId)=>dimensions.find((dimension)=>(encodedIds || []).includes(dimension.id) && dimension.id !== measureId)?.alias || fallback;
24
+ const tooltipSankey = (spec, context)=>{
25
+ const result = tooltip()(spec, context);
26
+ const { advancedVSeed, vseed } = context;
27
+ const { datasetReshapeInfo, dimensions = [] } = advancedVSeed;
28
+ const { foldInfo } = datasetReshapeInfo[0];
29
+ const nodes = getNodes(result);
30
+ const measures = vseed.measures || [];
31
+ const sourceAlias = getEncodingAlias(dimensions, advancedVSeed.encoding?.source, 'Source', foldInfo.measureId);
32
+ if (result.tooltip) result.tooltip.mark = {
33
+ title: {
34
+ visible: true,
35
+ value: (value)=>{
36
+ const datum = value;
37
+ if (isLinkDatum(value)) return `${getNodeNameByIndex(nodes, datum.source)} -> ${getNodeNameByIndex(nodes, datum.target)}`;
38
+ return getNodeTitle(value);
39
+ }
40
+ },
41
+ content: createMarkContent(nodes, measures, foldInfo, sourceAlias)
42
+ };
43
+ return result;
44
+ };
45
+ const createMarkContent = (nodes, measures = [], foldInfo, sourceAlias)=>{
46
+ const fallbackMeasure = findMeasureById(measures, foldInfo.measureValue) || measures[0];
47
+ const fallbackMeasureAlias = fallbackMeasure?.alias || fallbackMeasure?.id || 'Value';
48
+ return [
49
+ {
50
+ visible: (value)=>isLinkDatum(value),
51
+ hasShape: true,
52
+ shapeType: 'rectRound',
53
+ key: sourceAlias,
54
+ value: (value)=>{
55
+ const datum = value;
56
+ return String(datum.sourceNodeName ?? getNodeNameByIndex(nodes, datum.source));
57
+ }
58
+ },
59
+ {
60
+ visible: ()=>true,
61
+ hasShape: true,
62
+ shapeType: 'rectRound',
63
+ key: fallbackMeasureAlias,
64
+ value: (value)=>{
65
+ const datum = value;
66
+ const measure = findMeasureById(measures, datum?.[foldInfo.measureId]) || fallbackMeasure;
67
+ const formatter = createFormatterByMeasure(measure);
68
+ return formatter((datum?.[foldInfo.measureValue] ?? datum?.value ?? 0) || 0);
69
+ }
70
+ }
71
+ ];
72
+ };
73
+ export { tooltipSankey };
74
+
75
+ //# sourceMappingURL=tooltipSankey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/tooltip/tooltipSankey.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/tooltip/tooltipSankey.ts"],"sourcesContent":["import { createFormatterByMeasure, findMeasureById } from 'src/pipeline/utils'\nimport type { Datum, Dimension, FoldInfo, Measure, VChartSpecPipe } from 'src/types'\nimport { tooltip as commonTooltip } from './tooltip'\n\nconst isLinkDatum = (value: unknown) => {\n const datum = value as Datum\n return !!datum && datum.source !== undefined && datum.target !== undefined\n}\n\nconst getNodes = (spec: Record<string, any>) =>\n ((((spec.data || [])[0] as Record<string, any>)?.values || [])[0]?.nodes || []) as Array<Datum>\n\nconst getNodeNameByIndex = (nodes: Datum[], index: unknown) => {\n const node = nodes[Number(index)]\n return node?.nodeName ?? ''\n}\n\nconst getWrappedDatum = (value: unknown): Datum => {\n const datum = value as Datum\n const wrappedDatum = datum?.datum\n\n if (Array.isArray(wrappedDatum)) {\n return (wrappedDatum[wrappedDatum.length - 1] || datum) as Datum\n }\n\n if (wrappedDatum && typeof wrappedDatum === 'object') {\n return wrappedDatum as Datum\n }\n\n return datum\n}\n\nconst getNodeTitle = (value: unknown) => {\n const datum = getWrappedDatum(value)\n return String(datum?.nodeName ?? datum?.name ?? datum?.id ?? '')\n}\n\nconst getEncodingAlias = (\n dimensions: Dimension[],\n encodedIds: string[] | null | undefined,\n fallback: string,\n measureId: string,\n) =>\n dimensions.find((dimension) => (encodedIds || []).includes(dimension.id) && dimension.id !== measureId)?.alias ||\n fallback\n\nexport const tooltipSankey: VChartSpecPipe = (spec, context) => {\n const result = commonTooltip()(spec, context) as Record<string, any>\n const { advancedVSeed, vseed } = context\n const { datasetReshapeInfo, dimensions = [] } = advancedVSeed\n const { foldInfo } = datasetReshapeInfo[0]\n const nodes = getNodes(result)\n const measures = (vseed.measures || []) as Measure[]\n const sourceAlias = getEncodingAlias(dimensions, advancedVSeed.encoding?.source, 'Source', foldInfo.measureId)\n\n if (result.tooltip) {\n result.tooltip.mark = {\n title: {\n visible: true,\n value: (value: unknown) => {\n const datum = value as Datum\n if (isLinkDatum(value)) {\n return `${getNodeNameByIndex(nodes, datum.source)} -> ${getNodeNameByIndex(nodes, datum.target)}`\n }\n return getNodeTitle(value)\n },\n },\n content: createMarkContent(nodes, measures, foldInfo, sourceAlias),\n }\n }\n\n return result\n}\n\nconst createMarkContent = (nodes: Datum[], measures: Measure[] = [], foldInfo: FoldInfo, sourceAlias: string) => {\n const fallbackMeasure = findMeasureById(measures, foldInfo.measureValue) || measures[0]\n const fallbackMeasureAlias = fallbackMeasure?.alias || fallbackMeasure?.id || 'Value'\n\n return [\n {\n visible: (value: unknown) => isLinkDatum(value),\n hasShape: true,\n shapeType: 'rectRound',\n key: sourceAlias,\n value: (value: unknown) => {\n const datum = value as Datum\n return String(datum.sourceNodeName ?? getNodeNameByIndex(nodes, datum.source))\n },\n },\n {\n visible: () => true,\n hasShape: true,\n shapeType: 'rectRound',\n key: fallbackMeasureAlias,\n value: (value: unknown) => {\n const datum = value as Datum\n const measure = findMeasureById(measures, datum?.[foldInfo.measureId] as string) || fallbackMeasure\n const formatter = createFormatterByMeasure(measure)\n return formatter(((datum?.[foldInfo.measureValue] ?? datum?.value ?? 0) as string | number) || 0)\n },\n },\n ]\n}\n"],"names":["isLinkDatum","value","datum","undefined","getNodes","spec","getNodeNameByIndex","nodes","index","node","Number","getWrappedDatum","wrappedDatum","Array","getNodeTitle","String","getEncodingAlias","dimensions","encodedIds","fallback","measureId","dimension","tooltipSankey","context","result","commonTooltip","advancedVSeed","vseed","datasetReshapeInfo","foldInfo","measures","sourceAlias","createMarkContent","fallbackMeasure","findMeasureById","fallbackMeasureAlias","measure","formatter","createFormatterByMeasure"],"mappings":";;AAIA,MAAMA,cAAc,CAACC;IACnB,MAAMC,QAAQD;IACd,OAAO,CAAC,CAACC,SAASA,AAAiBC,WAAjBD,MAAM,MAAM,IAAkBA,AAAiBC,WAAjBD,MAAM,MAAM;AAC9D;AAEA,MAAME,WAAW,CAACC,OACd,AAAEA,CAAAA,CAAAA,KAAK,IAAI,IAAI,EAAC,CAAE,CAAC,EAAE,EAA0B,UAAU,EAAC,CAAE,CAAC,EAAE,EAAE,S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GAAGK,mBAAmBC,OAAOL,MAAM,MAAM,EAAE,IAAI,EAAEI,mBAAmBC,OAAOL,MAAM,MAAM,GAAG;gBAEnG,OAAOY,aAAab;YACtB;QACF;QACA,SAAS+B,kBAAkBzB,OAAOuB,UAAUD,UAAUE;IACxD;IAGF,OAAOP;AACT;AAEA,MAAMQ,oBAAoB,CAACzB,OAAgBuB,WAAsB,EAAE,EAAED,UAAoBE;IACvF,MAAME,kBAAkBC,gBAAgBJ,UAAUD,SAAS,YAAY,KAAKC,QAAQ,CAAC,EAAE;IACvF,MAAMK,uBAAuBF,iBAAiB,SAASA,iBAAiB,MAAM;IAE9E,OAAO;QACL;YACE,SAAS,CAAChC,QAAmBD,YAAYC;YACzC,UAAU;YACV,WAAW;YACX,KAAK8B;YACL,OAAO,CAAC9B;gBACN,MAAMC,QAAQD;gBACd,OAAOc,OAAOb,MAAM,cAAc,IAAII,mBAAmBC,OAAOL,MAAM,MAAM;YAC9E;QACF;QACA;YACE,SAAS,IAAM;YACf,UAAU;YACV,WAAW;YACX,KAAKiC;YACL,OAAO,CAAClC;gBACN,MAAMC,QAAQD;gBACd,MAAMmC,UAAUF,gBAAgBJ,UAAU5B,OAAO,CAAC2B,SAAS,SAAS,CAAC,KAAeI;gBACpF,MAAMI,YAAYC,yBAAyBF;gBAC3C,OAAOC,UAAYnC,AAAAA,CAAAA,OAAO,CAAC2B,SAAS,YAAY,CAAC,IAAI3B,OAAO,SAAS,MAA0B;YACjG;QACF;KACD;AACH"}
@@ -5,6 +5,8 @@ export declare const isRadar: (vseed: VSeed) => vseed is import("../../types").R
5
5
  export declare const isAreaPercent: (vseed: VSeed) => vseed is import("../../types").AreaPercent;
6
6
  export declare const isColumnPercent: (vseed: VSeed) => vseed is import("../../types").ColumnPercent;
7
7
  export declare const isBarPercent: (vseed: VSeed) => vseed is import("../../types").BarPercent;
8
+ export declare const isSankey: (vseed: VSeed) => vseed is import("../../types").Sankey;
9
+ export declare const isHierarchySankey: (vseed: VSeed) => vseed is import("../../types").HierarchySankey;
8
10
  export declare const isBarLikeChart: (vseed: VSeed) => vseed is import("../../types").Bar | import("../../types").RaceBar | import("../../types").BarParallel | import("../../types").BarPercent;
9
11
  export declare const isVTable: (vseed: VSeed) => boolean;
10
12
  export declare const isVChart: (vseed: VSeed) => boolean;
@@ -8,6 +8,8 @@ const isRadar = (vseed)=>vseed.chartType === ChartTypeEnum.Radar;
8
8
  const isAreaPercent = (vseed)=>vseed.chartType === ChartTypeEnum.AreaPercent;
9
9
  const isColumnPercent = (vseed)=>vseed.chartType === ChartTypeEnum.ColumnPercent;
10
10
  const isBarPercent = (vseed)=>vseed.chartType === ChartTypeEnum.BarPercent;
11
+ const isSankey = (vseed)=>vseed.chartType === ChartTypeEnum.Sankey;
12
+ const isHierarchySankey = (vseed)=>vseed.chartType === ChartTypeEnum.HierarchySankey;
11
13
  const isBarLikeChart = (vseed)=>vseed.chartType === ChartTypeEnum.Bar || vseed.chartType === ChartTypeEnum.RaceBar || vseed.chartType === ChartTypeEnum.BarPercent || vseed.chartType === ChartTypeEnum.BarParallel;
12
14
  const isVTable = (vseed)=>[
13
15
  'table',
@@ -85,6 +87,6 @@ const isDualAxisChartType = (chartType)=>chartType && [
85
87
  'areaPercent',
86
88
  'scatter'
87
89
  ].includes(chartType);
88
- export { DEFAULT_DUAL_CHART_TYPE, isAreaPercent, isBarLikeChart, isBarPercent, isColumnPercent, isCombination, isDualAxisChartType, isPivot, isPivotChart, isPivotTable, isRadar, isRectungularCoordinate, isTable, isVChart, isVTable };
90
+ export { DEFAULT_DUAL_CHART_TYPE, isAreaPercent, isBarLikeChart, isBarPercent, isColumnPercent, isCombination, isDualAxisChartType, isHierarchySankey, isPivot, isPivotChart, isPivotTable, isRadar, isRectungularCoordinate, isSankey, isTable, isVChart, isVTable };
89
91
 
90
92
  //# sourceMappingURL=chatType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/utils/chatType.js","sources":["../../../../src/pipeline/utils/chatType.ts"],"sourcesContent":["import type { MeasureEncoding, Measures } from 'src/types'\nimport { type Dimensions, type DimensionGroup, type VSeed, type Measure } from 'src/types'\nimport { isPositionMeasure } from './measures'\nimport { isCommonMeasureEncoding, isMeasureTreeWithParentId } from '../advanced/chart/pipes/measures/utils'\nimport { unique } from 'remeda'\nimport { ChartTypeEnum, DEFAULT_PARENT_ID } from './constant'\n\nexport const isTable = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Table\n}\nexport const isPivotTable = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.PivotTable\n}\nexport const isRadar = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Radar\n}\nexport const isAreaPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.AreaPercent\n}\nexport const isColumnPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.ColumnPercent\n}\nexport const isBarPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.BarPercent\n}\n\nexport const isBarLikeChart = (vseed: VSeed) => {\n return (\n vseed.chartType === ChartTypeEnum.Bar ||\n vseed.chartType === ChartTypeEnum.RaceBar ||\n vseed.chartType === ChartTypeEnum.BarPercent ||\n vseed.chartType === ChartTypeEnum.BarParallel\n )\n}\n\nexport const isVTable = (vseed: VSeed) => {\n return ['table', 'pivotTable'].includes(vseed.chartType)\n}\nexport const isVChart = (vseed: VSeed): boolean => {\n return !isVTable(vseed)\n}\n\n/**\n * @description 透视图表或组合图\n * - 透视图表定义: 存在 column 或 row的 encoding\n * - 组合图表定义: 存在多组指标的情况\n * - 透视组合图表: 存在 column 或 row的 encoding 且 存在多组指标的情况\n * 上述三者都只能使用 VTable.PivotChart 绘制\n */\nexport const isPivotChart = (vseed: VSeed) => {\n if (isVTable(vseed)) {\n return false\n }\n\n if (isPivot(vseed)) {\n return true\n }\n\n return isCombination(vseed)\n}\n\n/**\n * @description 存在column 或 row的encoding\n */\nexport const isPivot = (vseed: VSeed) => {\n const { dimensions = [], measures = [] } = vseed as {\n dimensions: Dimensions\n measures: Measures\n }\n\n if (dimensions && dimensions.some((dimension) => dimension.encoding === 'row' || dimension.encoding === 'column')) {\n return true\n }\n\n if (vseed.chartType === ChartTypeEnum.Scatter) {\n const xCount = measures.filter((m: Measure) => m.encoding === 'xAxis').length\n const yCount = measures.filter((m: Measure) => m.encoding === 'yAxis').length\n const otherCount = measures.filter(\n (m: Measure) =>\n !['size', 'xAxis', 'yAxis'].includes(m.encoding as string) &&\n !isCommonMeasureEncoding(m.encoding as MeasureEncoding),\n ).length\n\n /**\n * Scatter \"matrix\" detection logic\n *\n * xCount: number of measures explicitly encoded on the x-axis\n * yCount: number of measures explicitly encoded on the y-axis\n * otherCount: measures that are not size/xAxis/yAxis and are not common encodings\n *\n * When there is at least one explicit x-axis measure (xCount > 0):\n * - All x-encoded measures are counted as X.\n * - Remaining measures (y-encoded + \"other\") are treated as Y variants.\n *\n * When there is no explicit x-axis measure (xCount === 0):\n * - If there is at least one \"other\" measure, we treat exactly one of them as the X measure\n * (so finalXCount = 1), and the remaining \"other\" measures contribute to Y alongside\n * the explicit y-encoded measures.\n * - Since we conceptually \"promote\" one of the other measures to X, only (otherCount - 1)\n * are left to be counted towards Y. Math.max(..., 0) protects against negative values\n * when otherCount is 0.\n */\n let finalXCount: number\n let finalYCount: number\n\n if (xCount > 0) {\n // Explicit x-axis measures exist: X is fixed, Y aggregates y-encoded + other measures.\n finalXCount = xCount\n finalYCount = yCount + otherCount\n } else {\n // No explicit x-axis measure:\n // - If there are \"other\" measures, treat one as X.\n // - Remaining \"other\" measures contribute to Y, together with any y-encoded measures.\n finalXCount = otherCount > 0 ? 1 : 0\n finalYCount = yCount + Math.max(otherCount - 1, 0)\n }\n if (finalXCount > 1 || finalYCount > 1) return true\n }\n\n return false\n}\n\n/**\n * @description 不存在column 或 row的encoding, 但是有多组指标的情况\n */\nexport const isCombination = (vseed: VSeed) => {\n if (isMeasureTreeWithParentId(vseed.measures)) {\n const parentIds = vseed.measures\n ?.filter((m: Measure) => isPositionMeasure(m, vseed.chartType))\n .map((measure: Measure) => measure.parentId || DEFAULT_PARENT_ID)\n return parentIds && unique(parentIds).length > 1\n }\n\n const { measures = [] } = vseed as {\n measures: Measures\n dimensions: Dimensions\n }\n\n const hasMeasureGroup = measures && measures.some((measure: DimensionGroup) => measure && measure.children)\n\n return hasMeasureGroup\n}\n\nexport const isRectungularCoordinate = (chartType: string) => {\n return (\n [\n ChartTypeEnum.Bar,\n ChartTypeEnum.RaceBar,\n ChartTypeEnum.RaceColumn,\n ChartTypeEnum.RaceScatter,\n ChartTypeEnum.BarPercent,\n ChartTypeEnum.BarParallel,\n ChartTypeEnum.Column,\n ChartTypeEnum.ColumnPercent,\n ChartTypeEnum.ColumnParallel,\n ChartTypeEnum.Line,\n ChartTypeEnum.Area,\n ChartTypeEnum.AreaPercent,\n ChartTypeEnum.DualAxis,\n ChartTypeEnum.Boxplot,\n ChartTypeEnum.DualAxis,\n ChartTypeEnum.Scatter,\n ChartTypeEnum.Heatmap,\n ChartTypeEnum.Boxplot,\n ] as string[]\n ).includes(chartType)\n}\n\n/**\n * 默认的双轴图图表类型配置\n */\nexport const DEFAULT_DUAL_CHART_TYPE = {\n primary: 'column',\n secondary: 'line',\n}\n\nexport const isDualAxisChartType = (chartType: string | undefined) => {\n return (\n chartType &&\n ['column', 'columnParallel', 'columnPercent', 'line', 'area', 'areaPercent', 'scatter'].includes(chartType)\n )\n}\n"],"names":["isTable","vseed","ChartTypeEnum","isPivotTable","isRadar","isAreaPercent","isColumnPercent","isBarPercent","isBarLikeChart","isVTable","isVChart","isPivotChart","isPivot","isCombination","dimensions","measures","dimension","xCount","m","yCount","otherCount","isCommonMeasureEncoding","finalXCount","finalYCount","Math","isMeasureTreeWithParentId","parentIds","isPositionMeasure","measure","DEFAULT_PARENT_ID","unique","hasMeasureGroup","isRectungularCoordinate","chartType","DEFAULT_DUAL_CHART_TYPE","isDualAxisChartType"],"mappings":";;;;AAOO,MAAMA,UAAU,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AO;QACrBA,cAAc,OAAO;KACtB,CACD,QAAQ,CAAC+B;AAMN,MAAMC,0BAA0B;IACrC,SAAS;IACT,WAAW;AACb;AAEO,MAAMC,sBAAsB,CAACF,YAEhCA,aACA;QAAC;QAAU;QAAkB;QAAiB;QAAQ;QAAQ;QAAe;KAAU,CAAC,QAAQ,CAACA"}
1
+ {"version":3,"file":"pipeline/utils/chatType.js","sources":["../../../../src/pipeline/utils/chatType.ts"],"sourcesContent":["import type { MeasureEncoding, Measures } from 'src/types'\nimport { type Dimensions, type DimensionGroup, type VSeed, type Measure } from 'src/types'\nimport { isPositionMeasure } from './measures'\nimport { isCommonMeasureEncoding, isMeasureTreeWithParentId } from '../advanced/chart/pipes/measures/utils'\nimport { unique } from 'remeda'\nimport { ChartTypeEnum, DEFAULT_PARENT_ID } from './constant'\n\nexport const isTable = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Table\n}\nexport const isPivotTable = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.PivotTable\n}\nexport const isRadar = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Radar\n}\nexport const isAreaPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.AreaPercent\n}\nexport const isColumnPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.ColumnPercent\n}\nexport const isBarPercent = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.BarPercent\n}\nexport const isSankey = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.Sankey\n}\nexport const isHierarchySankey = (vseed: VSeed) => {\n return vseed.chartType === ChartTypeEnum.HierarchySankey\n}\n\nexport const isBarLikeChart = (vseed: VSeed) => {\n return (\n vseed.chartType === ChartTypeEnum.Bar ||\n vseed.chartType === ChartTypeEnum.RaceBar ||\n vseed.chartType === ChartTypeEnum.BarPercent ||\n vseed.chartType === ChartTypeEnum.BarParallel\n )\n}\n\nexport const isVTable = (vseed: VSeed) => {\n return ['table', 'pivotTable'].includes(vseed.chartType)\n}\nexport const isVChart = (vseed: VSeed): boolean => {\n return !isVTable(vseed)\n}\n\n/**\n * @description 透视图表或组合图\n * - 透视图表定义: 存在 column 或 row的 encoding\n * - 组合图表定义: 存在多组指标的情况\n * - 透视组合图表: 存在 column 或 row的 encoding 且 存在多组指标的情况\n * 上述三者都只能使用 VTable.PivotChart 绘制\n */\nexport const isPivotChart = (vseed: VSeed) => {\n if (isVTable(vseed)) {\n return false\n }\n\n if (isPivot(vseed)) {\n return true\n }\n\n return isCombination(vseed)\n}\n\n/**\n * @description 存在column 或 row的encoding\n */\nexport const isPivot = (vseed: VSeed) => {\n const { dimensions = [], measures = [] } = vseed as {\n dimensions: Dimensions\n measures: Measures\n }\n\n if (dimensions && dimensions.some((dimension) => dimension.encoding === 'row' || dimension.encoding === 'column')) {\n return true\n }\n\n if (vseed.chartType === ChartTypeEnum.Scatter) {\n const xCount = measures.filter((m: Measure) => m.encoding === 'xAxis').length\n const yCount = measures.filter((m: Measure) => m.encoding === 'yAxis').length\n const otherCount = measures.filter(\n (m: Measure) =>\n !['size', 'xAxis', 'yAxis'].includes(m.encoding as string) &&\n !isCommonMeasureEncoding(m.encoding as MeasureEncoding),\n ).length\n\n /**\n * Scatter \"matrix\" detection logic\n *\n * xCount: number of measures explicitly encoded on the x-axis\n * yCount: number of measures explicitly encoded on the y-axis\n * otherCount: measures that are not size/xAxis/yAxis and are not common encodings\n *\n * When there is at least one explicit x-axis measure (xCount > 0):\n * - All x-encoded measures are counted as X.\n * - Remaining measures (y-encoded + \"other\") are treated as Y variants.\n *\n * When there is no explicit x-axis measure (xCount === 0):\n * - If there is at least one \"other\" measure, we treat exactly one of them as the X measure\n * (so finalXCount = 1), and the remaining \"other\" measures contribute to Y alongside\n * the explicit y-encoded measures.\n * - Since we conceptually \"promote\" one of the other measures to X, only (otherCount - 1)\n * are left to be counted towards Y. Math.max(..., 0) protects against negative values\n * when otherCount is 0.\n */\n let finalXCount: number\n let finalYCount: number\n\n if (xCount > 0) {\n // Explicit x-axis measures exist: X is fixed, Y aggregates y-encoded + other measures.\n finalXCount = xCount\n finalYCount = yCount + otherCount\n } else {\n // No explicit x-axis measure:\n // - If there are \"other\" measures, treat one as X.\n // - Remaining \"other\" measures contribute to Y, together with any y-encoded measures.\n finalXCount = otherCount > 0 ? 1 : 0\n finalYCount = yCount + Math.max(otherCount - 1, 0)\n }\n if (finalXCount > 1 || finalYCount > 1) return true\n }\n\n return false\n}\n\n/**\n * @description 不存在column 或 row的encoding, 但是有多组指标的情况\n */\nexport const isCombination = (vseed: VSeed) => {\n if (isMeasureTreeWithParentId(vseed.measures)) {\n const parentIds = vseed.measures\n ?.filter((m: Measure) => isPositionMeasure(m, vseed.chartType))\n .map((measure: Measure) => measure.parentId || DEFAULT_PARENT_ID)\n return parentIds && unique(parentIds).length > 1\n }\n\n const { measures = [] } = vseed as {\n measures: Measures\n dimensions: Dimensions\n }\n\n const hasMeasureGroup = measures && measures.some((measure: DimensionGroup) => measure && measure.children)\n\n return hasMeasureGroup\n}\n\nexport const isRectungularCoordinate = (chartType: string) => {\n return (\n [\n ChartTypeEnum.Bar,\n ChartTypeEnum.RaceBar,\n ChartTypeEnum.RaceColumn,\n ChartTypeEnum.RaceScatter,\n ChartTypeEnum.BarPercent,\n ChartTypeEnum.BarParallel,\n ChartTypeEnum.Column,\n ChartTypeEnum.ColumnPercent,\n ChartTypeEnum.ColumnParallel,\n ChartTypeEnum.Line,\n ChartTypeEnum.Area,\n ChartTypeEnum.AreaPercent,\n ChartTypeEnum.DualAxis,\n ChartTypeEnum.Boxplot,\n ChartTypeEnum.DualAxis,\n ChartTypeEnum.Scatter,\n ChartTypeEnum.Heatmap,\n ChartTypeEnum.Boxplot,\n ] as string[]\n ).includes(chartType)\n}\n\n/**\n * 默认的双轴图图表类型配置\n */\nexport const DEFAULT_DUAL_CHART_TYPE = {\n primary: 'column',\n secondary: 'line',\n}\n\nexport const isDualAxisChartType = (chartType: string | undefined) => {\n return (\n chartType &&\n ['column', 'columnParallel', 'columnPercent', 'line', 'area', 'areaPercent', 'scatter'].includes(chartType)\n )\n}\n"],"names":["isTable","vseed","ChartTypeEnum","isPivotTable","isRadar","isAreaPercent","isColumnPercent","isBarPercent","isSankey","isHierarchySankey","isBarLikeChart","isVTable","isVChart","isPivotChart","isPivot","isCombination","dimensions","measures","dimension","xCount","m","yCount","otherCount","isCommonMeasureEncoding","finalXCount","finalYCount","Math","isMeasureTreeWithParentId","parentIds","isPositionMeasure","measure","DEFAULT_PARENT_ID","unique","hasMeasureGroup","isRectungularCoordinate","chartType","DEFAULT_DUAL_CHART_TYPE","isDualAxisChartType"],"mappings":";;;;AAOO,MAAMA,UAAU,CAACC,QACfA,MAAM,SAAS,KAAKC,cAAc,KAAK;AAEzC,MAAMC,eAAe,CAACF,QACpBA,MAAM,SAAS,KAAKC,cAAc,UAAU;AAE9C,MAAME,UAAU,CAACH,QACfA,MAAM,SAAS,KAAKC,cAAc,KAAK;AAEzC,MAAMG,gBAAgB,CAACJ,QACrBA,MAAM,SAAS,KAAKC,cAAc,WAAW;AAE/C,MAAMI,kBAAkB,CAACL,QACvBA,MAAM,SAAS,KAAKC,cAAc,aAAa;AAEjD,MAAMK,eAAe,CAACN,QACpBA,MAAM,SAAS,KAAKC,cAAc,UAAU;AAE9C,MAAMM,WAAW,CAACP,QAChBA,MAAM,SAAS,KAAKC,cAAc,MAAM;AAE1C,MAAMO,oBAAoB,CAACR,QACzBA,MAAM,SAAS,KAAKC,cAAc,eAAe;AAGnD,MAAMQ,iBAAiB,CAACT,QAE3BA,MAAM,SAAS,KAAKC,cAAc,GAAG,IACrCD,MAAM,SAAS,KAAKC,cAAc,OAAO,IACzCD,MAAM,SAAS,KAAKC,cAAc,UAAU,IAC5CD,MAAM,SAAS,KAAKC,cAAc,WAAW;AAI1C,MAAMS,WAAW,CAACV,QAChB;QAAC;QAAS;KAAa,CAAC,QAAQ,CAACA,MAAM,SAAS;AAElD,MAAMW,WAAW,CAACX,QAChB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