@visactor/vseed 0.1.40 → 0.1.42

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 (193) hide show
  1. package/dist/cjs/index.cjs +3 -3
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/esm/builder/builder/builder.d.ts +3211 -349
  4. package/dist/esm/pipeline/advanced/chart/pipeline/column.js +3 -2
  5. package/dist/esm/pipeline/advanced/chart/pipeline/column.js.map +1 -1
  6. package/dist/esm/pipeline/advanced/chart/pipeline/scatter.js +3 -2
  7. package/dist/esm/pipeline/advanced/chart/pipeline/scatter.js.map +1 -1
  8. package/dist/esm/pipeline/advanced/chart/pipes/analysis/common.d.ts +3 -0
  9. package/dist/esm/pipeline/advanced/chart/pipes/analysis/common.js +22 -0
  10. package/dist/esm/pipeline/advanced/chart/pipes/analysis/common.js.map +1 -0
  11. package/dist/esm/pipeline/advanced/chart/pipes/analysis/index.d.ts +1 -0
  12. package/dist/esm/pipeline/advanced/chart/pipes/analysis/index.js +1 -0
  13. package/dist/esm/pipeline/advanced/chart/pipes/analysis/sortLegend.js +1 -19
  14. package/dist/esm/pipeline/advanced/chart/pipes/analysis/sortLegend.js.map +1 -1
  15. package/dist/esm/pipeline/advanced/chart/pipes/analysis/sortXBand.d.ts +1 -2
  16. package/dist/esm/pipeline/advanced/chart/pipes/analysis/sortXBand.js +2 -20
  17. package/dist/esm/pipeline/advanced/chart/pipes/analysis/sortXBand.js.map +1 -1
  18. package/dist/esm/pipeline/advanced/chart/pipes/analysis/sortYBand.js +1 -1
  19. package/dist/esm/pipeline/advanced/chart/pipes/analysis/sortYBand.js.map +1 -1
  20. package/dist/esm/pipeline/advanced/chart/pipes/regressionLine/regressionLine.js +28 -1
  21. package/dist/esm/pipeline/advanced/chart/pipes/regressionLine/regressionLine.js.map +1 -1
  22. package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithBoxplotEncoding.js +0 -1
  23. package/dist/esm/pipeline/advanced/chart/pipes/reshape/pivotReshapeWithBoxplotEncoding.js.map +1 -1
  24. package/dist/esm/pipeline/spec/chart/pipeline/area.js +7 -4
  25. package/dist/esm/pipeline/spec/chart/pipeline/area.js.map +1 -1
  26. package/dist/esm/pipeline/spec/chart/pipeline/areaPercent.js +3 -2
  27. package/dist/esm/pipeline/spec/chart/pipeline/areaPercent.js.map +1 -1
  28. package/dist/esm/pipeline/spec/chart/pipeline/bar.js +4 -2
  29. package/dist/esm/pipeline/spec/chart/pipeline/bar.js.map +1 -1
  30. package/dist/esm/pipeline/spec/chart/pipeline/barParallel.js +4 -2
  31. package/dist/esm/pipeline/spec/chart/pipeline/barParallel.js.map +1 -1
  32. package/dist/esm/pipeline/spec/chart/pipeline/barPercent.js +4 -2
  33. package/dist/esm/pipeline/spec/chart/pipeline/barPercent.js.map +1 -1
  34. package/dist/esm/pipeline/spec/chart/pipeline/boxplot.js +3 -2
  35. package/dist/esm/pipeline/spec/chart/pipeline/boxplot.js.map +1 -1
  36. package/dist/esm/pipeline/spec/chart/pipeline/column.js +8 -4
  37. package/dist/esm/pipeline/spec/chart/pipeline/column.js.map +1 -1
  38. package/dist/esm/pipeline/spec/chart/pipeline/columnParallel.js +4 -2
  39. package/dist/esm/pipeline/spec/chart/pipeline/columnParallel.js.map +1 -1
  40. package/dist/esm/pipeline/spec/chart/pipeline/columnPercent.js +4 -2
  41. package/dist/esm/pipeline/spec/chart/pipeline/columnPercent.js.map +1 -1
  42. package/dist/esm/pipeline/spec/chart/pipeline/donut.js +3 -1
  43. package/dist/esm/pipeline/spec/chart/pipeline/donut.js.map +1 -1
  44. package/dist/esm/pipeline/spec/chart/pipeline/dualAxis.js +3 -2
  45. package/dist/esm/pipeline/spec/chart/pipeline/dualAxis.js.map +1 -1
  46. package/dist/esm/pipeline/spec/chart/pipeline/funnel.js +2 -1
  47. package/dist/esm/pipeline/spec/chart/pipeline/funnel.js.map +1 -1
  48. package/dist/esm/pipeline/spec/chart/pipeline/heatmap.js +3 -2
  49. package/dist/esm/pipeline/spec/chart/pipeline/heatmap.js.map +1 -1
  50. package/dist/esm/pipeline/spec/chart/pipeline/histogram.js +7 -4
  51. package/dist/esm/pipeline/spec/chart/pipeline/histogram.js.map +1 -1
  52. package/dist/esm/pipeline/spec/chart/pipeline/line.js +7 -4
  53. package/dist/esm/pipeline/spec/chart/pipeline/line.js.map +1 -1
  54. package/dist/esm/pipeline/spec/chart/pipeline/pie.js +4 -2
  55. package/dist/esm/pipeline/spec/chart/pipeline/pie.js.map +1 -1
  56. package/dist/esm/pipeline/spec/chart/pipeline/radar.js +3 -1
  57. package/dist/esm/pipeline/spec/chart/pipeline/radar.js.map +1 -1
  58. package/dist/esm/pipeline/spec/chart/pipeline/rose.js +3 -1
  59. package/dist/esm/pipeline/spec/chart/pipeline/rose.js.map +1 -1
  60. package/dist/esm/pipeline/spec/chart/pipeline/roseParallel.js +3 -1
  61. package/dist/esm/pipeline/spec/chart/pipeline/roseParallel.js.map +1 -1
  62. package/dist/esm/pipeline/spec/chart/pipeline/scatter.js +11 -4
  63. package/dist/esm/pipeline/spec/chart/pipeline/scatter.js.map +1 -1
  64. package/dist/esm/pipeline/spec/chart/pipes/annotation/index.d.ts +1 -0
  65. package/dist/esm/pipeline/spec/chart/pipes/annotation/index.js +2 -1
  66. package/dist/esm/pipeline/spec/chart/pipes/annotation/splitLine.d.ts +2 -0
  67. package/dist/esm/pipeline/spec/chart/pipes/annotation/splitLine.js +172 -0
  68. package/dist/esm/pipeline/spec/chart/pipes/annotation/splitLine.js.map +1 -0
  69. package/dist/esm/pipeline/spec/chart/pipes/index.d.ts +1 -0
  70. package/dist/esm/pipeline/spec/chart/pipes/index.js +1 -0
  71. package/dist/esm/pipeline/spec/chart/pipes/init/pivot.js +1 -1
  72. package/dist/esm/pipeline/spec/chart/pipes/init/pivot.js.map +1 -1
  73. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/index.d.ts +2 -0
  74. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/index.js +3 -1
  75. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.d.ts +2 -0
  76. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.js +13 -0
  77. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotAxisStyle.js.map +1 -0
  78. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js +38 -32
  79. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js.map +1 -1
  80. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotTitle.d.ts +2 -0
  81. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotTitle.js +28 -0
  82. package/dist/esm/pipeline/spec/chart/pipes/pivotChart/pivotTitle.js.map +1 -0
  83. package/dist/esm/pipeline/spec/chart/pipes/region/addRegionPadding.d.ts +2 -0
  84. package/dist/esm/pipeline/spec/chart/pipes/region/addRegionPadding.js +10 -0
  85. package/dist/esm/pipeline/spec/chart/pipes/region/addRegionPadding.js.map +1 -0
  86. package/dist/esm/pipeline/spec/chart/pipes/region/index.d.ts +1 -0
  87. package/dist/esm/pipeline/spec/chart/pipes/region/index.js +1 -0
  88. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.d.ts +2 -0
  89. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.js +150 -0
  90. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.js.map +1 -0
  91. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/common.d.ts +4 -0
  92. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/common.js +21 -0
  93. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/common.js.map +1 -0
  94. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.d.ts +2 -0
  95. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js +98 -0
  96. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js.map +1 -0
  97. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/index.d.ts +4 -1
  98. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/index.js +4 -1
  99. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.d.ts +2 -0
  100. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.js +98 -0
  101. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.js.map +1 -0
  102. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.d.ts +16 -0
  103. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js +159 -0
  104. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/linearRegressionLine.js.map +1 -0
  105. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.d.ts +2 -2
  106. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.js +5 -5
  107. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltip.js.map +1 -1
  108. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.js +2 -2
  109. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipDualAxis.js.map +1 -1
  110. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipScatter.d.ts +1 -1
  111. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipScatter.js +1 -6
  112. package/dist/esm/pipeline/spec/chart/pipes/tooltip/tooltipScatter.js.map +1 -1
  113. package/dist/esm/theme/common/color.d.ts +4 -0
  114. package/dist/esm/theme/common/color.js +6 -2
  115. package/dist/esm/theme/common/color.js.map +1 -1
  116. package/dist/esm/theme/common/regressionLine.d.ts +8 -4
  117. package/dist/esm/theme/common/regressionLine.js +60 -8
  118. package/dist/esm/theme/common/regressionLine.js.map +1 -1
  119. package/dist/esm/theme/common/table.d.ts +6 -0
  120. package/dist/esm/theme/common/table.js +4 -1
  121. package/dist/esm/theme/common/table.js.map +1 -1
  122. package/dist/esm/theme/dark/dark.js +8 -6
  123. package/dist/esm/theme/dark/dark.js.map +1 -1
  124. package/dist/esm/theme/light/light.js +8 -6
  125. package/dist/esm/theme/light/light.js.map +1 -1
  126. package/dist/esm/types/advancedVSeed.d.ts +1028 -37
  127. package/dist/esm/types/advancedVSeed.js +2 -2
  128. package/dist/esm/types/advancedVSeed.js.map +1 -1
  129. package/dist/esm/types/chartType/column/column.d.ts +6 -1
  130. package/dist/esm/types/chartType/column/zColumn.d.ts +25 -0
  131. package/dist/esm/types/chartType/column/zColumn.js +2 -1
  132. package/dist/esm/types/chartType/column/zColumn.js.map +1 -1
  133. package/dist/esm/types/chartType/histogram/histogram.d.ts +7 -3
  134. package/dist/esm/types/chartType/histogram/zHistogram.d.ts +19 -4
  135. package/dist/esm/types/chartType/histogram/zHistogram.js +3 -2
  136. package/dist/esm/types/chartType/histogram/zHistogram.js.map +1 -1
  137. package/dist/esm/types/chartType/scatter/scatter.d.ts +21 -1
  138. package/dist/esm/types/chartType/scatter/zScatter.d.ts +94 -0
  139. package/dist/esm/types/chartType/scatter/zScatter.js +5 -1
  140. package/dist/esm/types/chartType/scatter/zScatter.js.map +1 -1
  141. package/dist/esm/types/properties/annotation/annotationHorizontalLine.d.ts +13 -0
  142. package/dist/esm/types/properties/config/area.d.ts +6 -0
  143. package/dist/esm/types/properties/config/bar.d.ts +9 -0
  144. package/dist/esm/types/properties/config/boxplot.d.ts +3 -0
  145. package/dist/esm/types/properties/config/color/color.d.ts +8 -0
  146. package/dist/esm/types/properties/config/color/color.js.map +1 -1
  147. package/dist/esm/types/properties/config/column.d.ts +141 -2
  148. package/dist/esm/types/properties/config/column.js +6 -3
  149. package/dist/esm/types/properties/config/column.js.map +1 -1
  150. package/dist/esm/types/properties/config/config.d.ts +449 -9
  151. package/dist/esm/types/properties/config/dualAxis.d.ts +3 -0
  152. package/dist/esm/types/properties/config/funnel.d.ts +3 -0
  153. package/dist/esm/types/properties/config/heatmap.d.ts +3 -0
  154. package/dist/esm/types/properties/config/histogram.d.ts +132 -9
  155. package/dist/esm/types/properties/config/histogram.js +2 -2
  156. package/dist/esm/types/properties/config/histogram.js.map +1 -1
  157. package/dist/esm/types/properties/config/line.d.ts +3 -0
  158. package/dist/esm/types/properties/config/pie.d.ts +9 -0
  159. package/dist/esm/types/properties/config/pivotGrid/pivotGrid.d.ts +3 -0
  160. package/dist/esm/types/properties/config/pivotGrid/pivotGrid.js +4 -1
  161. package/dist/esm/types/properties/config/pivotGrid/pivotGrid.js.map +1 -1
  162. package/dist/esm/types/properties/config/rose.d.ts +6 -0
  163. package/dist/esm/types/properties/config/scatter.d.ts +133 -0
  164. package/dist/esm/types/properties/config/scatter.js +3 -1
  165. package/dist/esm/types/properties/config/scatter.js.map +1 -1
  166. package/dist/esm/types/properties/regressionLine/{histogramRegressionLine.d.ts → ecdfRegressionLine.d.ts} +2 -7
  167. package/dist/esm/types/properties/regressionLine/index.d.ts +7 -2
  168. package/dist/esm/types/properties/regressionLine/index.js +1 -1
  169. package/dist/esm/types/properties/regressionLine/kdeRegressionLine.d.ts +40 -0
  170. package/dist/esm/types/properties/regressionLine/linearRegressionLine.d.ts +53 -0
  171. package/dist/esm/types/properties/regressionLine/logisticRegressionLine.d.ts +53 -0
  172. package/dist/esm/types/properties/regressionLine/logisticRegressionLine.js +0 -0
  173. package/dist/esm/types/properties/regressionLine/lowessRegressionLine.d.ts +53 -0
  174. package/dist/esm/types/properties/regressionLine/lowessRegressionLine.js +0 -0
  175. package/dist/esm/types/properties/regressionLine/polynomialRegressionLine.d.ts +57 -0
  176. package/dist/esm/types/properties/regressionLine/polynomialRegressionLine.js +0 -0
  177. package/dist/esm/types/properties/regressionLine/zRegressionLine.d.ts +199 -0
  178. package/dist/esm/types/properties/regressionLine/zRegressionLine.js +32 -0
  179. package/dist/esm/types/properties/regressionLine/zRegressionLine.js.map +1 -0
  180. package/dist/esm/types/properties/theme/customTheme.d.ts +898 -18
  181. package/dist/esm/types/zVseed.d.ts +138 -4
  182. package/dist/umd/index.js +1889 -279
  183. package/dist/umd/index.js.map +1 -1
  184. package/package.json +1 -1
  185. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/histogramRegressionLine.d.ts +0 -2
  186. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/histogramRegressionLine.js +0 -126
  187. package/dist/esm/pipeline/spec/chart/pipes/regressionLine/histogramRegressionLine.js.map +0 -1
  188. package/dist/esm/types/properties/regressionLine/zHistogramRegressionLine.d.ts +0 -11
  189. package/dist/esm/types/properties/regressionLine/zHistogramRegressionLine.js +0 -17
  190. package/dist/esm/types/properties/regressionLine/zHistogramRegressionLine.js.map +0 -1
  191. /package/dist/esm/{pipeline/advanced/chart/pipes/analysis/sort.d.ts → types/properties/regressionLine/ecdfRegressionLine.js} +0 -0
  192. /package/dist/esm/{pipeline/advanced/chart/pipes/analysis/sort.js → types/properties/regressionLine/kdeRegressionLine.js} +0 -0
  193. /package/dist/esm/types/properties/regressionLine/{histogramRegressionLine.js → linearRegressionLine.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { isCombination, isPivot } from 'src/pipeline/utils'\nimport type { Config, SpecPipe } from 'src/types'\nimport { isNullish } from 'remeda'\n\nexport const pivotGridStyle: SpecPipe = (spec, context) => {\n const { vseed, advancedVSeed } = context\n const { config, chartType } = advancedVSeed\n const themConfig = (config?.[chartType] as Config['line'])?.pivotGrid ?? {}\n\n const onlyCombination = !isPivot(vseed) && isCombination(vseed)\n\n const result = { ...spec } as PivotChartConstructorOptions\n const transparent = 'rgba(0,0,0,0)'\n\n const borderColor = themConfig.borderColor ?? '#e3e5eb'\n const bodyFontColor = themConfig.bodyFontColor ?? '#141414'\n const headerFontColor = themConfig.headerFontColor ?? '#21252c'\n const headerBackgroundColor = themConfig.headerBackgroundColor ?? 'rgba(0,0,0,0)'\n const hoverHeaderBackgroundColor = onlyCombination\n ? transparent\n : (themConfig.hoverHeaderBackgroundColor ?? '#D9DDE4')\n const hoverHeaderInlineBackgroundColor = onlyCombination\n ? transparent\n : (themConfig.hoverHeaderInlineBackgroundColor ?? '#D9DDE455')\n const outlineBorderLineWidth = themConfig.outlineBorderLineWidth ?? 0\n const frameCornerRadius = themConfig.frameCornerRadius ?? 0\n\n if (!isNullish(themConfig.minChartWidth)) {\n result.defaultColWidth = themConfig.minChartWidth\n }\n\n if (!isNullish(themConfig.minChartHeight)) {\n result.defaultRowHeight = themConfig.minChartHeight\n }\n\n return {\n ...result,\n theme: {\n underlayBackgroundColor: transparent,\n bodyStyle: {\n borderColor,\n color: bodyFontColor,\n borderLineWidth: [1, outlineBorderLineWidth, 0, 1],\n bgColor: transparent,\n hover: {\n cellBgColor: 'transparent',\n },\n },\n headerStyle: {\n borderColor,\n fontSize: 12,\n borderLineWidth: [outlineBorderLineWidth, outlineBorderLineWidth, 1, 1],\n color: headerFontColor,\n textAlign: 'center',\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n rowHeaderStyle: {\n borderColor,\n fontSize: 12,\n color: headerFontColor,\n padding: [0, 4, 0, 4],\n borderLineWidth: [1, 1, 1, outlineBorderLineWidth],\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n cornerHeaderStyle: {\n borderColor,\n textAlign: 'center',\n fontSize: 12,\n color: headerFontColor,\n padding: [0, 4, 0, 4],\n fontWeight: 'bold',\n borderLineWidth: [outlineBorderLineWidth, 1, 1, outlineBorderLineWidth],\n bgColor: headerBackgroundColor,\n frameStyle: {\n borderColor,\n borderLineWidth: [outlineBorderLineWidth, 0, 0, outlineBorderLineWidth],\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n cornerRightTopCellStyle: {\n borderColor,\n borderLineWidth: 0,\n frameStyle: {\n borderColor,\n borderLineWidth: [outlineBorderLineWidth, 1, 0, 1],\n },\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n cornerLeftBottomCellStyle: {\n borderColor,\n borderLineWidth: [1, 0, outlineBorderLineWidth, outlineBorderLineWidth],\n bgColor: headerBackgroundColor,\n frameStyle: {\n borderColor,\n borderLineWidth: [1, 0, outlineBorderLineWidth, outlineBorderLineWidth],\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n cornerRightBottomCellStyle: {\n borderColor,\n borderLineWidth: 0,\n bgColor: headerBackgroundColor,\n frameStyle: {\n borderColor,\n borderLineWidth: [1, 1, 1, 1],\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n rightFrozenStyle: {\n borderColor,\n borderLineWidth: 1,\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n bottomFrozenStyle: {\n borderColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n selectionStyle: {\n cellBgColor: '',\n cellBorderColor: '',\n },\n frameStyle: {\n borderColor,\n cornerRadius: frameCornerRadius,\n borderLineWidth: outlineBorderLineWidth,\n },\n },\n }\n}\n"],"names":["pivotGridStyle","spec","context","vseed","advancedVSeed","config","chartType","themConfig","onlyCombination","isPivot","isCombination","result","transparent","borderColor","bodyFontColor","headerFontColor","headerBackgroundColor","hoverHeaderBackgroundColor","hoverHeaderInlineBackgroundColor","outlineBorderLineWidth","frameCornerRadius","isNullish","undefined"],"mappings":";;AAKO,MAAMA,iBAA2B,CAACC,MAAMC;IAC7C,MAAM,EAAEC,KAAK,EAAEC,aAAa,EAAE,GAAGF;IACjC,MAAM,EAAEG,MAAM,EAAEC,SAAS,EAAE,GAAGF;IAC9B,MAAMG,aAAcF,QAAQ,CAACC,UAAU,EAAqB,aAAa,CAAC;IAE1E,MAAME,kBAAkB,CAACC,QAAQN,UAAUO,cAAcP;IAEzD,MAAMQ,SAAS;QAAE,GAAGV,IAAI;IAAC;IACzB,MAAMW,cAAc;IAEpB,MAAMC,cAAcN,WAAW,WAAW,IAAI;IAC9C,MAAMO,gBAAgBP,WAAW,aAAa,IAAI;IAClD,MAAMQ,kBAAkBR,WAAW,eAAe,IAAI;IACtD,MAAMS,wBAAwBT,WAAW,qBAAqB,IAAI;IAClE,MAAMU,6BAA6BT,kBAC/BI,cACCL,WAAW,0BAA0B,IAAI;IAC9C,MAAMW,mCAAmCV,kBACrCI,cACCL,WAAW,gCAAgC,IAAI;IACpD,MAAMY,yBAAyBZ,WAAW,sBAAsB,IAAI;IACpE,MAAMa,oBAAoBb,WAAW,iBAAiB,IAAI;IAE1D,IAAI,CAACc,UAAUd,WAAW,aAAa,GACrCI,OAAO,eAAe,GAAGJ,WAAW,aAAa;IAGnD,IAAI,CAACc,UAAUd,WAAW,cAAc,GACtCI,OAAO,gBAAgB,GAAGJ,WAAW,cAAc;IAGrD,OAAO;QACL,GAAGI,MAAM;QACT,OAAO;YACL,yBAAyBC;YACzB,WAAW;gBACTC;gBACA,OAAOC;gBACP,iBAAiB;oBAAC;oBAAGK;oBAAwB;oBAAG;iBAAE;gBAClD,SAASP;gBACT,OAAO;oBACL,aAAa;gBACf;YACF;YACA,aAAa;gBACXC;gBACA,UAAU;gBACV,iBAAiB;oBAACM;oBAAwBA;oBAAwB;o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BAAG;wBAAG;qBAAE;gBAC/B;gBACA,OAAO;oBACL,aAAaI;gBACf;YACF;YACA,kBAAkB;gBAChBJ;gBACA,iBAAiB;gBACjB,SAASG;gBACT,OAAO;oBACL,aAAaC;gBACf;YACF;YACA,mBAAmB;gBACjBJ;gBACA,iBAAiB;oBAAC;oBAAGM;oBAAwBA;oBAAwB;iBAAE;gBACvE,SAASH;gBACT,OAAO;oBACL,aAAaC;gBACf;YACF;YACA,gBAAgB;gBACd,aAAa;gBACb,iBAAiB;YACnB;YACA,YAAY;gBACVJ;gBACA,cAAcO;gBACd,iBAAiBD;YACnB;QACF;IACF;AACF"}
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/pivotGridStyle.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport { isCombination, isPivot } from 'src/pipeline/utils'\nimport type { Config, Dimension, SpecPipe } from 'src/types'\nimport { isNullish } from 'remeda'\n\nexport const pivotGridStyle: SpecPipe = (spec, context) => {\n const { vseed, advancedVSeed } = context\n const { config, chartType, dimensions } = advancedVSeed\n const themConfig = (config?.[chartType] as Config['line'])?.pivotGrid ?? {}\n\n const onlyCombination = !isPivot(vseed) && isCombination(vseed)\n\n const result = { ...spec } as PivotChartConstructorOptions\n const transparent = 'rgba(0,0,0,0)'\n const hasColumnDimension = dimensions.some((dim: Dimension) => dim.encoding === 'column')\n\n const borderColor = themConfig.borderColor ?? '#e3e5eb'\n const bodyFontColor = themConfig.bodyFontColor ?? '#141414'\n const headerFontColor = themConfig.headerFontColor ?? '#21252c'\n const headerBackgroundColor = themConfig.headerBackgroundColor ?? 'rgba(0,0,0,0)'\n const hoverHeaderBackgroundColor = onlyCombination\n ? transparent\n : (themConfig.hoverHeaderBackgroundColor ?? '#D9DDE4')\n const hoverHeaderInlineBackgroundColor = onlyCombination\n ? transparent\n : (themConfig.hoverHeaderInlineBackgroundColor ?? '#D9DDE455')\n const outlineBorderLineWidth = themConfig.outlineBorderLineWidth ?? 0\n const frameCornerRadius = themConfig.frameCornerRadius ?? 0\n\n if (!isNullish(themConfig.minChartWidth)) {\n result.defaultColWidth = themConfig.minChartWidth\n }\n\n if (!isNullish(themConfig.minChartHeight)) {\n result.defaultRowHeight = themConfig.minChartHeight\n }\n\n return {\n ...result,\n theme: {\n underlayBackgroundColor: transparent,\n bodyStyle: {\n borderColor,\n color: bodyFontColor,\n borderLineWidth: (arg: { row: number; col: number }) => {\n return [\n arg.row === 0 ? outlineBorderLineWidth : 1,\n outlineBorderLineWidth,\n 0,\n arg.col === 0 ? outlineBorderLineWidth : 1,\n ]\n },\n bgColor: transparent,\n hover: {\n cellBgColor: 'transparent',\n },\n },\n headerStyle: {\n borderColor,\n fontSize: 12,\n // borderLineWidth: [outlineBorderLineWidth, outlineBorderLineWidth, 1, 1],\n borderLineWidth: (arg: { row: number; col: number }) => {\n return [outlineBorderLineWidth, outlineBorderLineWidth, 1, arg.col === 0 ? outlineBorderLineWidth : 1]\n },\n color: headerFontColor,\n textAlign: 'center',\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n rowHeaderStyle: {\n borderColor,\n fontSize: 12,\n color: headerFontColor,\n padding: [0, 4, 0, 4],\n borderLineWidth: (arg: { row: number }) => {\n return [arg.row === 0 ? outlineBorderLineWidth : 1, 1, 0, outlineBorderLineWidth]\n },\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n cornerHeaderStyle: {\n borderColor,\n textAlign: 'center',\n fontSize: 12,\n color: headerFontColor,\n padding: [0, 4, 0, 4],\n fontWeight: 'bold',\n borderLineWidth: [outlineBorderLineWidth, 1, 1, outlineBorderLineWidth],\n bgColor: headerBackgroundColor,\n frameStyle: {\n borderColor,\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n inlineRowBgColor: hoverHeaderInlineBackgroundColor || undefined,\n inlineColumnBgColor: hoverHeaderInlineBackgroundColor || undefined,\n },\n },\n cornerRightTopCellStyle: {\n borderColor,\n borderLineWidth: 0,\n frameStyle: {\n borderColor,\n borderLineWidth: [outlineBorderLineWidth, outlineBorderLineWidth, 1, 1],\n },\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n cornerLeftBottomCellStyle: {\n borderColor,\n borderLineWidth: [outlineBorderLineWidth, 0, outlineBorderLineWidth, outlineBorderLineWidth],\n bgColor: headerBackgroundColor,\n frameStyle: {\n borderColor,\n borderLineWidth: [1, 0, outlineBorderLineWidth, outlineBorderLineWidth],\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n cornerRightBottomCellStyle: {\n borderColor,\n bgColor: headerBackgroundColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n frameStyle: {\n borderColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n },\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n rightFrozenStyle: {\n borderColor,\n bgColor: headerBackgroundColor,\n borderLineWidth: (arg: { row: number }) => {\n return [\n arg.row === 0 || (hasColumnDimension && arg.row === 1) ? outlineBorderLineWidth : 1,\n outlineBorderLineWidth,\n 0,\n 1,\n ]\n },\n hover: {\n borderLineWidth: 0,\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n bottomFrozenStyle: {\n borderColor,\n borderLineWidth: [1, outlineBorderLineWidth, outlineBorderLineWidth, 1],\n bgColor: headerBackgroundColor,\n hover: {\n cellBgColor: hoverHeaderBackgroundColor,\n },\n },\n selectionStyle: {\n cellBgColor: '',\n cellBorderColor: '',\n },\n frameStyle: {\n borderColor,\n cornerRadius: frameCornerRadius,\n borderLineWidth: outlineBorderLineWidth,\n },\n },\n }\n}\n"],"names":["pivotGridStyle","spec","context","vseed","advancedVSeed","config","chartType","dimensions","themConfig","onlyCombination","isPivot","isCombination","result","transparent","hasColumnDimension","dim","borderColor","bodyFontColor","headerFontColor","headerBackgroundColor","hoverHeaderBackgroundColor","hoverHeaderInlineBackgroundColor","outlineBorderLineWidth","frameCornerRadius","isNullish","arg","undefined"],"mappings":";;AAKO,MAAMA,iBAA2B,CAACC,MAAMC;IAC7C,MAAM,EAAEC,KAAK,EAAEC,aAAa,EAAE,GAAGF;IACjC,MAAM,EAAEG,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGH;IAC1C,MAAMI,aAAcH,QAAQ,CAACC,UAAU,EAAqB,aAAa,CAAC;IAE1E,MAAMG,kBAAkB,CAACC,QAAQP,UAAUQ,cAAcR;IAEzD,MAAMS,SAAS;QAAE,GAAGX,IAAI;IAAC;IACzB,MAAMY,cAAc;IACpB,MAAMC,qBAAqBP,WAAW,IAAI,CAAC,CAACQ,MAAmBA,AAAiB,aAAjBA,IAAI,QAAQ;IAE3E,MAAMC,cAAcR,WAAW,WAAW,IAAI;IAC9C,MAAMS,gBAAgBT,WAAW,aAAa,IAAI;IAClD,MAAMU,kBAAkBV,WAAW,eAAe,IAAI;IACtD,MAAMW,wBAAwBX,WAAW,qBAAqB,IAAI;IAClE,MAAMY,6BAA6BX,kBAC/BI,cACCL,WAAW,0BAA0B,IAAI;IAC9C,MAAMa,mCAAmCZ,kBACrCI,cACCL,WAAW,gCAAgC,IAAI;IACpD,MAAMc,yBAAyBd,WAAW,sBAAsB,IAAI;IACpE,MAAMe,oBAAoBf,WAAW,iBAAiB,IAAI;IAE1D,IAAI,CAACgB,UAAUhB,WAAW,aAAa,GACrCI,OAAO,eAAe,GAAGJ,WAAW,aAAa;IAGnD,IAAI,CAACgB,UAAUhB,WAAW,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oBACA,iBAAiB;wBAACM;wBAAwBA;wBAAwB;wBAAG;qBAAE;gBACzE;gBACA,SAASH;gBACT,OAAO;oBACL,aAAaC;gBACf;YACF;YACA,2BAA2B;gBACzBJ;gBACA,iBAAiB;oBAACM;oBAAwB;oBAAGA;oBAAwBA;iBAAuB;gBAC5F,SAASH;gBACT,YAAY;oBACVH;oBACA,iBAAiB;wBAAC;wBAAG;wBAAGM;wBAAwBA;qBAAuB;gBACzE;gBACA,OAAO;oBACL,aAAaF;gBACf;YACF;YACA,4BAA4B;gBAC1BJ;gBACA,SAASG;gBACT,iBAAiB;oBAAC;oBAAGG;oBAAwBA;oBAAwB;iBAAE;gBACvE,YAAY;oBACVN;oBACA,iBAAiB;wBAAC;wBAAGM;wBAAwBA;wBAAwB;qBAAE;gBACzE;gBACA,OAAO;oBACL,aAAaF;gBACf;YACF;YACA,kBAAkB;gBAChBJ;gBACA,SAASG;gBACT,iBAAiB,CAACM,MACT;wBACO,MAAZA,IAAI,GAAG,IAAWX,sBAAsBW,AAAY,MAAZA,IAAI,GAAG,GAAUH,yBAAyB;wBAClFA;wBACA;wBACA;qBACD;gBAEH,OAAO;oBACL,iBAAiB;oBACjB,aAAaF;gBACf;YACF;YACA,mBAAmB;gBACjBJ;gBACA,iBAAiB;oBAAC;oBAAGM;oBAAwBA;oBAAwB;iBAAE;gBACvE,SAASH;gBACT,OAAO;oBACL,aAAaC;gBACf;YACF;YACA,gBAAgB;gBACd,aAAa;gBACb,iBAAiB;YACnB;YACA,YAAY;gBACVJ;gBACA,cAAcO;gBACd,iBAAiBD;YACnB;QACF;IACF;AACF"}
@@ -0,0 +1,2 @@
1
+ import type { SpecPipe } from '../../../../../types';
2
+ export declare const pivotTitle: SpecPipe;
@@ -0,0 +1,28 @@
1
+ const pivotTitle = (spec, context)=>{
2
+ const result = {
3
+ ...spec
4
+ };
5
+ const { advancedVSeed } = context;
6
+ const { config, chartType } = advancedVSeed;
7
+ const themConfig = config?.[chartType]?.pivotGrid ?? {};
8
+ if (result.columns && result.columns.length > 0) result.title = {
9
+ text: spec.columns.map((entry)=>entry.title).join('/'),
10
+ align: 'center',
11
+ orient: 'top',
12
+ padding: [
13
+ 2,
14
+ 0,
15
+ 0,
16
+ 0
17
+ ],
18
+ textStyle: {
19
+ fontSize: themConfig.titleFontSize ?? 12,
20
+ fill: themConfig.titleFontColor ?? '#000',
21
+ fontWeight: themConfig.titleFontWeight ?? 'bold'
22
+ }
23
+ };
24
+ return result;
25
+ };
26
+ export { pivotTitle };
27
+
28
+ //# sourceMappingURL=pivotTitle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/pivotChart/pivotTitle.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/pivotChart/pivotTitle.ts"],"sourcesContent":["import type { PivotChartConstructorOptions } from '@visactor/vtable'\nimport type { SpecPipe, Config } from 'src/types'\n\nexport const pivotTitle: SpecPipe = (spec, context): Partial<PivotChartConstructorOptions> => {\n const result = { ...spec } as PivotChartConstructorOptions\n const { advancedVSeed } = context\n const { config, chartType } = advancedVSeed\n const themConfig = (config?.[chartType] as Config['line'])?.pivotGrid ?? {}\n\n if (result.columns && result.columns.length > 0) {\n result.title = {\n text: (spec as unknown as { columns: { title: string }[] }).columns.map((entry) => entry.title).join('/'),\n align: 'center',\n orient: 'top',\n padding: [2, 0, 0, 0],\n textStyle: {\n fontSize: themConfig.titleFontSize ?? 12,\n fill: themConfig.titleFontColor ?? '#000',\n fontWeight: themConfig.titleFontWeight ?? 'bold',\n },\n }\n }\n\n return result\n}\n"],"names":["pivotTitle","spec","context","result","advancedVSeed","config","chartType","themConfig","entry"],"mappings":"AAGO,MAAMA,aAAuB,CAACC,MAAMC;IACzC,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,MAAM,EAAEC,SAAS,EAAE,GAAGF;IAC9B,MAAMG,aAAcF,QAAQ,CAACC,UAAU,EAAqB,aAAa,CAAC;IAE1E,IAAIH,OAAO,OAAO,IAAIA,OAAO,OAAO,CAAC,MAAM,GAAG,GAC5CA,OAAO,KAAK,GAAG;QACb,MAAOF,KAAqD,OAAO,CAAC,GAAG,CAAC,CAACO,QAAUA,MAAM,KAAK,EAAE,IAAI,CAAC;QACrG,OAAO;QACP,QAAQ;QACR,SAAS;YAAC;YAAG;YAAG;YAAG;SAAE;QACrB,WAAW;YACT,UAAUD,WAAW,aAAa,IAAI;YACtC,MAAMA,WAAW,cAAc,IAAI;YACnC,YAAYA,WAAW,eAAe,IAAI;QAC5C;IACF;IAGF,OAAOJ;AACT"}
@@ -0,0 +1,2 @@
1
+ import type { SpecPipe } from '../../../../../types';
2
+ export declare const addRegionPadding: SpecPipe;
@@ -0,0 +1,10 @@
1
+ const addRegionPadding = (spec)=>{
2
+ const result = {
3
+ ...spec
4
+ };
5
+ if (result.region && result.region.length > 0) result.region[0].padding = 10;
6
+ return result;
7
+ };
8
+ export { addRegionPadding };
9
+
10
+ //# sourceMappingURL=addRegionPadding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/region/addRegionPadding.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/region/addRegionPadding.ts"],"sourcesContent":["import type { IPieChartSpec } from '@visactor/vchart'\nimport type { SpecPipe } from 'src/types'\n\nexport const addRegionPadding: SpecPipe = (spec) => {\n const result = { ...spec } as IPieChartSpec\n\n if (result.region && result.region.length > 0) {\n result.region[0].padding = 10\n }\n\n return result\n}\n"],"names":["addRegionPadding","spec","result"],"mappings":"AAGO,MAAMA,mBAA6B,CAACC;IACzC,MAAMC,SAAS;QAAE,GAAGD,IAAI;IAAC;IAEzB,IAAIC,OAAO,MAAM,IAAIA,OAAO,MAAM,CAAC,MAAM,GAAG,GAC1CA,OAAO,MAAM,CAAC,EAAE,CAAC,OAAO,GAAG;IAG7B,OAAOA;AACT"}
@@ -0,0 +1 @@
1
+ export * from './addRegionPadding';
@@ -0,0 +1 @@
1
+ export * from "./addRegionPadding.js";
@@ -0,0 +1,2 @@
1
+ import type { SpecPipe } from '../../../../../types';
2
+ export declare const columnPolynomialRegressionLine: SpecPipe;
@@ -0,0 +1,150 @@
1
+ import { isNullish } from "remeda";
2
+ import { array, clamper, regressionPolynomial } from "@visactor/vutils";
3
+ import { defaultRegressionLineColor } from "./common.js";
4
+ const columnPolynomialRegressionLine = (spec, context)=>{
5
+ const result = {
6
+ ...spec
7
+ };
8
+ const { advancedVSeed } = context;
9
+ const { chartType, regressionLine } = advancedVSeed;
10
+ const lineTheme = advancedVSeed.config[chartType]?.regressionLine;
11
+ if (!regressionLine || !regressionLine.polynomialRegressionLine) return result;
12
+ const lineList = array(regressionLine.polynomialRegressionLine);
13
+ if (!result.customMark) result.customMark = [];
14
+ lineList.forEach((line, lineIndex)=>{
15
+ const theme = lineTheme.linearRegressionLine ?? {};
16
+ const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight, confidenceIntervalOpacity, confidenceIntervalVisible = theme.confidenceIntervalVisible } = line;
17
+ const childrenMarks = [];
18
+ result.customMark.push({
19
+ type: 'group',
20
+ interactive: false,
21
+ zIndex: 500,
22
+ name: `polynomialRegressionLine-${lineIndex}`,
23
+ style: {
24
+ data: (datum, ctx)=>{
25
+ const vchart = ctx.vchart;
26
+ const chart = vchart.getChart();
27
+ const s = chart.getAllSeries()[0];
28
+ if (s) {
29
+ const rect = s.getRegion().getLayoutRect();
30
+ if (0 === rect.width || 0 === rect.height) return null;
31
+ const start = s.getRegion().getLayoutStartPoint();
32
+ const yClamper = clamper(start.y, start.y + rect.height);
33
+ const data = s.getViewData()?.latestData;
34
+ const fieldX = s.fieldX?.[0];
35
+ const fieldY = s.fieldY?.[0];
36
+ const xValues = s.getRawDataStatisticsByField(fieldX).values;
37
+ if (!fieldX || !fieldY || !data || data.length <= 2 || xValues.length <= 2) return null;
38
+ const { confidenceInterval, evaluateGrid } = regressionPolynomial(xValues.map((xVal, index)=>{
39
+ const filteredData = data.filter((d)=>d[fieldX] === xVal);
40
+ return {
41
+ x: index,
42
+ y: Math.max(...filteredData.map((d)=>d[fieldY]))
43
+ };
44
+ }), void 0, void 0, {
45
+ degree: line.degree ?? 2
46
+ });
47
+ const N = xValues.length;
48
+ const xAxisHelper = s.getXAxisHelper();
49
+ const halfBandWidth = xAxisHelper ? xAxisHelper.getBandwidth(0) / 2 : 0;
50
+ const lineData = evaluateGrid(N);
51
+ const linePoints = lineData.map((datum, index)=>{
52
+ const d = {
53
+ [fieldX]: xValues[index],
54
+ [fieldY]: datum.y
55
+ };
56
+ return {
57
+ x: s.dataToPositionX(d) + start.x + halfBandWidth,
58
+ y: yClamper(s.dataToPositionY(d) + start.y)
59
+ };
60
+ });
61
+ const result = {
62
+ linePoints,
63
+ color: s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0])
64
+ };
65
+ if (confidenceIntervalVisible) {
66
+ const intervalData = confidenceInterval(N);
67
+ result.areaPoints = intervalData.map((datum, index)=>{
68
+ const d = {
69
+ [fieldX]: xValues[index],
70
+ [fieldY]: datum.lower
71
+ };
72
+ return {
73
+ x: s.dataToPositionX(d) + start.x + halfBandWidth,
74
+ y: yClamper(s.dataToPositionY(d) + start.y),
75
+ y1: yClamper(s.dataToPositionY({
76
+ [fieldY]: datum.upper
77
+ }) + start.y)
78
+ };
79
+ });
80
+ }
81
+ return result;
82
+ }
83
+ return null;
84
+ }
85
+ },
86
+ children: childrenMarks
87
+ });
88
+ if (confidenceIntervalVisible) childrenMarks.push({
89
+ type: 'area',
90
+ interactive: false,
91
+ zIndex: 500,
92
+ style: {
93
+ lineWidth: lineWidth ?? theme.lineWidth,
94
+ lineDash: lineDash ?? theme.lineDash,
95
+ fillOpacity: confidenceIntervalOpacity ?? theme.confidenceIntervalOpacity,
96
+ fill: color ?? defaultRegressionLineColor,
97
+ points: (datum, ctx, opt)=>{
98
+ const parentNode = opt.mark?._product?.parent;
99
+ if (parentNode?.attribute?.data) return parentNode.attribute.data.areaPoints;
100
+ return [];
101
+ }
102
+ }
103
+ });
104
+ childrenMarks.push({
105
+ type: 'line',
106
+ interactive: false,
107
+ zIndex: 500,
108
+ style: {
109
+ lineWidth: lineWidth ?? theme.lineWidth,
110
+ lineDash: lineDash ?? theme.lineDash,
111
+ stroke: color ?? defaultRegressionLineColor,
112
+ points: (datum, ctx, opt)=>{
113
+ const parentNode = opt.mark?._product?.parent;
114
+ if (parentNode?.attribute?.data) return parentNode.attribute.data.linePoints;
115
+ return [];
116
+ }
117
+ }
118
+ });
119
+ if (!isNullish(text)) childrenMarks.push({
120
+ type: 'text',
121
+ interactive: false,
122
+ zIndex: 500,
123
+ style: {
124
+ textAlign: 'end',
125
+ fill: textColor ?? theme.textColor,
126
+ fontSize: textFontSize ?? theme.textFontSize,
127
+ fontWeight: textFontWeight ?? theme.textFontWeight,
128
+ text: text,
129
+ x: (datum, ctx, opt)=>{
130
+ const parentNode = opt.mark?._product?.parent;
131
+ if (parentNode?.attribute?.data?.linePoints) {
132
+ const points = parentNode.attribute.data.linePoints;
133
+ return points[points.length - 1]?.x;
134
+ }
135
+ },
136
+ y: (datum, ctx, opt)=>{
137
+ const parentNode = opt.mark?._product?.parent;
138
+ if (parentNode?.attribute?.data?.linePoints) {
139
+ const points = parentNode.attribute.data.linePoints;
140
+ return points[points.length - 1]?.y;
141
+ }
142
+ }
143
+ }
144
+ });
145
+ });
146
+ return result;
147
+ };
148
+ export { columnPolynomialRegressionLine };
149
+
150
+ //# sourceMappingURL=columnRegressionLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/columnRegressionLine.ts"],"sourcesContent":["import type { IBarChartSpec, ICartesianSeries, IChart, IVChart } from '@visactor/vchart'\nimport { isNullish } from 'remeda'\nimport { array, clamper, regressionPolynomial } from '@visactor/vutils'\nimport type { Datum, SpecPipe, RegressionLineConfig, LinearRegressionLine, PolynomialRegressionLine } from 'src/types'\nimport { defaultRegressionLineColor } from './common'\n\nexport const columnPolynomialRegressionLine: SpecPipe = (spec, context): Partial<IBarChartSpec> => {\n const result = { ...spec } as Partial<IBarChartSpec>\n const { advancedVSeed } = context\n const { chartType, regressionLine } = advancedVSeed\n const lineTheme = advancedVSeed.config[chartType as 'scatter']?.regressionLine as RegressionLineConfig\n\n if (!regressionLine || !regressionLine.polynomialRegressionLine) {\n return result\n }\n\n const lineList = array(regressionLine.polynomialRegressionLine)\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n const theme = (lineTheme.linearRegressionLine ?? {}) as LinearRegressionLine\n const {\n color,\n lineWidth,\n lineDash,\n text,\n textColor,\n textFontSize,\n textFontWeight,\n confidenceIntervalOpacity,\n confidenceIntervalVisible = theme.confidenceIntervalVisible,\n } = line as LinearRegressionLine\n\n const childrenMarks: any[] = []\n\n ;(result.customMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `polynomialRegressionLine-${lineIndex}`,\n style: {\n data: (datum: any, ctx: any) => {\n const vchart = ctx.vchart as IVChart\n const chart = vchart.getChart() as IChart\n const s = chart.getAllSeries()[0] as ICartesianSeries\n\n if (s) {\n const rect = s.getRegion().getLayoutRect()\n\n if (rect.width === 0 || rect.height === 0) {\n return null\n }\n\n const start = s.getRegion().getLayoutStartPoint()\n const yClamper = clamper(start.y, start.y + rect.height)\n const data = s.getViewData()?.latestData as Datum[]\n const fieldX = s.fieldX?.[0]\n const fieldY = s.fieldY?.[0]\n const xValues = s.getRawDataStatisticsByField(fieldX).values as string[]\n\n if (!fieldX || !fieldY || !data || data.length <= 2 || xValues.length <= 2) {\n return null\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { confidenceInterval, evaluateGrid } = regressionPolynomial(\n xValues.map((xVal, index: number) => {\n const filteredData = data.filter((d) => d[fieldX] === xVal)\n\n return {\n x: index,\n y: Math.max(...filteredData.map((d) => d[fieldY] as number)),\n }\n }),\n undefined,\n undefined,\n {\n degree: (line as PolynomialRegressionLine).degree ?? 2,\n },\n )\n const N = xValues.length\n const xAxisHelper = s.getXAxisHelper()\n const halfBandWidth = xAxisHelper ? xAxisHelper.getBandwidth!(0) / 2 : 0\n const lineData = evaluateGrid(N)\n const linePoints = lineData.map((datum: Datum, index: number) => {\n const d = { [fieldX]: xValues[index], [fieldY]: datum.y }\n return {\n x: s.dataToPositionX(d)! + start.x + halfBandWidth,\n y: yClamper(s.dataToPositionY(d)! + start.y),\n }\n })\n const result: {\n linePoints: { x: number; y: number }[]\n areaPoints?: { x: number; y: number; y1: number }[]\n color: string\n } = {\n linePoints,\n color: s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0]),\n }\n\n if (confidenceIntervalVisible) {\n const intervalData = confidenceInterval(N)\n\n result.areaPoints = intervalData.map((datum: Datum, index: number) => {\n const d = { [fieldX]: xValues[index], [fieldY]: datum.lower }\n return {\n x: s.dataToPositionX(d)! + start.x + halfBandWidth,\n y: yClamper(s.dataToPositionY(d)! + start.y),\n y1: yClamper(s.dataToPositionY({ [fieldY]: datum.upper })! + start.y),\n }\n })\n }\n\n return result\n }\n return null\n },\n },\n children: childrenMarks,\n })\n\n if (confidenceIntervalVisible) {\n childrenMarks.push({\n type: 'area',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n fillOpacity: confidenceIntervalOpacity ?? theme.confidenceIntervalOpacity,\n fill: color ?? defaultRegressionLineColor,\n points: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parentNode.attribute.data.areaPoints\n }\n\n return []\n },\n },\n })\n }\n\n childrenMarks.push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n stroke: color ?? defaultRegressionLineColor,\n points: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parentNode.attribute.data.linePoints\n }\n\n return []\n },\n },\n })\n\n if (!isNullish(text)) {\n childrenMarks.push({\n type: 'text',\n interactive: false,\n zIndex: 500,\n style: {\n textAlign: 'end',\n fill: textColor ?? theme.textColor,\n fontSize: textFontSize ?? theme.textFontSize,\n fontWeight: textFontWeight ?? theme.textFontWeight,\n text: text,\n x: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.x\n }\n\n return undefined\n },\n y: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.y\n }\n\n return undefined\n },\n },\n })\n }\n })\n\n return result\n}\n"],"names":["columnPolynomialRegressionLine","spec","context","result","advancedVSeed","chartType","regressionLine","lineTheme","lineList","array","line","lineIndex","theme","color","lineWidth","lineDash","text","textColor","textFontSize","textFontWeight","confidenceIntervalOpacity","confidenceIntervalVisible","childrenMarks","datum","ctx","vchart","chart","s","rect","start","yClamper","clamper","data","fieldX","fieldY","xValues","confidenceInterval","evaluateGrid","regressionPolynomial","xVal","index","filteredData","d","Math","undefined","N","xAxisHelper","halfBandWidth","lineData","linePoints","intervalData","defaultRegressionLineColor","opt","parentNode","isNullish","points"],"mappings":";;;AAMO,MAAMA,iCAA2C,CAACC,MAAMC;IAC7D,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,SAAS,EAAEC,cAAc,EAAE,G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jB,MAAM;YACN,aAAa;YACb,QAAQ;YACR,OAAO;gBACL,WAAW;gBACX,MAAML,aAAaL,MAAM,SAAS;gBAClC,UAAUM,gBAAgBN,MAAM,YAAY;gBAC5C,YAAYO,kBAAkBP,MAAM,cAAc;gBAClD,MAAMI;gBACN,GAAG,CAACO,OAAYC,KAAU4B;oBACxB,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;oBAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;wBAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;wBACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;oBACpC;gBAGF;gBACA,GAAG,CAAChC,OAAYC,KAAU4B;oBACxB,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;oBAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;wBAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;wBACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;oBACpC;gBAGF;YACF;QACF;IAEJ;IAEA,OAAOpD;AACT"}
@@ -0,0 +1,4 @@
1
+ import type { Datum } from '@visactor/vchart';
2
+ export declare const defaultRegressionLineColor: (datum: Datum, ctx: any, opt: any) => string | undefined;
3
+ export declare const defaultRegressionLineLabelX: (datum: any, ctx: any, opt: any) => any;
4
+ export declare const defaultRegressionLineLabelY: (datum: any, ctx: any, opt: any) => any;
@@ -0,0 +1,21 @@
1
+ const defaultRegressionLineColor = (datum, ctx, opt)=>{
2
+ const parentNode = opt.mark?._product?.parent;
3
+ if (parentNode?.attribute?.data) return parentNode.attribute.data.color;
4
+ };
5
+ const defaultRegressionLineLabelX = (datum, ctx, opt)=>{
6
+ const parentNode = opt.mark?._product?.parent;
7
+ if (parentNode?.attribute?.data?.linePoints) {
8
+ const points = parentNode.attribute.data.linePoints;
9
+ return points[points.length - 1]?.x;
10
+ }
11
+ };
12
+ const defaultRegressionLineLabelY = (datum, ctx, opt)=>{
13
+ const parentNode = opt.mark?._product?.parent;
14
+ if (parentNode?.attribute?.data?.linePoints) {
15
+ const points = parentNode.attribute.data.linePoints;
16
+ return points[points.length - 1]?.y;
17
+ }
18
+ };
19
+ export { defaultRegressionLineColor, defaultRegressionLineLabelX, defaultRegressionLineLabelY };
20
+
21
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/common.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/common.ts"],"sourcesContent":["import type { Datum } from '@visactor/vchart'\n\nexport const defaultRegressionLineColor = (datum: Datum, ctx: any, opt: any): string | undefined => {\n const parentNode = opt.mark?._product?.parent\n if (parentNode?.attribute?.data) {\n return parentNode.attribute.data.color\n }\n return undefined\n}\n\nexport const defaultRegressionLineLabelX = (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.x\n }\n\n return undefined\n}\n\nexport const defaultRegressionLineLabelY = (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data?.linePoints) {\n const points = parentNode.attribute.data.linePoints\n return points[points.length - 1]?.y\n }\n\n return undefined\n}\n"],"names":["defaultRegressionLineColor","datum","ctx","opt","parentNode","defaultRegressionLineLabelX","points","defaultRegressionLineLabelY"],"mappings":"AAEO,MAAMA,6BAA6B,CAACC,OAAcC,KAAUC;IACjE,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;IACvC,IAAIC,YAAY,WAAW,MACzB,OAAOA,WAAW,SAAS,CAAC,IAAI,CAAC,KAAK;AAG1C;AAEO,MAAMC,8BAA8B,CAACJ,OAAYC,KAAUC;IAChE,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;IAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;QAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;QACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;IACpC;AAGF;AAEO,MAAMC,8BAA8B,CAACN,OAAYC,KAAUC;IAChE,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;IAEvC,IAAIC,YAAY,WAAW,MAAM,YAAY;QAC3C,MAAME,SAASF,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;QACnD,OAAOE,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,EAAE;IACpC;AAGF"}
@@ -0,0 +1,2 @@
1
+ import type { SpecPipe } from '../../../../../types';
2
+ export declare const ecdfRegressionLine: SpecPipe;
@@ -0,0 +1,98 @@
1
+ import { isNullish, uniqueBy } from "remeda";
2
+ import { array, ecdf } from "@visactor/vutils";
3
+ import { defaultRegressionLineColor, defaultRegressionLineLabelX, defaultRegressionLineLabelY } from "./common.js";
4
+ const ecdfRegressionLine = (spec, context)=>{
5
+ const result = {
6
+ ...spec
7
+ };
8
+ const { advancedVSeed, vseed } = context;
9
+ const { chartType, encoding = {}, dimensions, regressionLine } = advancedVSeed;
10
+ const { dataset } = vseed;
11
+ const lineTheme = advancedVSeed.config[chartType]?.regressionLine;
12
+ if (!regressionLine || !regressionLine.ecdfRegressionLine) return result;
13
+ const rowColumnFields = uniqueBy(dimensions.filter((dim)=>'row' === dim.encoding || 'column' === dim.encoding), (item)=>item.id);
14
+ const lineList = array(regressionLine.ecdfRegressionLine);
15
+ if (!result.customMark) result.customMark = [];
16
+ lineList.forEach((line, lineIndex)=>{
17
+ const theme = lineTheme?.ecdfRegressionLine ?? {};
18
+ const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } = line;
19
+ const childrenMarks = [];
20
+ result.customMark.push({
21
+ type: 'group',
22
+ interactive: false,
23
+ zIndex: 500,
24
+ name: `ecdfRegressionLine-${lineIndex}`,
25
+ style: {
26
+ data: (datum, ctx)=>{
27
+ const vchart = ctx.vchart;
28
+ const chart = vchart.getChart();
29
+ const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
30
+ if (series && series.length) {
31
+ const s = series[0];
32
+ const region = s.getRegion().getLayoutStartPoint();
33
+ const fieldX = s.fieldX?.[0];
34
+ const scaleY = s.getYAxisHelper().getScale?.(0);
35
+ const viewData = s.getViewData()?.latestData;
36
+ if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) return null;
37
+ const simpleData = dataset.filter((entry)=>rowColumnFields.length ? rowColumnFields.every((dim)=>entry[dim.id] === viewData[0][dim.id]) : true).map((d)=>d[encoding.value?.[0]]);
38
+ const res = ecdf(simpleData);
39
+ const N = Math.max(3, Math.floor(simpleData.length / 4));
40
+ const lineData = res.evaluateGrid(N);
41
+ const yRange = scaleY.range();
42
+ const y0 = yRange[0];
43
+ const y1 = yRange[yRange.length - 1];
44
+ const scaleR = (e)=>y0 + (y1 - y0) * e;
45
+ const linePoints = lineData.map((ld)=>{
46
+ const d = {
47
+ [fieldX]: ld.x
48
+ };
49
+ return {
50
+ x: s.dataToPositionX(d) + region.x,
51
+ y: scaleR(ld.y) + region.y
52
+ };
53
+ });
54
+ return {
55
+ linePoints,
56
+ color: color ?? s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0])
57
+ };
58
+ }
59
+ return null;
60
+ }
61
+ },
62
+ children: childrenMarks
63
+ });
64
+ childrenMarks.push({
65
+ type: 'line',
66
+ interactive: false,
67
+ zIndex: 500,
68
+ style: {
69
+ lineWidth: lineWidth ?? theme.lineWidth,
70
+ lineDash: lineDash ?? theme.lineDash,
71
+ stroke: color ?? defaultRegressionLineColor,
72
+ points: (datum, ctx, opt)=>{
73
+ const parentNode = opt.mark?._product?.parent;
74
+ if (parentNode?.attribute?.data) return parentNode.attribute.data.linePoints;
75
+ return [];
76
+ }
77
+ }
78
+ });
79
+ if (!isNullish(text)) childrenMarks.push({
80
+ type: 'text',
81
+ interactive: false,
82
+ zIndex: 500,
83
+ style: {
84
+ textAlign: 'end',
85
+ fill: textColor ?? theme.textColor,
86
+ fontSize: textFontSize ?? theme.textFontSize,
87
+ fontWeight: textFontWeight ?? theme.textFontWeight,
88
+ text: text,
89
+ x: defaultRegressionLineLabelX,
90
+ y: defaultRegressionLineLabelY
91
+ }
92
+ });
93
+ });
94
+ return result;
95
+ };
96
+ export { ecdfRegressionLine };
97
+
98
+ //# sourceMappingURL=ecdfRegressionLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/ecdfRegressionLine.ts"],"sourcesContent":["import type { ICartesianSeries, IChart, IHistogramChartSpec, IVChart } from '@visactor/vchart'\nimport { isNullish, uniqueBy } from 'remeda'\nimport { ecdf, array } from '@visactor/vutils'\nimport type { Datum, Dimension, SpecPipe, Encoding, RegressionLineConfig, EcdfRegressionLine } from 'src/types'\nimport { defaultRegressionLineColor, defaultRegressionLineLabelX, defaultRegressionLineLabelY } from './common'\n\nexport const ecdfRegressionLine: SpecPipe = (spec, context) => {\n const result = { ...spec } as IHistogramChartSpec\n const { advancedVSeed, vseed } = context\n const { chartType, encoding = {} as Encoding, dimensions, regressionLine } = advancedVSeed\n const { dataset } = vseed\n const lineTheme = advancedVSeed.config[chartType as 'histogram']?.regressionLine as RegressionLineConfig\n\n if (!regressionLine || !regressionLine.ecdfRegressionLine) {\n return result\n }\n\n const rowColumnFields = uniqueBy(\n dimensions.filter((dim: Dimension) => dim.encoding === 'row' || dim.encoding === 'column'),\n (item: Dimension) => item.id,\n )\n\n const lineList = array(regressionLine.ecdfRegressionLine)\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n const theme = (lineTheme?.ecdfRegressionLine ?? {}) as EcdfRegressionLine\n const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } = line as EcdfRegressionLine\n\n const childrenMarks: any[] = []\n\n ;(result.customMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `ecdfRegressionLine-${lineIndex}`,\n style: {\n data: (datum: any, ctx: any) => {\n const vchart = ctx.vchart as IVChart\n const chart = vchart.getChart() as IChart\n const series = chart.getAllSeries().filter((s: any) => s.type === 'bar')\n\n // 直方图使用的是bar系列\n if (series && series.length) {\n const s = series[0] as ICartesianSeries\n const region = s.getRegion().getLayoutStartPoint()\n\n const fieldX = s.fieldX?.[0]\n const scaleY = s.getYAxisHelper().getScale?.(0)\n const viewData = s.getViewData()?.latestData\n\n if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) {\n return null\n }\n const simpleData = dataset\n .filter((entry: Datum) => {\n return rowColumnFields.length\n ? rowColumnFields.every((dim: Dimension) => {\n return entry[dim.id] === viewData[0][dim.id]\n })\n : true\n })\n .map((d: Datum) => (d as any)[encoding.value?.[0] as string]) as number[]\n const res = ecdf(simpleData)\n const N = Math.max(3, Math.floor(simpleData.length / 4))\n const lineData = res.evaluateGrid(N)\n const yRange = scaleY.range()\n const y0 = yRange[0]\n const y1 = yRange[yRange.length - 1]\n const scaleR = (e: number) => {\n return y0 + (y1 - y0) * e\n }\n\n const linePoints = lineData.map((ld: Datum) => {\n const d = { [fieldX]: ld.x }\n return {\n x: s.dataToPositionX(d)! + region.x,\n y: scaleR(ld.y as number) + region.y,\n }\n })\n\n return {\n linePoints,\n color: color ?? s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0]),\n }\n }\n return null\n },\n },\n children: childrenMarks,\n })\n\n childrenMarks.push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n stroke: color ?? defaultRegressionLineColor,\n points: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parentNode.attribute.data.linePoints\n }\n\n return []\n },\n },\n })\n\n if (!isNullish(text)) {\n childrenMarks.push({\n type: 'text',\n interactive: false,\n zIndex: 500,\n style: {\n textAlign: 'end',\n fill: textColor ?? theme.textColor,\n fontSize: textFontSize ?? theme.textFontSize,\n fontWeight: textFontWeight ?? theme.textFontWeight,\n text: text,\n x: defaultRegressionLineLabelX,\n y: defaultRegressionLineLabelY,\n },\n })\n }\n })\n\n return result\n}\n"],"names":["ecdfRegressionLine","spec","context","result","advancedVSeed","vseed","chartType","encoding","dimensions","regressionLine","dataset","lineTheme","rowColumnFields","uniqueBy","dim","item","lineList","array","line","lineIndex","theme","color","lineWidth","lineDash","text","textColor","textFontSize","textFontWeight","childrenMarks","datum","ctx","vchart","chart","series","s","region","fieldX","scaleY","viewData","simpleData","entry","d","res","ecdf","N","Math","lineData","yRange","y0","y1","scaleR","e","linePoints","ld","defaultRegressionLineColor","opt","parentNode","isNullish","defaultRegressionLineLabelX","defaultRegressionLineLabelY"],"mappings":";;;AAMO,MAAMA,qBAA+B,CAACC,MAAMC;IACjD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAEC,WAAW,CAAC,CAAa,EAAEC,UAAU,EAAEC,cAAc,EAAE,GAAGL;IAC7E,MAAM,EAAEM,OAAO,EAAE,GAAGL;IACpB,MAAMM,YAAYP,cAAc,MAAM,CAACE,UAAyB,EAAE;IAElE,IAAI,CAACG,kBAAkB,CAACA,eAAe,kBAAkB,EACvD,OAAON;IAGT,MAAMS,kBAAkBC,SACtBL,WAAW,MAAM,CAAC,CAACM,MAAmBA,AAAiB,UAAjBA,IAAI,QAAQ,IAAcA,AAAiB,aAAjBA,IAAI,QAAQ,GAC5E,CAACC,OAAoBA,KAAK,EAAE;IAG9B,MAAMC,WAAWC,MAAMR,eAAe,kBAAkB;IAExD,IAAI,CAACN,OAAO,UAAU,EACpBA,OA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AO;gBACL,WAAW;gBACX,MAAMH,aAAaL,MAAM,SAAS;gBAClC,UAAUM,gBAAgBN,MAAM,YAAY;gBAC5C,YAAYO,kBAAkBP,MAAM,cAAc;gBAClD,MAAMI;gBACN,GAAGkC;gBACH,GAAGC;YACL;QACF;IAEJ;IAEA,OAAOxD;AACT"}
@@ -1 +1,4 @@
1
- export * from './histogramRegressionLine';
1
+ export * from './kdeRegressionLine';
2
+ export * from './ecdfRegressionLine';
3
+ export * from './linearRegressionLine';
4
+ export * from './columnRegressionLine';
@@ -1 +1,4 @@
1
- export * from "./histogramRegressionLine.js";
1
+ export * from "./kdeRegressionLine.js";
2
+ export * from "./ecdfRegressionLine.js";
3
+ export * from "./linearRegressionLine.js";
4
+ export * from "./columnRegressionLine.js";
@@ -0,0 +1,2 @@
1
+ import type { SpecPipe } from '../../../../../types';
2
+ export declare const kdeRegressionLine: SpecPipe;
@@ -0,0 +1,98 @@
1
+ import { isNullish, uniqueBy } from "remeda";
2
+ import { array, kde } from "@visactor/vutils";
3
+ import { BinEndMeasureId, BinStartMeasureId } from "../../../../../dataReshape/index.js";
4
+ import { defaultRegressionLineColor, defaultRegressionLineLabelX, defaultRegressionLineLabelY } from "./common.js";
5
+ const kdeRegressionLine = (spec, context)=>{
6
+ const result = {
7
+ ...spec
8
+ };
9
+ const { advancedVSeed, vseed } = context;
10
+ const { chartType, encoding = {}, dimensions, regressionLine } = advancedVSeed;
11
+ const { dataset } = vseed;
12
+ const lineTheme = advancedVSeed.config[chartType]?.regressionLine;
13
+ if (!regressionLine || !regressionLine.kdeRegressionLine) return result;
14
+ const rowColumnFields = uniqueBy(dimensions.filter((dim)=>'row' === dim.encoding || 'column' === dim.encoding), (item)=>item.id);
15
+ const lineList = array(regressionLine.kdeRegressionLine);
16
+ if (!result.customMark) result.customMark = [];
17
+ lineList.forEach((line, lineIndex)=>{
18
+ const theme = lineTheme.kdeRegressionLine ?? {};
19
+ const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } = line;
20
+ const childrenMarks = [];
21
+ result.customMark.push({
22
+ type: 'group',
23
+ interactive: false,
24
+ zIndex: 500,
25
+ name: `kdeRegressionLine-${lineIndex}`,
26
+ style: {
27
+ data: (datum, ctx)=>{
28
+ const vchart = ctx.vchart;
29
+ const chart = vchart.getChart();
30
+ const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
31
+ if (series && series.length) {
32
+ const s = series[0];
33
+ const region = s.getRegion().getLayoutStartPoint();
34
+ const fieldX = s.fieldX?.[0];
35
+ const scaleY = s.getYAxisHelper().getScale?.(0);
36
+ const viewData = s.getViewData()?.latestData;
37
+ if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) return null;
38
+ const simpleData = dataset.filter((entry)=>rowColumnFields.length ? rowColumnFields.every((dim)=>entry[dim.id] === viewData[0][dim.id]) : true).map((d)=>d[encoding.value?.[0]]);
39
+ const res = kde(simpleData, {
40
+ bandwidth: Math.abs(viewData[0][BinEndMeasureId] - viewData[0][BinStartMeasureId])
41
+ });
42
+ const N = Math.max(3, Math.floor(simpleData.length / 4));
43
+ const lineData = res.evaluateGrid(N);
44
+ const scaleR = (k)=>scaleY.scale(k * simpleData.length * res.bandwidth);
45
+ const linePoints = lineData.map((ld)=>{
46
+ const d = {
47
+ [fieldX]: ld.x
48
+ };
49
+ return {
50
+ x: s.dataToPositionX(d) + region.x,
51
+ y: scaleR(ld.y) + region.y
52
+ };
53
+ });
54
+ return {
55
+ linePoints,
56
+ color: color ?? s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0])
57
+ };
58
+ }
59
+ return null;
60
+ }
61
+ },
62
+ children: childrenMarks
63
+ });
64
+ childrenMarks.push({
65
+ type: 'line',
66
+ interactive: false,
67
+ zIndex: 500,
68
+ style: {
69
+ lineWidth: lineWidth ?? theme.lineWidth,
70
+ lineDash: lineDash ?? theme.lineDash,
71
+ stroke: color ?? defaultRegressionLineColor,
72
+ points: (datum, ctx, opt)=>{
73
+ const parentNode = opt.mark?._product?.parent;
74
+ if (parentNode?.attribute?.data) return parentNode.attribute.data.linePoints;
75
+ return [];
76
+ }
77
+ }
78
+ });
79
+ if (!isNullish(text)) childrenMarks.push({
80
+ type: 'text',
81
+ interactive: false,
82
+ zIndex: 500,
83
+ style: {
84
+ textAlign: 'end',
85
+ fill: textColor ?? theme.textColor,
86
+ fontSize: textFontSize ?? theme.textFontSize,
87
+ fontWeight: textFontWeight ?? theme.textFontWeight,
88
+ text: text,
89
+ x: defaultRegressionLineLabelX,
90
+ y: defaultRegressionLineLabelY
91
+ }
92
+ });
93
+ });
94
+ return result;
95
+ };
96
+ export { kdeRegressionLine };
97
+
98
+ //# sourceMappingURL=kdeRegressionLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/kdeRegressionLine.ts"],"sourcesContent":["import type { ICartesianSeries, IChart, IHistogramChartSpec, IVChart } from '@visactor/vchart'\nimport type { KDEOptions } from '@visactor/vutils'\nimport { isNullish, uniqueBy } from 'remeda'\nimport { kde, array } from '@visactor/vutils'\nimport { BinEndMeasureId, BinStartMeasureId } from 'src/dataReshape'\nimport type { Datum, Dimension, SpecPipe, Encoding, RegressionLineConfig, KdeRegressionLine } from 'src/types'\nimport { defaultRegressionLineColor, defaultRegressionLineLabelX, defaultRegressionLineLabelY } from './common'\n\nexport const kdeRegressionLine: SpecPipe = (spec, context) => {\n const result = { ...spec } as IHistogramChartSpec\n const { advancedVSeed, vseed } = context\n const { chartType, encoding = {} as Encoding, dimensions, regressionLine } = advancedVSeed\n const { dataset } = vseed\n const lineTheme = advancedVSeed.config[chartType as 'histogram']?.regressionLine as RegressionLineConfig\n\n if (!regressionLine || !regressionLine.kdeRegressionLine) {\n return result\n }\n\n const rowColumnFields = uniqueBy(\n dimensions.filter((dim: Dimension) => dim.encoding === 'row' || dim.encoding === 'column'),\n (item: Dimension) => item.id,\n )\n\n const lineList = array(regressionLine.kdeRegressionLine)\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n lineList.forEach((line, lineIndex) => {\n const theme = (lineTheme.kdeRegressionLine ?? {}) as KdeRegressionLine\n const { color, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } = line as KdeRegressionLine\n\n const childrenMarks: any[] = []\n\n ;(result.customMark as any[]).push({\n type: 'group',\n interactive: false,\n zIndex: 500,\n name: `kdeRegressionLine-${lineIndex}`,\n style: {\n data: (datum: any, ctx: any) => {\n const vchart = ctx.vchart as IVChart\n const chart = vchart.getChart() as IChart\n const series = chart.getAllSeries().filter((s: any) => s.type === 'bar')\n\n // 直方图使用的是bar系列\n if (series && series.length) {\n const s = series[0] as ICartesianSeries\n const region = s.getRegion().getLayoutStartPoint()\n\n const fieldX = s.fieldX?.[0]\n const scaleY = s.getYAxisHelper().getScale?.(0)\n const viewData = s.getViewData()?.latestData\n\n if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) {\n return null\n }\n const simpleData = dataset\n .filter((entry: Datum) => {\n return rowColumnFields.length\n ? rowColumnFields.every((dim: Dimension) => {\n return entry[dim.id] === viewData[0][dim.id]\n })\n : true\n })\n .map((d: Datum) => (d as any)[encoding.value?.[0] as string]) as number[]\n const res = kde(simpleData, {\n bandwidth: Math.abs(viewData[0][BinEndMeasureId] - viewData[0][BinStartMeasureId]),\n } as KDEOptions)\n const N = Math.max(3, Math.floor(simpleData.length / 4))\n const lineData = res.evaluateGrid(N)\n const scaleR = (k: number) => {\n return scaleY.scale(k * simpleData.length * res.bandwidth)\n }\n\n const linePoints = lineData.map((ld: Datum) => {\n const d = { [fieldX]: ld.x }\n return {\n x: s.dataToPositionX(d)! + region.x,\n y: scaleR(ld.y as number) + region.y,\n }\n })\n\n return {\n linePoints,\n color: color ?? s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0]),\n }\n }\n return null\n },\n },\n children: childrenMarks,\n })\n\n childrenMarks.push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme.lineWidth,\n lineDash: lineDash ?? theme.lineDash,\n stroke: color ?? defaultRegressionLineColor,\n points: (datum: any, ctx: any, opt: any) => {\n const parentNode = opt.mark?._product?.parent\n\n if (parentNode?.attribute?.data) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return parentNode.attribute.data.linePoints\n }\n\n return []\n },\n },\n })\n\n if (!isNullish(text)) {\n childrenMarks.push({\n type: 'text',\n interactive: false,\n zIndex: 500,\n style: {\n textAlign: 'end',\n fill: textColor ?? theme.textColor,\n fontSize: textFontSize ?? theme.textFontSize,\n fontWeight: textFontWeight ?? theme.textFontWeight,\n text: text,\n x: defaultRegressionLineLabelX,\n y: defaultRegressionLineLabelY,\n },\n })\n }\n })\n\n return result\n}\n"],"names":["kdeRegressionLine","spec","context","result","advancedVSeed","vseed","chartType","encoding","dimensions","regressionLine","dataset","lineTheme","rowColumnFields","uniqueBy","dim","item","lineList","array","line","lineIndex","theme","color","lineWidth","lineDash","text","textColor","textFontSize","textFontWeight","childrenMarks","datum","ctx","vchart","chart","series","s","region","fieldX","scaleY","viewData","simpleData","entry","d","res","kde","Math","BinEndMeasureId","BinStartMeasureId","N","lineData","scaleR","k","linePoints","ld","defaultRegressionLineColor","opt","parentNode","isNullish","defaultRegressionLineLabelX","defaultRegressionLineLabelY"],"mappings":";;;;AAQO,MAAMA,oBAA8B,CAACC,MAAMC;IAChD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAEC,WAAW,CAAC,CAAa,EAAEC,UAAU,EAAEC,cAAc,EAAE,GAAGL;IAC7E,MAAM,EAAEM,OAAO,EAAE,GAAGL;IACpB,MAAMM,YAAYP,cAAc,MAAM,CAACE,UAAyB,EAAE;IAElE,IAAI,CAACG,kBAAkB,CAACA,eAAe,iBAAiB,EACtD,OA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AUwB;oBAC7B,MAAMC,aAAaD,IAAI,IAAI,EAAE,UAAU;oBAEvC,IAAIC,YAAY,WAAW,MAEzB,OAAOA,WAAW,SAAS,CAAC,IAAI,CAAC,UAAU;oBAG7C,OAAO,EAAE;gBACX;YACF;QACF;QAEA,IAAI,CAACC,UAAUhC,OACbI,cAAc,IAAI,CAAC;YACjB,MAAM;YACN,aAAa;YACb,QAAQ;YACR,OAAO;gBACL,WAAW;gBACX,MAAMH,aAAaL,MAAM,SAAS;gBAClC,UAAUM,gBAAgBN,MAAM,YAAY;gBAC5C,YAAYO,kBAAkBP,MAAM,cAAc;gBAClD,MAAMI;gBACN,GAAGiC;gBACH,GAAGC;YACL;QACF;IAEJ;IAEA,OAAOvD;AACT"}
@@ -0,0 +1,16 @@
1
+ import type { Datum, SpecPipe } from '../../../../../types';
2
+ export declare const generateRegressionLinePipe: (type: "linearRegressionLine" | "lowessRegressionLine" | "polynomialRegressionLine" | "logisticRegressionLine", regressionFunction: (arr: Datum[], xAccessor: (d: Datum) => number, yAccessor: (d: Datum) => number, options?: any) => {
3
+ confidenceInterval: (N: number) => {
4
+ lower: number;
5
+ upper: number;
6
+ x: number;
7
+ }[];
8
+ evaluateGrid: (N: number) => {
9
+ x: number;
10
+ y: number;
11
+ }[];
12
+ }, getOptions?: (lineConfig: any) => any) => SpecPipe;
13
+ export declare const linearRegressionLine: SpecPipe;
14
+ export declare const lowessRegressionLine: SpecPipe;
15
+ export declare const polynomialRegressionLine: SpecPipe;
16
+ export declare const logisticRegressionLine: SpecPipe;