@antv/g2plot 2.4.19 → 2.4.22

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 (208) hide show
  1. package/CHANGELOG.md +1626 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/dist/g2plot.min.js +2 -2
  5. package/dist/g2plot.min.js.map +1 -1
  6. package/esm/adaptor/brush.js +2 -3
  7. package/esm/adaptor/brush.js.map +1 -1
  8. package/esm/adaptor/common.js +2 -11
  9. package/esm/adaptor/common.js.map +1 -1
  10. package/esm/adaptor/geometries/base.d.ts +2 -2
  11. package/esm/adaptor/geometries/base.js +3 -1
  12. package/esm/adaptor/geometries/base.js.map +1 -1
  13. package/esm/adaptor/pattern.d.ts +1 -1
  14. package/esm/index.d.ts +1 -1
  15. package/esm/index.js +1 -1
  16. package/esm/index.js.map +1 -1
  17. package/esm/interactions/brush.d.ts +18 -6
  18. package/esm/interactions/brush.js +35 -25
  19. package/esm/interactions/brush.js.map +1 -1
  20. package/esm/plots/box/adaptor.js +2 -2
  21. package/esm/plots/box/adaptor.js.map +1 -1
  22. package/esm/plots/chord/adaptor.js +2 -13
  23. package/esm/plots/chord/adaptor.js.map +1 -1
  24. package/esm/plots/chord/constant.d.ts +4 -4
  25. package/esm/plots/chord/constant.js +4 -4
  26. package/esm/plots/chord/constant.js.map +1 -1
  27. package/esm/plots/column/adaptor.js +3 -1
  28. package/esm/plots/column/adaptor.js.map +1 -1
  29. package/esm/plots/facet/types.d.ts +1 -2
  30. package/esm/plots/facet/types.js.map +1 -1
  31. package/esm/plots/facet/utils.js +2 -11
  32. package/esm/plots/facet/utils.js.map +1 -1
  33. package/esm/plots/funnel/adaptor.d.ts +5 -0
  34. package/esm/plots/funnel/adaptor.js +31 -2
  35. package/esm/plots/funnel/adaptor.js.map +1 -1
  36. package/esm/plots/funnel/geometries/basic.d.ts +5 -0
  37. package/esm/plots/funnel/geometries/basic.js +8 -4
  38. package/esm/plots/funnel/geometries/basic.js.map +1 -1
  39. package/esm/plots/funnel/geometries/common.d.ts +1 -0
  40. package/esm/plots/funnel/geometries/common.js +5 -2
  41. package/esm/plots/funnel/geometries/common.js.map +1 -1
  42. package/esm/plots/funnel/geometries/compare.d.ts +1 -0
  43. package/esm/plots/funnel/geometries/compare.js +37 -30
  44. package/esm/plots/funnel/geometries/compare.js.map +1 -1
  45. package/esm/plots/funnel/index.d.ts +1 -0
  46. package/esm/plots/funnel/index.js +1 -0
  47. package/esm/plots/funnel/index.js.map +1 -1
  48. package/esm/plots/funnel/interactions/funnel-conversion-tag.d.ts +9 -0
  49. package/esm/plots/funnel/interactions/funnel-conversion-tag.js +57 -0
  50. package/esm/plots/funnel/interactions/funnel-conversion-tag.js.map +1 -0
  51. package/esm/plots/funnel/interactions/index.d.ts +5 -0
  52. package/esm/plots/funnel/interactions/index.js +10 -0
  53. package/esm/plots/funnel/interactions/index.js.map +1 -0
  54. package/esm/plots/funnel/types.d.ts +1 -0
  55. package/esm/plots/funnel/types.js.map +1 -1
  56. package/esm/plots/gauge/utils.js +6 -5
  57. package/esm/plots/gauge/utils.js.map +1 -1
  58. package/esm/plots/heatmap/adaptor.js +9 -11
  59. package/esm/plots/heatmap/adaptor.js.map +1 -1
  60. package/esm/plots/histogram/adaptor.js +3 -0
  61. package/esm/plots/histogram/adaptor.js.map +1 -1
  62. package/esm/plots/pie/adaptor.js +3 -1
  63. package/esm/plots/pie/adaptor.js.map +1 -1
  64. package/esm/plots/pie/types.d.ts +6 -1
  65. package/esm/plots/pie/types.js.map +1 -1
  66. package/esm/plots/progress/adaptor.js +1 -2
  67. package/esm/plots/progress/adaptor.js.map +1 -1
  68. package/esm/plots/progress/utils.d.ts +1 -0
  69. package/esm/plots/progress/utils.js +4 -1
  70. package/esm/plots/progress/utils.js.map +1 -1
  71. package/esm/plots/sankey/adaptor.js +2 -11
  72. package/esm/plots/sankey/adaptor.js.map +1 -1
  73. package/esm/plots/stock/utils.d.ts +3 -1
  74. package/esm/plots/stock/utils.js +4 -2
  75. package/esm/plots/stock/utils.js.map +1 -1
  76. package/esm/plots/violin/adaptor.js +2 -10
  77. package/esm/plots/violin/adaptor.js.map +1 -1
  78. package/esm/types/common.d.ts +4 -3
  79. package/esm/types/common.js.map +1 -1
  80. package/esm/types/interaction.d.ts +5 -0
  81. package/esm/types/interaction.js.map +1 -1
  82. package/esm/utils/conversion.js +4 -3
  83. package/esm/utils/conversion.js.map +1 -1
  84. package/esm/utils/index.d.ts +1 -0
  85. package/esm/utils/index.js +1 -0
  86. package/esm/utils/index.js.map +1 -1
  87. package/esm/utils/view.d.ts +8 -1
  88. package/esm/utils/view.js +27 -0
  89. package/esm/utils/view.js.map +1 -1
  90. package/lib/adaptor/brush.js +2 -3
  91. package/lib/adaptor/brush.js.map +1 -1
  92. package/lib/adaptor/common.js +1 -10
  93. package/lib/adaptor/common.js.map +1 -1
  94. package/lib/adaptor/geometries/base.d.ts +2 -2
  95. package/lib/adaptor/geometries/base.js +3 -1
  96. package/lib/adaptor/geometries/base.js.map +1 -1
  97. package/lib/adaptor/pattern.d.ts +1 -1
  98. package/lib/index.d.ts +1 -1
  99. package/lib/index.js +1 -1
  100. package/lib/index.js.map +1 -1
  101. package/lib/interactions/brush.d.ts +18 -6
  102. package/lib/interactions/brush.js +35 -25
  103. package/lib/interactions/brush.js.map +1 -1
  104. package/lib/plots/box/adaptor.js +1 -1
  105. package/lib/plots/box/adaptor.js.map +1 -1
  106. package/lib/plots/chord/adaptor.js +1 -12
  107. package/lib/plots/chord/adaptor.js.map +1 -1
  108. package/lib/plots/chord/constant.d.ts +4 -4
  109. package/lib/plots/chord/constant.js +4 -4
  110. package/lib/plots/chord/constant.js.map +1 -1
  111. package/lib/plots/column/adaptor.js +3 -1
  112. package/lib/plots/column/adaptor.js.map +1 -1
  113. package/lib/plots/facet/types.d.ts +1 -2
  114. package/lib/plots/facet/types.js.map +1 -1
  115. package/lib/plots/facet/utils.js +1 -10
  116. package/lib/plots/facet/utils.js.map +1 -1
  117. package/lib/plots/funnel/adaptor.d.ts +5 -0
  118. package/lib/plots/funnel/adaptor.js +32 -2
  119. package/lib/plots/funnel/adaptor.js.map +1 -1
  120. package/lib/plots/funnel/geometries/basic.d.ts +5 -0
  121. package/lib/plots/funnel/geometries/basic.js +8 -3
  122. package/lib/plots/funnel/geometries/basic.js.map +1 -1
  123. package/lib/plots/funnel/geometries/common.d.ts +1 -0
  124. package/lib/plots/funnel/geometries/common.js +6 -3
  125. package/lib/plots/funnel/geometries/common.js.map +1 -1
  126. package/lib/plots/funnel/geometries/compare.d.ts +1 -0
  127. package/lib/plots/funnel/geometries/compare.js +38 -30
  128. package/lib/plots/funnel/geometries/compare.js.map +1 -1
  129. package/lib/plots/funnel/index.d.ts +1 -0
  130. package/lib/plots/funnel/index.js +1 -0
  131. package/lib/plots/funnel/index.js.map +1 -1
  132. package/lib/plots/funnel/interactions/funnel-conversion-tag.d.ts +9 -0
  133. package/lib/plots/funnel/interactions/funnel-conversion-tag.js +60 -0
  134. package/lib/plots/funnel/interactions/funnel-conversion-tag.js.map +1 -0
  135. package/lib/plots/funnel/interactions/index.d.ts +5 -0
  136. package/lib/plots/funnel/interactions/index.js +13 -0
  137. package/lib/plots/funnel/interactions/index.js.map +1 -0
  138. package/lib/plots/funnel/types.d.ts +1 -0
  139. package/lib/plots/funnel/types.js.map +1 -1
  140. package/lib/plots/gauge/utils.js +5 -4
  141. package/lib/plots/gauge/utils.js.map +1 -1
  142. package/lib/plots/heatmap/adaptor.js +8 -10
  143. package/lib/plots/heatmap/adaptor.js.map +1 -1
  144. package/lib/plots/histogram/adaptor.js +3 -0
  145. package/lib/plots/histogram/adaptor.js.map +1 -1
  146. package/lib/plots/pie/adaptor.js +3 -1
  147. package/lib/plots/pie/adaptor.js.map +1 -1
  148. package/lib/plots/pie/types.d.ts +6 -1
  149. package/lib/plots/pie/types.js.map +1 -1
  150. package/lib/plots/progress/adaptor.js +1 -2
  151. package/lib/plots/progress/adaptor.js.map +1 -1
  152. package/lib/plots/progress/utils.d.ts +1 -0
  153. package/lib/plots/progress/utils.js +4 -1
  154. package/lib/plots/progress/utils.js.map +1 -1
  155. package/lib/plots/sankey/adaptor.js +2 -11
  156. package/lib/plots/sankey/adaptor.js.map +1 -1
  157. package/lib/plots/stock/utils.d.ts +3 -1
  158. package/lib/plots/stock/utils.js +4 -2
  159. package/lib/plots/stock/utils.js.map +1 -1
  160. package/lib/plots/violin/adaptor.js +2 -10
  161. package/lib/plots/violin/adaptor.js.map +1 -1
  162. package/lib/types/common.d.ts +4 -3
  163. package/lib/types/common.js.map +1 -1
  164. package/lib/types/interaction.d.ts +5 -0
  165. package/lib/types/interaction.js.map +1 -1
  166. package/lib/utils/conversion.js +4 -3
  167. package/lib/utils/conversion.js.map +1 -1
  168. package/lib/utils/index.d.ts +1 -0
  169. package/lib/utils/index.js +2 -0
  170. package/lib/utils/index.js.map +1 -1
  171. package/lib/utils/view.d.ts +8 -1
  172. package/lib/utils/view.js +29 -1
  173. package/lib/utils/view.js.map +1 -1
  174. package/package.json +4 -2
  175. package/src/adaptor/brush.ts +2 -2
  176. package/src/adaptor/common.ts +2 -11
  177. package/src/adaptor/geometries/base.ts +5 -3
  178. package/src/index.ts +1 -1
  179. package/src/interactions/brush.ts +38 -25
  180. package/src/plots/box/adaptor.ts +2 -2
  181. package/src/plots/chord/adaptor.ts +2 -14
  182. package/src/plots/chord/constant.ts +4 -4
  183. package/src/plots/column/adaptor.ts +3 -1
  184. package/src/plots/facet/types.ts +1 -1
  185. package/src/plots/facet/utils.ts +4 -12
  186. package/src/plots/funnel/adaptor.ts +32 -2
  187. package/src/plots/funnel/geometries/basic.ts +10 -5
  188. package/src/plots/funnel/geometries/common.ts +6 -3
  189. package/src/plots/funnel/geometries/compare.ts +50 -41
  190. package/src/plots/funnel/index.ts +1 -0
  191. package/src/plots/funnel/interactions/funnel-conversion-tag.ts +57 -0
  192. package/src/plots/funnel/interactions/index.ts +11 -0
  193. package/src/plots/funnel/types.ts +1 -0
  194. package/src/plots/gauge/utils.ts +5 -4
  195. package/src/plots/heatmap/adaptor.ts +10 -11
  196. package/src/plots/histogram/adaptor.ts +2 -0
  197. package/src/plots/pie/adaptor.ts +3 -1
  198. package/src/plots/pie/types.ts +6 -1
  199. package/src/plots/progress/adaptor.ts +1 -2
  200. package/src/plots/progress/utils.ts +4 -1
  201. package/src/plots/sankey/adaptor.ts +2 -11
  202. package/src/plots/stock/utils.ts +4 -3
  203. package/src/plots/violin/adaptor.ts +2 -11
  204. package/src/types/common.ts +5 -3
  205. package/src/types/interaction.ts +6 -0
  206. package/src/utils/conversion.ts +6 -3
  207. package/src/utils/index.ts +1 -0
  208. package/src/utils/view.ts +34 -1
