@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vseed",
3
- "version": "0.1.40",
3
+ "version": "0.1.42",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +0,0 @@
1
- import type { SpecPipe } from '../../../../../types';
2
- export declare const histogramRegressionLine: SpecPipe;
@@ -1,126 +0,0 @@
1
- import { isNullish, uniqueBy } from "remeda";
2
- import { ecdf, kde } from "@visactor/vutils";
3
- import { BinEndMeasureId, BinStartMeasureId } from "../../../../../dataReshape/index.js";
4
- const getRegressionByType = (type, data, kdeOptions)=>{
5
- switch(type){
6
- case 'kde':
7
- return kde(data, kdeOptions);
8
- case 'ecdf':
9
- return ecdf(data);
10
- }
11
- };
12
- const histogramRegressionLine_histogramRegressionLine = (spec, context)=>{
13
- const result = {
14
- ...spec
15
- };
16
- const { advancedVSeed, vseed } = context;
17
- const { chartType, encoding = {}, dimensions, histogramRegressionLine } = advancedVSeed;
18
- const { dataset } = vseed;
19
- const theme = advancedVSeed.config[chartType]?.histogramRegressionLine;
20
- if (!histogramRegressionLine) return result;
21
- const rowColumnFields = uniqueBy(dimensions.filter((dim)=>'row' === dim.encoding || 'column' === dim.encoding), (item)=>item.id);
22
- const lineList = Array.isArray(histogramRegressionLine) ? histogramRegressionLine : [
23
- histogramRegressionLine
24
- ];
25
- if (!result.customMark) result.customMark = [];
26
- lineList.forEach((line)=>{
27
- const { color, type, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } = line;
28
- result.customMark.push({
29
- type: 'line',
30
- interactive: false,
31
- zIndex: 500,
32
- style: {
33
- lineWidth: lineWidth ?? theme?.lineWidth,
34
- lineDash: lineDash ?? theme?.lineDash,
35
- stroke: color ?? ((datum, ctx)=>{
36
- const vchart = ctx.vchart;
37
- const chart = vchart.getChart();
38
- const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
39
- return series.length ? series[0].getOption().globalScale.getScale('color')?.scale(series[0].getSeriesKeys()[0]) : void 0;
40
- }),
41
- points: (datum, ctx)=>{
42
- const vchart = ctx.vchart;
43
- const chart = vchart.getChart();
44
- const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
45
- if (series && series.length) {
46
- const s = series[0];
47
- const region = s.getRegion().getLayoutStartPoint();
48
- const fieldX = s.fieldX?.[0];
49
- const scaleY = s.getYAxisHelper().getScale?.(0);
50
- const viewData = s.getViewData()?.latestData;
51
- if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) return;
52
- const simpleData = dataset.filter((entry)=>rowColumnFields.length ? rowColumnFields.every((dim)=>entry[dim.id] === viewData[0][dim.id]) : true).map((d)=>d[encoding.value?.[0]]);
53
- const res = getRegressionByType(type, simpleData, 'kde' === type ? {
54
- bandwidth: Math.abs(viewData[0][BinEndMeasureId] - viewData[0][BinStartMeasureId])
55
- } : void 0);
56
- const N = Math.max(3, Math.floor(simpleData.length / 4));
57
- const lineData = res.evaluateGrid(N);
58
- const yRange = scaleY.range();
59
- const y0 = yRange[0];
60
- const y1 = yRange[yRange.length - 1];
61
- const scaleR = 'kde' === type ? (k)=>scaleY.scale(k * simpleData.length * res.bandwidth) : (e)=>y0 + (y1 - y0) * e;
62
- return lineData.map((ld)=>{
63
- const d = {
64
- [fieldX]: ld.x
65
- };
66
- return {
67
- x: s.dataToPositionX(d) + region.x,
68
- y: scaleR(ld.y) + region.y
69
- };
70
- });
71
- }
72
- return [];
73
- }
74
- }
75
- });
76
- if (!isNullish(text)) result.customMark.push({
77
- type: 'text',
78
- interactive: false,
79
- zIndex: 500,
80
- style: {
81
- textAlign: 'end',
82
- fill: textColor ?? theme?.textColor,
83
- fontSize: textFontSize ?? theme?.textFontSize,
84
- fontWeight: textFontWeight ?? theme?.textFontWeight,
85
- text: text,
86
- x: (datum, ctx)=>{
87
- const vchart = ctx.vchart;
88
- const chart = vchart.getChart();
89
- const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
90
- if (series && series.length) {
91
- const s = series[0];
92
- const startPoint = s.getRegion().getLayoutStartPoint();
93
- const fieldX = s.fieldX[0];
94
- const fieldX2 = s.fieldX2;
95
- const scaleY = s.getYAxisHelper().getScale?.(0);
96
- const viewData = s.getViewData()?.latestData;
97
- if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) return;
98
- const maxX = Math.max.apply(null, viewData.map((d)=>Math.max(d[fieldX], d[fieldX2])));
99
- return startPoint.x + s.dataToPositionX({
100
- [fieldX]: maxX
101
- });
102
- }
103
- },
104
- y: (datum, ctx)=>{
105
- const vchart = ctx.vchart;
106
- const chart = vchart.getChart();
107
- const series = chart.getAllSeries().filter((s)=>'bar' === s.type);
108
- if (series && series.length) {
109
- const s = series[0];
110
- const startPoint = s.getRegion().getLayoutStartPoint();
111
- const fieldY = s.fieldY[0];
112
- const viewData = s.getViewData()?.latestData;
113
- if (!viewData || !viewData.length) return;
114
- return 'ecdf' === type ? startPoint.y + 12 : startPoint.y + s.dataToPositionY({
115
- [fieldY]: viewData[viewData.length - 1]?.[fieldY]
116
- });
117
- }
118
- }
119
- }
120
- });
121
- });
122
- return result;
123
- };
124
- export { histogramRegressionLine_histogramRegressionLine as histogramRegressionLine };
125
-
126
- //# sourceMappingURL=histogramRegressionLine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipeline/spec/chart/pipes/regressionLine/histogramRegressionLine.js","sources":["webpack://@visactor/vseed/./src/pipeline/spec/chart/pipes/regressionLine/histogramRegressionLine.ts"],"sourcesContent":["import type { ICartesianSeries, IChart, IHistogramChartSpec, IVChart } from '@visactor/vchart'\nimport type { KDEEvaluator, KDEOptions } from '@visactor/vutils'\nimport { isNullish, uniqueBy } from 'remeda'\nimport { ecdf, kde } from '@visactor/vutils'\nimport { BinEndMeasureId, BinStartMeasureId } from 'src/dataReshape'\nimport type { Datum, Dimension, HistogramRegressionLine, SpecPipe, Encoding } from 'src/types'\n\nconst getRegressionByType = (type: 'kde' | 'ecdf', data: number[], kdeOptions?: KDEOptions) => {\n switch (type) {\n case 'kde':\n return kde(data, kdeOptions)\n case 'ecdf':\n return ecdf(data)\n }\n}\n\nexport const histogramRegressionLine: SpecPipe = (spec, context) => {\n const result = { ...spec } as IHistogramChartSpec\n const { advancedVSeed, vseed } = context\n const { chartType, encoding = {} as Encoding, dimensions, histogramRegressionLine } = advancedVSeed\n const { dataset } = vseed\n const theme = advancedVSeed.config[chartType as 'histogram']?.histogramRegressionLine as HistogramRegressionLine\n\n if (!histogramRegressionLine) {\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 const lineList = Array.isArray(histogramRegressionLine) ? histogramRegressionLine : [histogramRegressionLine]\n\n if (!result.customMark) {\n result.customMark = []\n }\n\n lineList.forEach((line) => {\n const { color, type, lineWidth, lineDash, text, textColor, textFontSize, textFontWeight } =\n line as HistogramRegressionLine\n\n ;(result.customMark as any[]).push({\n type: 'line',\n interactive: false,\n zIndex: 500,\n style: {\n lineWidth: lineWidth ?? theme?.lineWidth,\n lineDash: lineDash ?? theme?.lineDash,\n stroke:\n color ??\n ((datum: Datum, ctx: any): string | undefined => {\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 return series.length\n ? series[0].getOption().globalScale.getScale('color')?.scale(series[0].getSeriesKeys()[0])\n : undefined\n }),\n points: (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\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 = getRegressionByType(\n type,\n simpleData,\n type === 'kde'\n ? ({\n bandwidth: Math.abs(viewData[0][BinEndMeasureId] - viewData[0][BinStartMeasureId]),\n } as KDEOptions)\n : undefined,\n )\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 =\n type === 'kde'\n ? (k: number) => {\n return scaleY.scale(k * simpleData.length * (res as KDEEvaluator).bandwidth)\n }\n : (e: number) => {\n return y0 + (y1 - y0) * e\n }\n\n //color: color ?? s.getOption().globalScale.getScale('color')?.scale(s.getSeriesKeys()[0]),\n\n return 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 },\n },\n })\n\n if (!isNullish(text)) {\n ;(result.customMark as any[]).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) => {\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 // 直方图使用的是bar系列\n if (series && series.length) {\n const s = series[0] as ICartesianSeries\n const startPoint = s.getRegion().getLayoutStartPoint()\n\n const fieldX = s.fieldX[0]\n const fieldX2 = s.fieldX2\n const scaleY = s.getYAxisHelper().getScale?.(0)\n const viewData = s.getViewData()?.latestData\n if (!dataset || !dataset.length || !viewData || !viewData.length || !scaleY) {\n return undefined\n }\n const maxX = Math.max.apply(\n null,\n (viewData as any[]).map((d: Datum) =>\n Math.max((d as any)[fieldX] as number, (d as any)[fieldX2] as number),\n ),\n )\n return startPoint.x + s.dataToPositionX({ [fieldX]: maxX })!\n }\n\n return undefined\n },\n y: (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 // 直方图使用的是bar系列\n if (series && series.length) {\n const s = series[0] as ICartesianSeries\n const startPoint = s.getRegion().getLayoutStartPoint()\n\n const fieldY = s.fieldY[0]\n const viewData = s.getViewData()?.latestData\n if (!viewData || !viewData.length) {\n return undefined\n }\n return type === 'ecdf'\n ? startPoint.y + 12\n : startPoint.y + s.dataToPositionY({ [fieldY]: viewData[viewData.length - 1]?.[fieldY] })!\n }\n\n return undefined\n },\n },\n })\n }\n })\n\n return result\n}\n"],"names":["getRegressionByType","type","data","kdeOptions","kde","ecdf","histogramRegressionLine","spec","context","result","advancedVSeed","vseed","chartType","encoding","dimensions","dataset","theme","rowColumnFields","uniqueBy","dim","item","lineList","Array","line","color","lineWidth","lineDash","text","textColor","textFontSize","textFontWeight","datum","ctx","vchart","chart","series","s","undefined","region","fieldX","scaleY","viewData","simpleData","entry","d","res","Math","BinEndMeasureId","BinStartMeasureId","N","lineData","yRange","y0","y1","scaleR","k","e","ld","isNullish","startPoint","fieldX2","maxX","fieldY"],"mappings":";;;AAOA,MAAMA,sBAAsB,CAACC,MAAsBC,MAAgBC;IACjE,OAAQF;QACN,KAAK;YACH,OAAOG,IAAIF,MAAMC;QACnB,KAAK;YACH,OAAOE,KAAKH;IAChB;AACF;AAEO,MAAMI,kDAAoC,CAACC,MAAMC;IACtD,MAAMC,SAAS;QAAE,GAAGF,IAAI;IAAC;IACzB,MAAM,EAAEG,aAAa,EAAEC,KAAK,EAAE,GAAGH;IACjC,MAAM,EAAEI,SAAS,EAAEC,WAAW,CAAC,CAAa,EAAEC,UAAU,EAAER,uBAAuB,EAAE,GAAGI;IACtF,MAAM,EAAEK,OAAO,EAAE,GAAGJ;IACpB,MAAMK,QAAQN,cAAc,MAAM,CAACE,UAAyB,EAAE;IAE9D,IAAI,CAACN,yBACH,OAAOG;IAGT,MAAMQ,kBAAkBC,SACtBJ,WAAW,MAAM,CAAC,CAACK,MAAmBA,AAAiB,UAAjBA,IAAI,QAAQ,IAAcA,AAAiB,aAAjBA,IAAI,QAAQ,GAC5E,CAACC,OAAoBA,KAAK,EAAE;IAE9B,MAAMC,WAAWC,MAAM,OAAO,CAAChB,2BAA2BA,0BAA0B;QAACA;KAAwB;IAE7G,IAAI,CAACG,OAAO,UAAU,EACpBA,OAAO,UAAU,GAAG,EAAE;IAGxBY,SAAS,OAAO,CAAC,CAACE;QAChB,MAAM,EAAEC,KAAK,EAAEvB,IAAI,EAAEwB,SAAS,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,SAAS,EAAEC,YAAY,EAAEC,cAAc,EAAE,GACvFP;QAEAd,O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AAI;wBAClC,IAAI,CAACK,YAAY,CAACA,SAAS,MAAM,EAC/B;wBAEF,OAAOxC,AAAS,WAATA,OACH0D,WAAW,CAAC,GAAG,KACfA,WAAW,CAAC,GAAGvB,EAAE,eAAe,CAAC;4BAAE,CAAC0B,OAAO,EAAErB,QAAQ,CAACA,SAAS,MAAM,GAAG,EAAE,EAAE,CAACqB,OAAO;wBAAC;oBAC3F;gBAGF;YACF;QACF;IAEJ;IAEA,OAAOrD;AACT"}
@@ -1,11 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const zHistogramRegressionLine: z.ZodObject<{
3
- type: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<"kde">, z.ZodLiteral<"ecdf">]>>>;
4
- color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
5
- lineWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
6
- lineDash: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
7
- text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
- textColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
- textFontSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
10
- textFontWeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
11
- }, z.core.$strip>;
@@ -1,17 +0,0 @@
1
- import { z } from "zod";
2
- const zHistogramRegressionLine = z.object({
3
- type: z.union([
4
- z.literal('kde'),
5
- z.literal('ecdf')
6
- ]).nullish(),
7
- color: z.string().nullish(),
8
- lineWidth: z.number().nullish(),
9
- lineDash: z.array(z.number()).nullish(),
10
- text: z.string().nullish(),
11
- textColor: z.string().nullish(),
12
- textFontSize: z.number().nullish(),
13
- textFontWeight: z.number().nullish()
14
- });
15
- export { zHistogramRegressionLine };
16
-
17
- //# sourceMappingURL=zHistogramRegressionLine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types/properties/regressionLine/zHistogramRegressionLine.js","sources":["webpack://@visactor/vseed/./src/types/properties/regressionLine/zHistogramRegressionLine.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const zHistogramRegressionLine = z.object({\n type: z.union([z.literal('kde'), z.literal('ecdf')]).nullish(),\n color: z.string().nullish(),\n lineWidth: z.number().nullish(),\n lineDash: z.array(z.number()).nullish(),\n text: z.string().nullish(),\n textColor: z.string().nullish(),\n textFontSize: z.number().nullish(),\n textFontWeight: z.number().nullish(),\n})\n"],"names":["zHistogramRegressionLine","z"],"mappings":";AAEO,MAAMA,2BAA2BC,EAAE,MAAM,CAAC;IAC/C,MAAMA,EAAE,KAAK,CAAC;QAACA,EAAE,OAAO,CAAC;QAAQA,EAAE,OAAO,CAAC;KAAQ,EAAE,OAAO;IAC5D,OAAOA,EAAE,MAAM,GAAG,OAAO;IACzB,WAAWA,EAAE,MAAM,GAAG,OAAO;IAC7B,UAAUA,EAAE,KAAK,CAACA,EAAE,MAAM,IAAI,OAAO;IACrC,MAAMA,EAAE,MAAM,GAAG,OAAO;IACxB,WAAWA,EAAE,MAAM,GAAG,OAAO;IAC7B,cAAcA,EAAE,MAAM,GAAG,OAAO;IAChC,gBAAgBA,EAAE,MAAM,GAAG,OAAO;AACpC"}