@@ -34,6 +34,8 @@ Object.defineProperty(exports, "measureTextWidth", { enumerable: true, get: func
34
34
  var number_1 = require("./number");
35
35
  Object.defineProperty(exports, "isBetween", { enumerable: true, get: function () { return number_1.isBetween; } });
36
36
  Object.defineProperty(exports, "isRealNumber", { enumerable: true, get: function () { return number_1.isRealNumber; } });
37
+ var view_2 = require("./view");
38
+ Object.defineProperty(exports, "addViewAnimation", { enumerable: true, get: function () { return view_2.addViewAnimation; } });
37
39
  tslib_1.__exportStar(require("./data"), exports);
38
40
  tslib_1.__exportStar(require("./padding"), exports);
39
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,yCAAoD;AAA3C,gGAAA,GAAG,OAAA;AAAE,sGAAA,SAAS,OAAA;AAAE,kGAAA,KAAK,OAAA;AAC9B,6BAAyC;AAAhC,uGAAA,gBAAgB,OAAA;AACzB,qDAA2B;AAC3B,+BAAiE;AAAxD,oGAAA,YAAY,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAAE,uGAAA,eAAe,OAAA;AAChD,iCAAyC;AAAhC,uGAAA,cAAc,OAAA;AACvB,+BAAuC;AAA9B,qGAAA,aAAa,OAAA;AACtB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,yCAAoE;AAA3D,4GAAA,eAAe,OAAA;AAAE,iHAAA,oBAAoB,OAAA;AAC9C,+CAAkD;AAAzC,gHAAA,gBAAgB,OAAA;AACzB,mCAAmD;AAA1C,mGAAA,SAAS,OAAA;AAAE,sGAAA,YAAY,OAAA;AAChC,iDAAuB;AACvB,oDAA0B","sourcesContent":["export { flow } from './flow';\nexport { pick } from './pick';\nexport { template } from './template';\nexport { log, invariant, LEVEL } from './invariant';\nexport { getContainerSize } from './dom';\nexport * from './geometry';\nexport { findViewById, getViews, getSiblingViews } from './view';\nexport { transformLabel } from './label';\nexport { getSplinePath } from './path';\nexport { deepAssign } from './deep-assign';\nexport { kebabCase } from './kebab-case';\nexport { renderStatistic, renderGaugeStatistic } from './statistic';\nexport { measureTextWidth } from './measure-text';\nexport { isBetween, isRealNumber } from './number';\nexport * from './data';\nexport * from './padding';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,yCAAoD;AAA3C,gGAAA,GAAG,OAAA;AAAE,sGAAA,SAAS,OAAA;AAAE,kGAAA,KAAK,OAAA;AAC9B,6BAAyC;AAAhC,uGAAA,gBAAgB,OAAA;AACzB,qDAA2B;AAC3B,+BAAiE;AAAxD,oGAAA,YAAY,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAAE,uGAAA,eAAe,OAAA;AAChD,iCAAyC;AAAhC,uGAAA,cAAc,OAAA;AACvB,+BAAuC;AAA9B,qGAAA,aAAa,OAAA;AACtB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,yCAAoE;AAA3D,4GAAA,eAAe,OAAA;AAAE,iHAAA,oBAAoB,OAAA;AAC9C,+CAAkD;AAAzC,gHAAA,gBAAgB,OAAA;AACzB,mCAAmD;AAA1C,mGAAA,SAAS,OAAA;AAAE,sGAAA,YAAY,OAAA;AAChC,+BAA0C;AAAjC,wGAAA,gBAAgB,OAAA;AACzB,iDAAuB;AACvB,oDAA0B","sourcesContent":["export { flow } from './flow';\nexport { pick } from './pick';\nexport { template } from './template';\nexport { log, invariant, LEVEL } from './invariant';\nexport { getContainerSize } from './dom';\nexport * from './geometry';\nexport { findViewById, getViews, getSiblingViews } from './view';\nexport { transformLabel } from './label';\nexport { getSplinePath } from './path';\nexport { deepAssign } from './deep-assign';\nexport { kebabCase } from './kebab-case';\nexport { renderStatistic, renderGaugeStatistic } from './statistic';\nexport { measureTextWidth } from './measure-text';\nexport { isBetween, isRealNumber } from './number';\nexport { addViewAnimation } from './view';\nexport * from './data';\nexport * from './padding';\n"]}
@@ -1,4 +1,5 @@
1
- import { View } from '@antv/g2';
1
+ import { Geometry, View, Types } from '@antv/g2';
2
+ import { Options } from '../types';
2
3
  /**
3
4
  * 在 Chart 中查找特定 id 的子 View
4
5
  * @param chart
@@ -19,3 +20,9 @@ export declare function getViews(view: View): View[];
19
20
  * @ignore
20
21
  */
21
22
  export declare function getSiblingViews(view: View): View[];
23
+ /**
24
+ * 所有的 Geometries 都使用同一动画(各个图形如有区别,自行覆盖)并添加处理动画回调
25
+ * @param view View
26
+ * @param animation 动画配置
27
+ */
28
+ export declare function addViewAnimation(view: View, animation: Options['animation'], geometries?: Geometry<Types.ShapePoint>[]): void;
package/lib/utils/view.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSiblingViews = exports.getViews = exports.findViewById = void 0;
3
+ exports.addViewAnimation = exports.getSiblingViews = exports.getViews = exports.findViewById = void 0;
4
+ var util_1 = require("@antv/util");
4
5
  /**
5
6
  * 在 Chart 中查找特定 id 的子 View
6
7
  * @param chart
@@ -31,4 +32,31 @@ function getSiblingViews(view) {
31
32
  return getViews(view).filter(function (sub) { return sub !== view; });
32
33
  }
33
34
  exports.getSiblingViews = getSiblingViews;
35
+ /**
36
+ * 所有的 Geometries 都使用同一动画(各个图形如有区别,自行覆盖)并添加处理动画回调
37
+ * @param view View
38
+ * @param animation 动画配置
39
+ */
40
+ function addViewAnimation(view, animation, geometries) {
41
+ if (geometries === void 0) { geometries = view.geometries; }
42
+ // 同时设置整个 view 动画选项
43
+ if (typeof animation === 'boolean') {
44
+ view.animate(animation);
45
+ }
46
+ else {
47
+ view.animate(true);
48
+ }
49
+ // 所有的 Geometry 都使用同一动画(各个图形如有区别,自行覆盖)
50
+ util_1.each(geometries, function (g) {
51
+ var animationCfg;
52
+ if (util_1.isFunction(animation)) {
53
+ animationCfg = animation(g.type || g.shapeType, g) || true;
54
+ }
55
+ else {
56
+ animationCfg = animation;
57
+ }
58
+ g.animate(animationCfg);
59
+ });
60
+ }
61
+ exports.addViewAnimation = addViewAnimation;
34
62
  //# sourceMappingURL=view.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/utils/view.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,SAAgB,YAAY,CAAC,KAAW,EAAE,EAAU;IAClD,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,UAAC,IAAU,IAAK,OAAA,IAAI,CAAC,EAAE,KAAK,EAAE,EAAd,CAAc,CAAC,CAAC;AAC1D,CAAC;AAFD,oCAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAU;IACjC,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC;AAHD,4BAGC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,IAAU;IACxC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,KAAK,IAAI,EAAZ,CAAY,CAAC,CAAC;AACtD,CAAC;AAFD,0CAEC","sourcesContent":["import { View } from '@antv/g2';\n\n/**\n * 在 Chart 中查找特定 id 的子 View\n * @param chart\n * @param id\n */\nexport function findViewById(chart: View, id: string): View {\n return chart.views.find((view: View) => view.id === id);\n}\n\n/**\n * 获取同 view 同一级的所有 views\n * @param view 当前 view\n * @returns 同一级的 views\n * @ignore\n */\nexport function getViews(view: View): View[] {\n const parent = view.parent;\n return parent ? parent.views : [];\n}\n\n/**\n * 获取同 view 同一级的 views,不包括自身\n * @param view 当前 view\n * @returns 同一级的 views\n * @ignore\n */\nexport function getSiblingViews(view: View): View[] {\n return getViews(view).filter((sub) => sub !== view);\n}\n"]}
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/utils/view.ts"],"names":[],"mappings":";;;AACA,mCAA8C;AAI9C;;;;GAIG;AACH,SAAgB,YAAY,CAAC,KAAW,EAAE,EAAU;IAClD,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,UAAC,IAAU,IAAK,OAAA,IAAI,CAAC,EAAE,KAAK,EAAE,EAAd,CAAc,CAAC,CAAC;AAC1D,CAAC;AAFD,oCAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAU;IACjC,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC;AAHD,4BAGC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,IAAU;IACxC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,KAAK,IAAI,EAAZ,CAAY,CAAC,CAAC;AACtD,CAAC;AAFD,0CAEC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAC9B,IAAU,EACV,SAA+B,EAC/B,UAA0D;IAA1D,2BAAA,EAAA,aAA2C,IAAI,CAAC,UAAU;IAE1D,mBAAmB;IACnB,IAAI,OAAO,SAAS,KAAK,SAAS,EAAE;QAClC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;KACzB;SAAM;QACL,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACpB;IAED,sCAAsC;IACtC,WAAI,CAAC,UAAU,EAAE,UAAC,CAAW;QAC3B,IAAI,YAAY,CAAC;QACjB,IAAI,iBAAU,CAAC,SAAS,CAAC,EAAE;YACzB,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC;SAC5D;aAAM;YACL,YAAY,GAAG,SAAS,CAAC;SAC1B;QAED,CAAC,CAAC,OAAO,CAAC,YAAyB,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAvBD,4CAuBC","sourcesContent":["import { Geometry, View, Types } from '@antv/g2';\nimport { each, isFunction } from '@antv/util';\nimport { Options } from '../types';\nimport { Animation } from '../types/animation';\n\n/**\n * 在 Chart 中查找特定 id 的子 View\n * @param chart\n * @param id\n */\nexport function findViewById(chart: View, id: string): View {\n return chart.views.find((view: View) => view.id === id);\n}\n\n/**\n * 获取同 view 同一级的所有 views\n * @param view 当前 view\n * @returns 同一级的 views\n * @ignore\n */\nexport function getViews(view: View): View[] {\n const parent = view.parent;\n return parent ? parent.views : [];\n}\n\n/**\n * 获取同 view 同一级的 views,不包括自身\n * @param view 当前 view\n * @returns 同一级的 views\n * @ignore\n */\nexport function getSiblingViews(view: View): View[] {\n return getViews(view).filter((sub) => sub !== view);\n}\n\n/**\n * 所有的 Geometries 都使用同一动画(各个图形如有区别,自行覆盖)并添加处理动画回调\n * @param view View\n * @param animation 动画配置\n */\nexport function addViewAnimation(\n view: View,\n animation: Options['animation'],\n geometries: Geometry<Types.ShapePoint>[] = view.geometries\n) {\n // 同时设置整个 view 动画选项\n if (typeof animation === 'boolean') {\n view.animate(animation);\n } else {\n view.animate(true);\n }\n\n // 所有的 Geometry 都使用同一动画(各个图形如有区别,自行覆盖)\n each(geometries, (g: Geometry) => {\n let animationCfg;\n if (isFunction(animation)) {\n animationCfg = animation(g.type || g.shapeType, g) || true;\n } else {\n animationCfg = animation;\n }\n\n g.animate(animationCfg as Animation);\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g2plot",
3
- "version": "2.4.19",
3
+ "version": "2.4.22",
4
4
  "description": "An interactive and responsive charting library",
5
5
  "keywords": [
6
6
  "chart",
@@ -160,6 +160,8 @@
160
160
  "monaco-editor": "0.21.3",
161
161
  "@babel/plugin-transform-spread": "7.12.1",
162
162
  "@babel/standalone": "7.12.6",
163
- "d3-array": "2.12.1"
163
+ "d3-array": "2.12.1",
164
+ "remark-mdx": "1.6.22",
165
+ "@types/lodash": "4.14.182"
164
166
  }
165
167
  }
@@ -39,8 +39,8 @@ export function brushInteraction<O extends Options = Options>(params: Params<O>)
39
39
  }
40
40
  const obj: Writable<Interaction> = { type, enable };
41
41
 
42
- if (brush.mask?.style || brush.type) {
43
- obj.cfg = getInteractionCfg(type, brush.type, brush.mask);
42
+ if (brush) {
43
+ obj.cfg = getInteractionCfg(type, brush.type, brush);
44
44
  }
45
45
  interactions.push(obj);
46
46
  });
@@ -6,7 +6,7 @@ import { Interaction } from '../types/interaction';
6
6
  import { Transformations } from '../types/coordinate';
7
7
  import { Axis } from '../types/axis';
8
8
  import { AXIS_META_CONFIG_KEYS } from '../constant';
9
- import { pick, deepAssign } from '../utils';
9
+ import { pick, deepAssign, addViewAnimation } from '../utils';
10
10
 
11
11
  /**
12
12
  * 通用 legend 配置, 适用于带 colorField 或 seriesField 的图表
@@ -69,17 +69,8 @@ export function animation<O extends Pick<Options, 'animation'>>(params: Params<O
69
69
  const { chart, options } = params;
70
70
  const { animation } = options;
71
71
 
72
- // 同时设置整个 view 动画选项
73
- if (typeof animation === 'boolean') {
74
- chart.animate(animation);
75
- } else {
76
- chart.animate(true);
77
- }
78
-
79
72
  // 所有的 Geometry 都使用同一动画(各个图形如有区别,自行覆盖)
80
- each(chart.geometries, (g: Geometry) => {
81
- g.animate(animation);
82
- });
73
+ addViewAnimation(chart, animation);
83
74
 
84
75
  return params;
85
76
  }
@@ -1,6 +1,6 @@
1
1
  import { uniq, isFunction, isObject, isString, isNumber, isEmpty } from '@antv/util';
2
2
  import { Params } from '../../core/adaptor';
3
- import { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum } from '../../types';
3
+ import { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum, RawFields } from '../../types';
4
4
  import { Label } from '../../types/label';
5
5
  import { State } from '../../types/state';
6
6
  import { transformLabel } from '../../utils';
@@ -43,7 +43,7 @@ export type Geometry = {
43
43
  /** tooltip 的映射字段 */
44
44
  readonly tooltipFields?: string[] | false;
45
45
  /** 其他原始字段, 用于 mapping 回调参数 */
46
- readonly rawFields?: string[];
46
+ readonly rawFields?: RawFields;
47
47
  /** 图形映射规则 */
48
48
  readonly mapping?: MappingOptions;
49
49
  /** label 映射通道,因为历史原因导致实现略有区别 */
@@ -73,9 +73,11 @@ export function getMappingField(
73
73
  mappingFields: string[];
74
74
  tileMappingField: string;
75
75
  } {
76
- const { type, xField, yField, colorField, shapeField, sizeField, styleField, rawFields = [] } = o;
76
+ const { type, xField, yField, colorField, shapeField, sizeField, styleField } = o;
77
+ let { rawFields } = o;
77
78
 
78
79
  let fields = [];
80
+ rawFields = (isFunction(rawFields) ? rawFields(type, field) : rawFields) || [];
79
81
 
80
82
  // 因为 color 会影响到数据分组,以及最后的图形映射。所以导致 bar 图中的 widthRatio 设置不生效
81
83
  // 所以对于 color 字段,仅仅保留 colorField 好了! + rawFields
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '2.4.19';
1
+ export const version = '2.4.22';
2
2
 
3
3
  // G2 自定义能力透出
4
4
  import * as G2 from '@antv/g2';
@@ -22,20 +22,21 @@ function isPointInView(context) {
22
22
  /**
23
23
  * 获取 交互 start 阶段的相关配置
24
24
  */
25
- export function getInteractionCfg(interactionType: string, brushType?: string, mask?: BrushCfg['mask']) {
25
+ export function getInteractionCfg(interactionType: string, brushType?: string, options?: BrushCfg) {
26
+ const { mask, isStartEnable } = options || {};
26
27
  const maskType = brushType || 'rect';
27
28
 
28
29
  switch (interactionType) {
29
30
  case 'brush':
30
31
  return {
31
32
  showEnable: [
32
- { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
33
+ { trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (() => true) },
33
34
  { trigger: 'plot:mouseleave', action: 'cursor:default' },
34
35
  ],
35
36
  start: [
36
37
  {
37
38
  trigger: 'mousedown',
38
- isEnable: isPointInView,
39
+ isEnable: isStartEnable || isPointInView,
39
40
  action: ['brush:start', `${maskType}-mask:start`, `${maskType}-mask:show`],
40
41
  // 对应第二个action的参数
41
42
  arg: [null, { maskStyle: mask?.style }],
@@ -71,18 +72,26 @@ export function getInteractionCfg(interactionType: string, brushType?: string, m
71
72
  case 'brush-highlight':
72
73
  return {
73
74
  showEnable: [
74
- { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
75
- { trigger: 'mask:mouseenter', action: 'cursor:move' },
75
+ { trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (() => true) },
76
+ { trigger: 'plot:mousemove', action: 'cursor:crosshair', isEnable: isStartEnable || (() => true) },
77
+ {
78
+ trigger: 'plot:mousemove',
79
+ action: 'cursor:default',
80
+ isEnable: (context) => (isStartEnable ? !isStartEnable(context) : false),
81
+ },
82
+ { trigger: 'mask:mouseenter', action: 'cursor:move', isEnable: isStartEnable || (() => true) },
76
83
  { trigger: 'plot:mouseleave', action: 'cursor:default' },
77
84
  { trigger: 'mask:mouseleave', action: 'cursor:crosshair' },
78
85
  ],
79
86
  start: [
80
87
  {
81
88
  trigger: 'plot:mousedown',
82
- isEnable(context) {
83
- // 不要点击在 mask 上重新开始
84
- return !context.isInShape('mask');
85
- },
89
+ isEnable:
90
+ isStartEnable ||
91
+ ((context) => {
92
+ // 不要点击在 mask 上重新开始
93
+ return !context.isInShape('mask');
94
+ }),
86
95
  action: [`${maskType}-mask:start`, `${maskType}-mask:show`],
87
96
  // 对应第 1 个action的参数
88
97
  arg: [{ maskStyle: mask?.style }],
@@ -122,13 +131,13 @@ export function getInteractionCfg(interactionType: string, brushType?: string, m
122
131
  case 'brush-x':
123
132
  return {
124
133
  showEnable: [
125
- { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
134
+ { trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (() => true) },
126
135
  { trigger: 'plot:mouseleave', action: 'cursor:default' },
127
136
  ],
128
137
  start: [
129
138
  {
130
139
  trigger: 'mousedown',
131
- isEnable: isPointInView,
140
+ isEnable: isStartEnable || isPointInView,
132
141
  action: ['brush-x:start', `${maskType}-mask:start`, `${maskType}-mask:show`],
133
142
  // 对应第二个action的参数
134
143
  arg: [null, { maskStyle: mask?.style }],
@@ -153,18 +162,20 @@ export function getInteractionCfg(interactionType: string, brushType?: string, m
153
162
  case 'brush-x-highlight':
154
163
  return {
155
164
  showEnable: [
156
- { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
157
- { trigger: 'mask:mouseenter', action: 'cursor:move' },
165
+ { trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (() => true) },
166
+ { trigger: 'mask:mouseenter', action: 'cursor:move', isEnable: isStartEnable || (() => true) },
158
167
  { trigger: 'plot:mouseleave', action: 'cursor:default' },
159
168
  { trigger: 'mask:mouseleave', action: 'cursor:crosshair' },
160
169
  ],
161
170
  start: [
162
171
  {
163
172
  trigger: 'plot:mousedown',
164
- isEnable(context) {
165
- // 不要点击在 mask 上重新开始
166
- return !context.isInShape('mask');
167
- },
173
+ isEnable:
174
+ isStartEnable ||
175
+ ((context) => {
176
+ // 不要点击在 mask 上重新开始
177
+ return !context.isInShape('mask');
178
+ }),
168
179
  action: [`${maskType}-mask:start`, `${maskType}-mask:show`],
169
180
  // 对应第 1 个action的参数
170
181
  arg: [{ maskStyle: mask?.style }],
@@ -204,13 +215,13 @@ export function getInteractionCfg(interactionType: string, brushType?: string, m
204
215
  case 'brush-y':
205
216
  return {
206
217
  showEnable: [
207
- { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
218
+ { trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (() => true) },
208
219
  { trigger: 'plot:mouseleave', action: 'cursor:default' },
209
220
  ],
210
221
  start: [
211
222
  {
212
223
  trigger: 'mousedown',
213
- isEnable: isPointInView,
224
+ isEnable: isStartEnable || isPointInView,
214
225
  action: ['brush-y:start', `${maskType}-mask:start`, `${maskType}-mask:show`],
215
226
  // 对应第二个action的参数
216
227
  arg: [null, { maskStyle: mask?.style }],
@@ -235,18 +246,20 @@ export function getInteractionCfg(interactionType: string, brushType?: string, m
235
246
  case 'brush-y-highlight':
236
247
  return {
237
248
  showEnable: [
238
- { trigger: 'plot:mouseenter', action: 'cursor:crosshair' },
239
- { trigger: 'mask:mouseenter', action: 'cursor:move' },
249
+ { trigger: 'plot:mouseenter', action: 'cursor:crosshair', isEnable: isStartEnable || (() => true) },
250
+ { trigger: 'mask:mouseenter', action: 'cursor:move', isEnable: isStartEnable || (() => true) },
240
251
  { trigger: 'plot:mouseleave', action: 'cursor:default' },
241
252
  { trigger: 'mask:mouseleave', action: 'cursor:crosshair' },
242
253
  ],
243
254
  start: [
244
255
  {
245
256
  trigger: 'plot:mousedown',
246
- isEnable(context) {
247
- // 不要点击在 mask 上重新开始
248
- return !context.isInShape('mask');
249
- },
257
+ isEnable:
258
+ isStartEnable ||
259
+ ((context) => {
260
+ // 不要点击在 mask 上重新开始
261
+ return !context.isInShape('mask');
262
+ }),
250
263
  action: [`${maskType}-mask:start`, `${maskType}-mask:show`],
251
264
  // 对应第 1 个action的参数
252
265
  arg: [{ maskStyle: mask?.style }],
@@ -1,7 +1,7 @@
1
1
  import { isArray } from '@antv/util';
2
2
  import { Types } from '@antv/g2';
3
3
  import { Params } from '../../core/adaptor';
4
- import { interaction, animation, theme, tooltip } from '../../adaptor/common';
4
+ import { interaction, animation, theme, tooltip, annotation } from '../../adaptor/common';
5
5
  import { point, schema } from '../../adaptor/geometries';
6
6
  import { flow, pick, deepAssign } from '../../utils';
7
7
  import { AXIS_META_CONFIG_KEYS } from '../../constant';
@@ -167,5 +167,5 @@ export function legend(params: Params<BoxOptions>): Params<BoxOptions> {
167
167
  * @param params
168
168
  */
169
169
  export function adaptor(params: Params<BoxOptions>) {
170
- return flow(field, outliersPoint, meta, axis, legend, tooltip, interaction, animation, theme)(params);
170
+ return flow(field, outliersPoint, meta, axis, legend, tooltip, annotation(), interaction, animation, theme)(params);
171
171
  }
@@ -1,11 +1,9 @@
1
- import { Geometry } from '@antv/g2';
2
- import { each } from '@antv/util';
3
1
  import { interaction, theme, state } from '../../adaptor/common';
4
2
  import { Params } from '../../core/adaptor';
5
3
  import { flow, pick } from '../../utils';
6
4
  import { polygon, edge } from '../../adaptor/geometries';
7
5
  import { chordLayout } from '../../utils/transform/chord';
8
- import { getAllGeometriesRecursively, transformDataToNodeLinkData } from '../../utils';
6
+ import { getAllGeometriesRecursively, transformDataToNodeLinkData, addViewAnimation } from '../../utils';
9
7
  import { ChordOptions } from './types';
10
8
  import { X_FIELD, Y_FIELD, NODE_COLOR_FIELD, EDGE_COLOR_FIELD } from './constant';
11
9
 
@@ -170,17 +168,7 @@ function animation(params: Params<ChordOptions>): Params<ChordOptions> {
170
168
  const { chart, options } = params;
171
169
  const { animation } = options;
172
170
 
173
- // 同时设置整个 view 动画选项
174
- if (typeof animation === 'boolean') {
175
- chart.animate(animation);
176
- } else {
177
- chart.animate(true);
178
- }
179
-
180
- // 所有的 Geometry 都使用同一动画(各个图形如有区别,自行覆盖)
181
- each(getAllGeometriesRecursively(chart), (g: Geometry) => {
182
- g.animate(animation);
183
- });
171
+ addViewAnimation(chart, animation, getAllGeometriesRecursively(chart));
184
172
 
185
173
  return params;
186
174
  }
@@ -22,14 +22,14 @@ export const DEFAULT_OPTIONS = {
22
22
  const centerX = (x[0] + x[1]) / 2;
23
23
  const offsetX = centerX > 0.5 ? -4 : 4;
24
24
  return {
25
- labelEmit: true,
26
- style: {
27
- fill: '#8c8c8c',
28
- },
29
25
  offsetX,
30
26
  content: name,
31
27
  };
32
28
  },
29
+ labelEmit: true,
30
+ style: {
31
+ fill: '#8c8c8c',
32
+ },
33
33
  },
34
34
  tooltip: {
35
35
  showTitle: false,
@@ -251,6 +251,7 @@ function columnTooltip(params: Params<ColumnOptions>): Params<ColumnOptions> {
251
251
  let tooltipOptions = tooltip;
252
252
  // fix: https://github.com/antvis/G2Plot/issues/2572
253
253
  if (isGroup && isStack) {
254
+ const { customItems } = tooltipOptions;
254
255
  const tooltipFormatter =
255
256
  tooltipOptions?.formatter ||
256
257
  ((datum: Datum) => ({ name: `${datum[seriesField]} - ${datum[groupField]}`, value: datum[yField] }));
@@ -271,7 +272,8 @@ function columnTooltip(params: Params<ColumnOptions>): Params<ColumnOptions> {
271
272
  });
272
273
  });
273
274
  });
274
- return items;
275
+ // fix https://github.com/antvis/G2Plot/issues/3367
276
+ return customItems ? customItems(items) : items;
275
277
  },
276
278
  };
277
279
  }
@@ -54,7 +54,7 @@ export type IView = {
54
54
  /**
55
55
  * @title animation 配置
56
56
  */
57
- readonly animation?: Animation;
57
+ readonly animation?: Options['animation'];
58
58
  /**
59
59
  * @title tooltip 配置
60
60
  */
@@ -1,9 +1,9 @@
1
- import { Geometry, View } from '@antv/g2';
1
+ import { View } from '@antv/g2';
2
2
  import { each } from '@antv/util';
3
3
  import { geometry as geometryAdaptor } from '../../adaptor/geometries/base';
4
4
  import { AXIS_META_CONFIG_KEYS } from '../../constant';
5
- import { pick, deepAssign } from '../../utils';
6
- import { Axis, Interaction } from '../../types';
5
+ import { pick, deepAssign, addViewAnimation } from '../../utils';
6
+ import { Axis, Interaction, Options } from '../../types';
7
7
  import { IView } from './types';
8
8
 
9
9
  /**
@@ -74,15 +74,7 @@ export function execViewAdaptor(viewOfG2: View, options: IView): void {
74
74
  });
75
75
 
76
76
  // 7. animation (先做动画)
77
- if (typeof animation === 'boolean') {
78
- viewOfG2.animate(false);
79
- } else {
80
- viewOfG2.animate(true);
81
- // 所有的 Geometry 都使用同一动画(各个图形如有区别,todo 自行覆盖)
82
- each(viewOfG2.geometries, (g: Geometry) => {
83
- g.animate(animation);
84
- });
85
- }
77
+ addViewAnimation(viewOfG2, animation as Options['animation']);
86
78
 
87
79
  if (tooltip) {
88
80
  // 8. tooltip
@@ -1,6 +1,6 @@
1
- import { isFunction, clone } from '@antv/util';
1
+ import { isFunction, clone, each } from '@antv/util';
2
2
  import { Params } from '../../core/adaptor';
3
- import { interaction, animation, theme, scale, annotation, tooltip } from '../../adaptor/common';
3
+ import { animation, theme, scale, annotation, tooltip } from '../../adaptor/common';
4
4
  import { getLocale } from '../../core/locale';
5
5
  import { Datum } from '../../types';
6
6
  import { flow, deepAssign } from '../../utils';
@@ -11,6 +11,8 @@ import { compareFunnel } from './geometries/compare';
11
11
  import { facetFunnel } from './geometries/facet';
12
12
  import { dynamicHeightFunnel } from './geometries/dynamic-height';
13
13
  import { FUNNEL_CONVERSATION, FUNNEL_PERCENT } from './constant';
14
+ import { interactionStart, FUNNEL_LEGEND_FILTER } from './interactions';
15
+ import type { Interaction } from './types';
14
16
 
15
17
  /**
16
18
  *
@@ -137,6 +139,34 @@ function legend(params: Params<FunnelOptions>): Params<FunnelOptions> {
137
139
  return params;
138
140
  }
139
141
 
142
+ /**
143
+ * Interaction 配置
144
+ * @param params
145
+ */
146
+ export function interaction<O extends Pick<FunnelOptions, 'interactions'>>(params: Params<O>): Params<O> {
147
+ const { chart, options } = params;
148
+ // @ts-ignore
149
+ const { interactions, dynamicHeight } = options;
150
+
151
+ each(interactions, (i: Interaction) => {
152
+ if (i.enable === false) {
153
+ chart.removeInteraction(i.type);
154
+ } else {
155
+ chart.interaction(i.type, i.cfg || {});
156
+ }
157
+ });
158
+ // 动态高度 不进行交互操作
159
+ if (!dynamicHeight) {
160
+ chart.interaction(FUNNEL_LEGEND_FILTER, {
161
+ start: [{ ...interactionStart, arg: options }],
162
+ });
163
+ } else {
164
+ chart.removeInteraction(FUNNEL_LEGEND_FILTER);
165
+ }
166
+
167
+ return params;
168
+ }
169
+
140
170
  /**
141
171
  * 漏斗图适配器
142
172
  * @param chart
@@ -1,5 +1,5 @@
1
1
  import { Types } from '@antv/g2';
2
- import { isArray } from '@antv/util';
2
+ import { isArray, get, map } from '@antv/util';
3
3
  import { flow, findGeometry } from '../../../utils';
4
4
  import { getTooltipMapping } from '../../../utils/tooltip';
5
5
  import { Params } from '../../../core/adaptor';
@@ -80,10 +80,15 @@ function transpose(params: Params<FunnelOptions>): Params<FunnelOptions> {
80
80
  * 转化率组件
81
81
  * @param params
82
82
  */
83
- function conversionTag(params: Params<FunnelOptions>): Params<FunnelOptions> {
84
- const { options } = params;
83
+ export function conversionTag(params: Params<FunnelOptions>): Params<FunnelOptions> {
84
+ const { options, chart } = params;
85
85
  const { maxSize } = options;
86
86
 
87
+ // 获取形状位置,再转化为需要的转化率位置
88
+ const dataArray = get(chart, ['geometries', '0', 'dataArray'], []);
89
+ const size = get(chart, ['options', 'data', 'length']);
90
+ const x = map(dataArray, (item) => get(item, ['0', 'nextPoints', '0', 'x']) * size - 0.5);
91
+
87
92
  const getLineCoordinate = (
88
93
  datum: Datum,
89
94
  datumIndex: number,
@@ -93,8 +98,8 @@ function conversionTag(params: Params<FunnelOptions>): Params<FunnelOptions> {
93
98
  const percent = maxSize - (maxSize - datum[FUNNEL_MAPPING_VALUE]) / 2;
94
99
  return {
95
100
  ...initLineOption,
96
- start: [datumIndex - 0.5, percent],
97
- end: [datumIndex - 0.5, percent + 0.05],
101
+ start: [x[datumIndex - 1] || datumIndex - 0.5, percent],
102
+ end: [x[datumIndex - 1] || datumIndex - 0.5, percent + 0.05],
98
103
  };
99
104
  };
100
105
 
@@ -5,6 +5,8 @@ import { FUNNEL_PERCENT, FUNNEL_CONVERSATION, FUNNEL_MAPPING_VALUE } from '../co
5
5
  import { Params } from '../../../core/adaptor';
6
6
  import { FunnelOptions } from '../types';
7
7
 
8
+ export const CONVERSION_TAG_NAME = 'CONVERSION_TAG_NAME';
9
+
8
10
  /**
9
11
  * 漏斗图 transform
10
12
  * @param geometry
@@ -47,16 +49,17 @@ export function conversionTagComponent(
47
49
  ) {
48
50
  return function (params: Params<FunnelOptions>): Params<FunnelOptions> {
49
51
  const { chart, options } = params;
50
- const { conversionTag } = options;
51
-
52
- const { data } = chart.getOptions();
52
+ // @ts-ignore
53
+ const { conversionTag, filteredData } = options;
53
54
 
55
+ const data = filteredData || chart.getOptions().data;
54
56
  if (conversionTag) {
55
57
  const { formatter } = conversionTag;
56
58
  data.forEach((obj, index) => {
57
59
  if (index <= 0 || Number.isNaN(obj[FUNNEL_MAPPING_VALUE])) return;
58
60
  const lineOption = getLineCoordinate(obj, index, data, {
59
61
  top: true,
62
+ name: CONVERSION_TAG_NAME,
60
63
  text: {
61
64
  content: isFunction(formatter) ? formatter(obj, data) : formatter,
62
65
  offsetX: conversionTag.offsetX,