@antv/g2plot 2.3.36 → 2.3.40

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 (237) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/g2plot.min.js +18 -3
  3. package/dist/g2plot.min.js.map +1 -1
  4. package/esm/adaptor/geometries/base.d.ts +2 -0
  5. package/esm/adaptor/geometries/base.js +7 -1
  6. package/esm/adaptor/geometries/base.js.map +1 -1
  7. package/esm/adaptor/geometries/index.d.ts +1 -0
  8. package/esm/adaptor/geometries/index.js.map +1 -1
  9. package/esm/adaptor/pattern.d.ts +1 -1
  10. package/esm/core/plot.d.ts +1 -1
  11. package/esm/core/plot.js +2 -2
  12. package/esm/core/plot.js.map +1 -1
  13. package/esm/index.d.ts +1 -1
  14. package/esm/index.js +1 -1
  15. package/esm/index.js.map +1 -1
  16. package/esm/interactions/actions/drill-down.d.ts +5 -1
  17. package/esm/interactions/actions/drill-down.js +12 -4
  18. package/esm/interactions/actions/drill-down.js.map +1 -1
  19. package/esm/interactions/drill-down.js +23 -0
  20. package/esm/interactions/drill-down.js.map +1 -1
  21. package/esm/plots/area/adaptor.js +5 -2
  22. package/esm/plots/area/adaptor.js.map +1 -1
  23. package/esm/plots/area/types.d.ts +2 -3
  24. package/esm/plots/area/types.js.map +1 -1
  25. package/esm/plots/bidirectional-bar/adaptor.js +45 -9
  26. package/esm/plots/bidirectional-bar/adaptor.js.map +1 -1
  27. package/esm/plots/bidirectional-bar/index.d.ts +2 -0
  28. package/esm/plots/bidirectional-bar/index.js +2 -0
  29. package/esm/plots/bidirectional-bar/index.js.map +1 -1
  30. package/esm/plots/box/adaptor.js +17 -2
  31. package/esm/plots/box/adaptor.js.map +1 -1
  32. package/esm/plots/column/adaptor.js +2 -1
  33. package/esm/plots/column/adaptor.js.map +1 -1
  34. package/esm/plots/column/types.d.ts +3 -0
  35. package/esm/plots/column/types.js.map +1 -1
  36. package/esm/plots/funnel/adaptor.js +3 -3
  37. package/esm/plots/funnel/adaptor.js.map +1 -1
  38. package/esm/plots/heatmap/adaptor.js +23 -1
  39. package/esm/plots/heatmap/adaptor.js.map +1 -1
  40. package/esm/plots/heatmap/types.d.ts +4 -2
  41. package/esm/plots/heatmap/types.js.map +1 -1
  42. package/esm/plots/line/adaptor.js +25 -4
  43. package/esm/plots/line/adaptor.js.map +1 -1
  44. package/esm/plots/line/types.d.ts +6 -2
  45. package/esm/plots/line/types.js.map +1 -1
  46. package/esm/plots/pie/interactions/{pie-legend-action.d.ts → actions/legend-active.d.ts} +0 -0
  47. package/esm/plots/pie/interactions/{pie-legend-action.js → actions/legend-active.js} +2 -2
  48. package/esm/plots/pie/interactions/actions/legend-active.js.map +1 -0
  49. package/{lib/plots/pie/interactions/pie-statistic-action.d.ts → esm/plots/pie/interactions/actions/statistic-active.d.ts} +1 -1
  50. package/esm/plots/pie/interactions/{pie-statistic-action.js → actions/statistic-active.js} +8 -2
  51. package/esm/plots/pie/interactions/actions/statistic-active.js.map +1 -0
  52. package/esm/plots/pie/interactions/index.js +2 -2
  53. package/esm/plots/pie/interactions/index.js.map +1 -1
  54. package/esm/plots/pie/interactions/util.d.ts +7 -0
  55. package/esm/plots/pie/interactions/util.js +15 -0
  56. package/esm/plots/pie/interactions/util.js.map +1 -0
  57. package/esm/plots/sankey/helper.js +16 -2
  58. package/esm/plots/sankey/helper.js.map +1 -1
  59. package/esm/plots/sankey/types.d.ts +51 -8
  60. package/esm/plots/sankey/types.js.map +1 -1
  61. package/esm/plots/sunburst/types.d.ts +3 -1
  62. package/esm/plots/sunburst/types.js.map +1 -1
  63. package/esm/plots/sunburst/utils.js +6 -1
  64. package/esm/plots/sunburst/utils.js.map +1 -1
  65. package/esm/plots/venn/adaptor.d.ts +1 -1
  66. package/esm/plots/venn/adaptor.js +53 -14
  67. package/esm/plots/venn/adaptor.js.map +1 -1
  68. package/esm/plots/venn/constant.js +22 -6
  69. package/esm/plots/venn/constant.js.map +1 -1
  70. package/esm/plots/venn/interactions/actions/active.d.ts +14 -0
  71. package/esm/plots/venn/interactions/actions/active.js +34 -0
  72. package/esm/plots/venn/interactions/actions/active.js.map +1 -0
  73. package/esm/plots/venn/interactions/actions/highlight.d.ts +16 -0
  74. package/esm/plots/venn/interactions/actions/highlight.js +39 -0
  75. package/esm/plots/venn/interactions/actions/highlight.js.map +1 -0
  76. package/esm/plots/venn/interactions/actions/selected.d.ts +33 -0
  77. package/esm/plots/venn/interactions/actions/selected.js +70 -0
  78. package/esm/plots/venn/interactions/actions/selected.js.map +1 -0
  79. package/esm/plots/venn/{interaction → interactions}/index.d.ts +0 -0
  80. package/esm/plots/venn/interactions/index.js +48 -0
  81. package/esm/plots/venn/interactions/index.js.map +1 -0
  82. package/esm/plots/venn/interactions/util.d.ts +3 -0
  83. package/esm/plots/venn/interactions/util.js +11 -0
  84. package/esm/plots/venn/interactions/util.js.map +1 -0
  85. package/esm/plots/venn/types.d.ts +2 -2
  86. package/esm/plots/venn/types.js.map +1 -1
  87. package/esm/plots/venn/utils.d.ts +3 -4
  88. package/esm/plots/venn/utils.js +2 -3
  89. package/esm/plots/venn/utils.js.map +1 -1
  90. package/esm/types/attr.d.ts +1 -1
  91. package/esm/types/attr.js.map +1 -1
  92. package/esm/types/common.d.ts +2 -0
  93. package/esm/types/common.js.map +1 -1
  94. package/lib/adaptor/geometries/base.d.ts +2 -0
  95. package/lib/adaptor/geometries/base.js +7 -1
  96. package/lib/adaptor/geometries/base.js.map +1 -1
  97. package/lib/adaptor/geometries/index.d.ts +1 -0
  98. package/lib/adaptor/geometries/index.js.map +1 -1
  99. package/lib/adaptor/pattern.d.ts +1 -1
  100. package/lib/core/plot.d.ts +1 -1
  101. package/lib/core/plot.js +2 -2
  102. package/lib/core/plot.js.map +1 -1
  103. package/lib/index.d.ts +1 -1
  104. package/lib/index.js +1 -1
  105. package/lib/index.js.map +1 -1
  106. package/lib/interactions/actions/drill-down.d.ts +5 -1
  107. package/lib/interactions/actions/drill-down.js +11 -3
  108. package/lib/interactions/actions/drill-down.js.map +1 -1
  109. package/lib/interactions/drill-down.js +23 -0
  110. package/lib/interactions/drill-down.js.map +1 -1
  111. package/lib/plots/area/adaptor.js +5 -2
  112. package/lib/plots/area/adaptor.js.map +1 -1
  113. package/lib/plots/area/types.d.ts +2 -3
  114. package/lib/plots/area/types.js.map +1 -1
  115. package/lib/plots/bidirectional-bar/adaptor.js +45 -9
  116. package/lib/plots/bidirectional-bar/adaptor.js.map +1 -1
  117. package/lib/plots/bidirectional-bar/index.d.ts +2 -0
  118. package/lib/plots/bidirectional-bar/index.js +2 -0
  119. package/lib/plots/bidirectional-bar/index.js.map +1 -1
  120. package/lib/plots/box/adaptor.js +17 -2
  121. package/lib/plots/box/adaptor.js.map +1 -1
  122. package/lib/plots/column/adaptor.js +2 -1
  123. package/lib/plots/column/adaptor.js.map +1 -1
  124. package/lib/plots/column/types.d.ts +3 -0
  125. package/lib/plots/column/types.js.map +1 -1
  126. package/lib/plots/funnel/adaptor.js +2 -2
  127. package/lib/plots/funnel/adaptor.js.map +1 -1
  128. package/lib/plots/heatmap/adaptor.js +23 -1
  129. package/lib/plots/heatmap/adaptor.js.map +1 -1
  130. package/lib/plots/heatmap/types.d.ts +4 -2
  131. package/lib/plots/heatmap/types.js.map +1 -1
  132. package/lib/plots/line/adaptor.js +23 -2
  133. package/lib/plots/line/adaptor.js.map +1 -1
  134. package/lib/plots/line/types.d.ts +6 -2
  135. package/lib/plots/line/types.js.map +1 -1
  136. package/lib/plots/pie/interactions/{pie-legend-action.d.ts → actions/legend-active.d.ts} +0 -0
  137. package/lib/plots/pie/interactions/{pie-legend-action.js → actions/legend-active.js} +2 -2
  138. package/lib/plots/pie/interactions/actions/legend-active.js.map +1 -0
  139. package/{esm/plots/pie/interactions/pie-statistic-action.d.ts → lib/plots/pie/interactions/actions/statistic-active.d.ts} +1 -1
  140. package/lib/plots/pie/interactions/{pie-statistic-action.js → actions/statistic-active.js} +8 -2
  141. package/lib/plots/pie/interactions/actions/statistic-active.js.map +1 -0
  142. package/lib/plots/pie/interactions/index.js +4 -4
  143. package/lib/plots/pie/interactions/index.js.map +1 -1
  144. package/lib/plots/pie/interactions/util.d.ts +7 -0
  145. package/lib/plots/pie/interactions/util.js +19 -0
  146. package/lib/plots/pie/interactions/util.js.map +1 -0
  147. package/lib/plots/sankey/helper.js +16 -2
  148. package/lib/plots/sankey/helper.js.map +1 -1
  149. package/lib/plots/sankey/types.d.ts +51 -8
  150. package/lib/plots/sankey/types.js.map +1 -1
  151. package/lib/plots/sunburst/types.d.ts +3 -1
  152. package/lib/plots/sunburst/types.js.map +1 -1
  153. package/lib/plots/sunburst/utils.js +6 -1
  154. package/lib/plots/sunburst/utils.js.map +1 -1
  155. package/lib/plots/venn/adaptor.d.ts +1 -1
  156. package/lib/plots/venn/adaptor.js +52 -13
  157. package/lib/plots/venn/adaptor.js.map +1 -1
  158. package/lib/plots/venn/constant.js +22 -6
  159. package/lib/plots/venn/constant.js.map +1 -1
  160. package/lib/plots/venn/interactions/actions/active.d.ts +14 -0
  161. package/lib/plots/venn/interactions/actions/active.js +37 -0
  162. package/lib/plots/venn/interactions/actions/active.js.map +1 -0
  163. package/lib/plots/venn/interactions/actions/highlight.d.ts +16 -0
  164. package/lib/plots/venn/interactions/actions/highlight.js +42 -0
  165. package/lib/plots/venn/interactions/actions/highlight.js.map +1 -0
  166. package/lib/plots/venn/interactions/actions/selected.d.ts +33 -0
  167. package/lib/plots/venn/interactions/actions/selected.js +73 -0
  168. package/lib/plots/venn/interactions/actions/selected.js.map +1 -0
  169. package/lib/plots/venn/{interaction → interactions}/index.d.ts +0 -0
  170. package/lib/plots/venn/interactions/index.js +50 -0
  171. package/lib/plots/venn/interactions/index.js.map +1 -0
  172. package/lib/plots/venn/interactions/util.d.ts +3 -0
  173. package/lib/plots/venn/interactions/util.js +15 -0
  174. package/lib/plots/venn/interactions/util.js.map +1 -0
  175. package/lib/plots/venn/types.d.ts +2 -2
  176. package/lib/plots/venn/types.js.map +1 -1
  177. package/lib/plots/venn/utils.d.ts +3 -4
  178. package/lib/plots/venn/utils.js +2 -3
  179. package/lib/plots/venn/utils.js.map +1 -1
  180. package/lib/types/attr.d.ts +1 -1
  181. package/lib/types/attr.js.map +1 -1
  182. package/lib/types/common.d.ts +2 -0
  183. package/lib/types/common.js.map +1 -1
  184. package/package.json +5 -5
  185. package/src/adaptor/geometries/base.ts +23 -2
  186. package/src/adaptor/geometries/index.ts +1 -0
  187. package/src/core/plot.ts +3 -1
  188. package/src/index.ts +1 -1
  189. package/src/interactions/actions/drill-down.ts +13 -4
  190. package/src/interactions/drill-down.ts +24 -1
  191. package/src/plots/area/adaptor.ts +5 -2
  192. package/src/plots/area/types.ts +2 -3
  193. package/src/plots/bidirectional-bar/adaptor.ts +35 -7
  194. package/src/plots/bidirectional-bar/index.ts +3 -0
  195. package/src/plots/box/adaptor.ts +14 -2
  196. package/src/plots/column/adaptor.ts +2 -0
  197. package/src/plots/column/types.ts +5 -0
  198. package/src/plots/funnel/adaptor.ts +3 -3
  199. package/src/plots/heatmap/adaptor.ts +29 -11
  200. package/src/plots/heatmap/types.ts +6 -2
  201. package/src/plots/line/adaptor.ts +31 -3
  202. package/src/plots/line/types.ts +13 -2
  203. package/src/plots/pie/interactions/{pie-legend-action.ts → actions/legend-active.ts} +1 -1
  204. package/src/plots/pie/interactions/{pie-statistic-action.ts → actions/statistic-active.ts} +11 -3
  205. package/src/plots/pie/interactions/index.ts +2 -2
  206. package/src/plots/pie/interactions/util.ts +16 -0
  207. package/src/plots/sankey/helper.ts +26 -9
  208. package/src/plots/sankey/types.ts +52 -8
  209. package/src/plots/sunburst/types.ts +3 -1
  210. package/src/plots/sunburst/utils.ts +6 -1
  211. package/src/plots/venn/adaptor.ts +63 -13
  212. package/src/plots/venn/constant.ts +22 -6
  213. package/src/plots/venn/interactions/actions/active.ts +31 -0
  214. package/src/plots/venn/interactions/actions/highlight.ts +37 -0
  215. package/src/plots/venn/interactions/actions/selected.ts +65 -0
  216. package/src/plots/venn/interactions/index.ts +55 -0
  217. package/src/plots/venn/interactions/util.ts +12 -0
  218. package/src/plots/venn/types.ts +2 -2
  219. package/src/plots/venn/utils.ts +10 -4
  220. package/src/types/attr.ts +1 -1
  221. package/src/types/common.ts +2 -0
  222. package/esm/plots/pie/interactions/pie-legend-action.js.map +0 -1
  223. package/esm/plots/pie/interactions/pie-statistic-action.js.map +0 -1
  224. package/esm/plots/venn/interaction/action.d.ts +0 -18
  225. package/esm/plots/venn/interaction/action.js +0 -77
  226. package/esm/plots/venn/interaction/action.js.map +0 -1
  227. package/esm/plots/venn/interaction/index.js +0 -15
  228. package/esm/plots/venn/interaction/index.js.map +0 -1
  229. package/lib/plots/pie/interactions/pie-legend-action.js.map +0 -1
  230. package/lib/plots/pie/interactions/pie-statistic-action.js.map +0 -1
  231. package/lib/plots/venn/interaction/action.d.ts +0 -18
  232. package/lib/plots/venn/interaction/action.js +0 -80
  233. package/lib/plots/venn/interaction/action.js.map +0 -1
  234. package/lib/plots/venn/interaction/index.js +0 -17
  235. package/lib/plots/venn/interaction/index.js.map +0 -1
  236. package/src/plots/venn/interaction/action.ts +0 -67
  237. package/src/plots/venn/interaction/index.ts +0 -17
@@ -46,6 +46,8 @@ export declare type Geometry = {
46
46
  readonly label?: Label;
47
47
  /** 不同状态的样式 */
48
48
  readonly state?: State;
49
+ /** 自定义信息,一般在 registerShape 中使用 */
50
+ readonly customInfo?: any;
49
51
  /** geometry params */
50
52
  readonly args?: any;
51
53
  };
@@ -72,7 +72,7 @@ export function getMappingFunction(mappingFields, func) {
72
72
  */
73
73
  export function geometry(params) {
74
74
  var chart = params.chart, options = params.options;
75
- var type = options.type, args = options.args, mapping = options.mapping, xField = options.xField, yField = options.yField, colorField = options.colorField, shapeField = options.shapeField, sizeField = options.sizeField, tooltipFields = options.tooltipFields, label = options.label, state = options.state;
75
+ var type = options.type, args = options.args, mapping = options.mapping, xField = options.xField, yField = options.yField, colorField = options.colorField, shapeField = options.shapeField, sizeField = options.sizeField, tooltipFields = options.tooltipFields, label = options.label, state = options.state, customInfo = options.customInfo;
76
76
  // 如果没有 mapping 信息,那么直接返回
77
77
  if (!mapping) {
78
78
  return params;
@@ -174,6 +174,12 @@ export function geometry(params) {
174
174
  if (state) {
175
175
  geometry.state(state);
176
176
  }
177
+ /**
178
+ * 自定义信息
179
+ */
180
+ if (customInfo) {
181
+ geometry.customInfo(customInfo);
182
+ }
177
183
  // 防止因为 x y 字段做了通道映射,导致生成图例
178
184
  [xField, yField]
179
185
  .filter(function (f) { return f !== colorField; })
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAwD7C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,CAAkB,EAClB,KAA2C;IAKnC,IAAA,IAAI,GAAoF,CAAC,KAArF,EAAE,MAAM,GAA4E,CAAC,OAA7E,EAAE,MAAM,GAAoE,CAAC,OAArE,EAAE,UAAU,GAAwD,CAAC,WAAzD,EAAE,UAAU,GAA4C,CAAC,WAA7C,EAAE,SAAS,GAAiC,CAAC,UAAlC,EAAE,UAAU,GAAqB,CAAC,WAAtB,EAAE,KAAmB,CAAC,UAAN,EAAd,SAAS,mBAAG,EAAE,KAAA,CAAO;IAElG,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,4DAA4D;IAC5D,gDAAgD;IAChD,iBAAiB;IACjB,IAAI,KAAK,KAAK,OAAO,EAAE;QACrB,MAAM,mBAAI,UAAU,IAAI,MAAM,GAAK,SAAS,CAAC,CAAC;KAC/C;SAAM,IAAI,KAAK,KAAK,OAAO,EAAE;QAC5B,MAAM,mBAAI,UAAU,IAAI,MAAM,GAAK,SA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AAW;QAC3C,QAAQ,CAAC,KAAK,CAAC;YACb,MAAM,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC;YAC1B,QAAQ,UAAA;YACR,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC;SACzB,CAAC,CAAC;KACJ;IAED;;OAEG;IACH,IAAI,KAAK,EAAE;QACT,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACvB;IAED,2BAA2B;IAC3B,CAAC,MAAM,EAAE,MAAM,CAAC;SACb,MAAM,CAAC,UAAC,CAAS,IAAK,OAAA,CAAC,KAAK,UAAU,EAAhB,CAAgB,CAAC;SACvC,OAAO,CAAC,UAAC,CAAS;QACjB,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IACL,6BACK,MAAM;QACT,gFAAgF;QAChF,GAAG,EAAE,EAAE,QAAQ,UAAA,EAAE,IACjB;AACJ,CAAC","sourcesContent":["import { uniq, isFunction, isObject, isString, isNumber, isEmpty } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum } from '../../types';\nimport { Label } from '../../types/label';\nimport { State } from '../../types/state';\nimport { transformLabel } from '../../utils';\n\n/**\n * 图形映射属性,按照优先级来的\n */\nexport type MappingOptions = {\n /** color 映射 */\n readonly color?: ColorAttr;\n /** shape 映射 */\n readonly shape?: ShapeAttr;\n /** 大小映射, 提供回调的方式 */\n readonly size?: SizeAttr;\n /** 样式映射 */\n readonly style?: StyleAttr;\n /** tooltip 映射 */\n readonly tooltip?: TooltipAttr;\n};\n\n/**\n * 一个图形映射的逻辑,纯粹的图形语法\n * // TODO 后续需要处理 adjust 的配置,然后通过 field 信息。比如 styleField,labelField 等一定是一个数组形式\n */\nexport type Geometry = {\n /** geometry 类型, 'line' | 'interval' | 'point' | 'area' | 'polygon' */\n readonly type?: string;\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly colorField?: string;\n /** shape 的映射字段 */\n readonly shapeField?: string;\n /** size 映射字段 */\n readonly sizeField?: string;\n /** style 的映射字段 */\n readonly styleField?: string;\n /** tooltip 的映射字段 */\n readonly tooltipFields?: string[] | false;\n /** 其他原始字段, 用于 mapping 回调参数 */\n readonly rawFields?: string[];\n /** 图形映射规则 */\n readonly mapping?: MappingOptions;\n /** label 映射通道,因为历史原因导致实现略有区别 */\n readonly label?: Label;\n /** 不同状态的样式 */\n readonly state?: State;\n /** geometry params */\n readonly args?: any;\n};\n\n/**\n * geometry options\n */\nexport type GeometryOptions = Geometry & Partial<Options>;\n\n/**\n * 获得映射的字段列表\n * @param options\n * @param field\n */\nexport function getMappingField(\n o: GeometryOptions,\n field: 'color' | 'shape' | 'size' | 'style'\n): {\n mappingFields: string[];\n tileMappingField: string;\n} {\n const { type, xField, yField, colorField, shapeField, sizeField, styleField, rawFields = [] } = o;\n\n let fields = [];\n\n // 因为 color 会影响到数据分组,以及最后的图形映射。所以导致 bar 图中的 widthRatio 设置不生效\n // 所以对于 color 字段,仅仅保留 colorField 好了! + rawFields\n // shape, size 同理\n if (field === 'color') {\n fields = [colorField || xField, ...rawFields];\n } else if (field === 'shape') {\n fields = [shapeField || xField, ...rawFields];\n } else if (field === 'size') {\n fields = [sizeField || xField, ...rawFields];\n } else {\n fields = [xField, yField, colorField, shapeField, sizeField, styleField, ...rawFields];\n\n // 一定能找到的!\n const idx = ['x', 'y', 'color', 'shape', 'size', 'style'].indexOf(field);\n\n const f = fields[idx];\n // 删除当前字段\n fields.splice(idx, 1);\n // 插入到第一个\n fields.unshift(f);\n }\n\n const mappingFields = uniq(fields.filter((f) => !!f));\n /**\n * 修复 line geometry 无拆分时 color 回调错误\n * eg:\n * geometry.color(xField, ()=> '#f24')\n */\n const tileMappingField =\n type === 'line' && [xField, yField].includes(mappingFields.join('*')) ? '' : mappingFields.join('*');\n return {\n mappingFields,\n tileMappingField,\n };\n}\n\n/**\n * 获得映射函数\n * @param mappingFields\n * @param func\n */\nexport function getMappingFunction(mappingFields: string[], func: (datum: Datum) => any) {\n if (!func) return undefined;\n // 返回函数\n return (...args: any[]) => {\n const params: Datum = {};\n\n mappingFields.forEach((f: string, idx: number) => {\n params[f] = args[idx];\n });\n\n // 删除 undefined\n delete params['undefined'];\n\n return func(params);\n };\n}\n\n/**\n * 通用 geometry 的配置处理的 adaptor\n * @param params\n */\nexport function geometry<O extends GeometryOptions>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const { type, args, mapping, xField, yField, colorField, shapeField, sizeField, tooltipFields, label, state } =\n options;\n\n // 如果没有 mapping 信息,那么直接返回\n if (!mapping) {\n return params;\n }\n\n const { color, shape, size, style, tooltip } = mapping;\n\n // 创建 geometry\n const geometry = chart[type](args).position(`${xField}*${yField}`);\n\n /**\n * color 的几种情况\n * g.color('red');\n * g.color('color', ['red', 'blue']);\n * g.color('x', (x, y) => 'red');\n * g.color('color', (color, x, y) => 'red');\n */\n if (isString(color)) {\n colorField ? geometry.color(colorField, color) : geometry.color(color);\n } else if (isFunction(color)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'color');\n geometry.color(tileMappingField, getMappingFunction(mappingFields, color));\n } else {\n colorField && geometry.color(colorField, color);\n }\n\n /**\n * shape 的几种情况\n * g.shape('rect');\n * g.shape('shape', ['rect', 'circle']);\n * g.shape('x*y', (x, y) => 'rect');\n * g.shape('shape*x*y', (shape, x, y) => 'rect');\n */\n if (isString(shape)) {\n shapeField ? geometry.shape(shapeField, [shape]) : geometry.shape(shape); // [shape] 需要在 G2 做掉\n } else if (isFunction(shape)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'shape');\n geometry.shape(tileMappingField, getMappingFunction(mappingFields, shape));\n } else {\n shapeField && geometry.shape(shapeField, shape);\n }\n\n /**\n * size 的几种情况\n * g.size(10);\n * g.size('size', [10, 20]);\n * g.size('x*y', (x, y) => 10);\n * g.color('size*x*y', (size, x, y) => 1-);\n */\n if (isNumber(size)) {\n sizeField ? geometry.size(sizeField, size) : geometry.size(size);\n } else if (isFunction(size)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'size');\n geometry.size(tileMappingField, getMappingFunction(mappingFields, size));\n } else {\n sizeField && geometry.size(sizeField, size);\n }\n\n /**\n * style 的几种情况\n * g.style({ fill: 'red' });\n * g.style('x*y*color', (x, y, color) => ({ fill: 'red' }));\n */\n if (isFunction(style)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'style');\n geometry.style(tileMappingField, getMappingFunction(mappingFields, style));\n } else if (isObject(style)) {\n geometry.style(style);\n }\n\n /**\n * tooltip 的 API\n * g.tooltip('x*y*color', (x, y, color) => ({ name, value }));\n * g.tooltip(false);\n */\n if (tooltipFields === false) {\n geometry.tooltip(false);\n } else if (!isEmpty(tooltipFields)) {\n geometry.tooltip(tooltipFields.join('*'), getMappingFunction(tooltipFields, tooltip));\n }\n\n /**\n * label 的映射\n */\n if (label === false) {\n geometry.label(false);\n } else if (label) {\n const { callback, fields, ...cfg } = label;\n geometry.label({\n fields: fields || [yField],\n callback,\n cfg: transformLabel(cfg),\n });\n }\n\n /**\n * state 状态样式\n */\n if (state) {\n geometry.state(state);\n }\n\n // 防止因为 x y 字段做了通道映射,导致生成图例\n [xField, yField]\n .filter((f: string) => f !== colorField)\n .forEach((f: string) => {\n chart.legend(f, false);\n });\n return {\n ...params,\n // geometry adaptor 额外需要做的事情,就是将创建好的 geometry 返回到下一层 adaptor,防止通过 type 查询的时候容易误判\n ext: { geometry },\n };\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA0D7C;;;;GAIG;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AM;QACT,gFAAgF;QAChF,GAAG,EAAE,EAAE,QAAQ,UAAA,EAAE,IACjB;AACJ,CAAC","sourcesContent":["import { uniq, isFunction, isObject, isString, isNumber, isEmpty } from '@antv/util';\nimport { Params } from '../../core/adaptor';\nimport { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum } from '../../types';\nimport { Label } from '../../types/label';\nimport { State } from '../../types/state';\nimport { transformLabel } from '../../utils';\n\n/**\n * 图形映射属性,按照优先级来的\n */\nexport type MappingOptions = {\n /** color 映射 */\n readonly color?: ColorAttr;\n /** shape 映射 */\n readonly shape?: ShapeAttr;\n /** 大小映射, 提供回调的方式 */\n readonly size?: SizeAttr;\n /** 样式映射 */\n readonly style?: StyleAttr;\n /** tooltip 映射 */\n readonly tooltip?: TooltipAttr;\n};\n\n/**\n * 一个图形映射的逻辑,纯粹的图形语法\n * // TODO 后续需要处理 adjust 的配置,然后通过 field 信息。比如 styleField,labelField 等一定是一个数组形式\n */\nexport type Geometry = {\n /** geometry 类型, 'line' | 'interval' | 'point' | 'area' | 'polygon' */\n readonly type?: string;\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly colorField?: string;\n /** shape 的映射字段 */\n readonly shapeField?: string;\n /** size 映射字段 */\n readonly sizeField?: string;\n /** style 的映射字段 */\n readonly styleField?: string;\n /** tooltip 的映射字段 */\n readonly tooltipFields?: string[] | false;\n /** 其他原始字段, 用于 mapping 回调参数 */\n readonly rawFields?: string[];\n /** 图形映射规则 */\n readonly mapping?: MappingOptions;\n /** label 映射通道,因为历史原因导致实现略有区别 */\n readonly label?: Label;\n /** 不同状态的样式 */\n readonly state?: State;\n /** 自定义信息,一般在 registerShape 中使用 */\n readonly customInfo?: any;\n /** geometry params */\n readonly args?: any;\n};\n\n/**\n * geometry options\n */\nexport type GeometryOptions = Geometry & Partial<Options>;\n\n/**\n * 获得映射的字段列表\n * @param options\n * @param field\n */\nexport function getMappingField(\n o: GeometryOptions,\n field: 'color' | 'shape' | 'size' | 'style'\n): {\n mappingFields: string[];\n tileMappingField: string;\n} {\n const { type, xField, yField, colorField, shapeField, sizeField, styleField, rawFields = [] } = o;\n\n let fields = [];\n\n // 因为 color 会影响到数据分组,以及最后的图形映射。所以导致 bar 图中的 widthRatio 设置不生效\n // 所以对于 color 字段,仅仅保留 colorField 好了! + rawFields\n // shape, size 同理\n if (field === 'color') {\n fields = [colorField || xField, ...rawFields];\n } else if (field === 'shape') {\n fields = [shapeField || xField, ...rawFields];\n } else if (field === 'size') {\n fields = [sizeField || xField, ...rawFields];\n } else {\n fields = [xField, yField, colorField, shapeField, sizeField, styleField, ...rawFields];\n\n // 一定能找到的!\n const idx = ['x', 'y', 'color', 'shape', 'size', 'style'].indexOf(field);\n\n const f = fields[idx];\n // 删除当前字段\n fields.splice(idx, 1);\n // 插入到第一个\n fields.unshift(f);\n }\n\n const mappingFields = uniq(fields.filter((f) => !!f));\n /**\n * 修复 line geometry 无拆分时 color 回调错误\n * eg:\n * geometry.color(xField, ()=> '#f24')\n */\n const tileMappingField =\n type === 'line' && [xField, yField].includes(mappingFields.join('*')) ? '' : mappingFields.join('*');\n return {\n mappingFields,\n tileMappingField,\n };\n}\n\n/**\n * 获得映射函数\n * @param mappingFields\n * @param func\n */\nexport function getMappingFunction(mappingFields: string[], func: (datum: Datum) => any) {\n if (!func) return undefined;\n // 返回函数\n return (...args: any[]) => {\n const params: Datum = {};\n\n mappingFields.forEach((f: string, idx: number) => {\n params[f] = args[idx];\n });\n\n // 删除 undefined\n delete params['undefined'];\n\n return func(params);\n };\n}\n\n/**\n * 通用 geometry 的配置处理的 adaptor\n * @param params\n */\nexport function geometry<O extends GeometryOptions>(params: Params<O>): Params<O> {\n const { chart, options } = params;\n const {\n type,\n args,\n mapping,\n xField,\n yField,\n colorField,\n shapeField,\n sizeField,\n tooltipFields,\n label,\n state,\n customInfo,\n } = options;\n\n // 如果没有 mapping 信息,那么直接返回\n if (!mapping) {\n return params;\n }\n\n const { color, shape, size, style, tooltip } = mapping;\n\n // 创建 geometry\n const geometry = chart[type](args).position(`${xField}*${yField}`);\n\n /**\n * color 的几种情况\n * g.color('red');\n * g.color('color', ['red', 'blue']);\n * g.color('x', (x, y) => 'red');\n * g.color('color', (color, x, y) => 'red');\n */\n if (isString(color)) {\n colorField ? geometry.color(colorField, color) : geometry.color(color);\n } else if (isFunction(color)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'color');\n geometry.color(tileMappingField, getMappingFunction(mappingFields, color));\n } else {\n colorField && geometry.color(colorField, color);\n }\n\n /**\n * shape 的几种情况\n * g.shape('rect');\n * g.shape('shape', ['rect', 'circle']);\n * g.shape('x*y', (x, y) => 'rect');\n * g.shape('shape*x*y', (shape, x, y) => 'rect');\n */\n if (isString(shape)) {\n shapeField ? geometry.shape(shapeField, [shape]) : geometry.shape(shape); // [shape] 需要在 G2 做掉\n } else if (isFunction(shape)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'shape');\n geometry.shape(tileMappingField, getMappingFunction(mappingFields, shape));\n } else {\n shapeField && geometry.shape(shapeField, shape);\n }\n\n /**\n * size 的几种情况\n * g.size(10);\n * g.size('size', [10, 20]);\n * g.size('x*y', (x, y) => 10);\n * g.color('size*x*y', (size, x, y) => 1-);\n */\n if (isNumber(size)) {\n sizeField ? geometry.size(sizeField, size) : geometry.size(size);\n } else if (isFunction(size)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'size');\n geometry.size(tileMappingField, getMappingFunction(mappingFields, size));\n } else {\n sizeField && geometry.size(sizeField, size);\n }\n\n /**\n * style 的几种情况\n * g.style({ fill: 'red' });\n * g.style('x*y*color', (x, y, color) => ({ fill: 'red' }));\n */\n if (isFunction(style)) {\n const { mappingFields, tileMappingField } = getMappingField(options, 'style');\n geometry.style(tileMappingField, getMappingFunction(mappingFields, style));\n } else if (isObject(style)) {\n geometry.style(style);\n }\n\n /**\n * tooltip 的 API\n * g.tooltip('x*y*color', (x, y, color) => ({ name, value }));\n * g.tooltip(false);\n */\n if (tooltipFields === false) {\n geometry.tooltip(false);\n } else if (!isEmpty(tooltipFields)) {\n geometry.tooltip(tooltipFields.join('*'), getMappingFunction(tooltipFields, tooltip));\n }\n\n /**\n * label 的映射\n */\n if (label === false) {\n geometry.label(false);\n } else if (label) {\n const { callback, fields, ...cfg } = label;\n geometry.label({\n fields: fields || [yField],\n callback,\n cfg: transformLabel(cfg),\n });\n }\n\n /**\n * state 状态样式\n */\n if (state) {\n geometry.state(state);\n }\n\n /**\n * 自定义信息\n */\n if (customInfo) {\n geometry.customInfo(customInfo);\n }\n\n // 防止因为 x y 字段做了通道映射,导致生成图例\n [xField, yField]\n .filter((f: string) => f !== colorField)\n .forEach((f: string) => {\n chart.legend(f, false);\n });\n return {\n ...params,\n // geometry adaptor 额外需要做的事情,就是将创建好的 geometry 返回到下一层 adaptor,防止通过 type 查询的时候容易误判\n ext: { geometry },\n };\n}\n"]}
@@ -1,3 +1,4 @@
1
+ export type { GeometryOptions } from './base';
1
2
  export { area } from './area';
2
3
  export type { AreaGeometryOptions } from './area';
3
4
  export { line } from './line';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export { area } from './area';\nexport type { AreaGeometryOptions } from './area';\nexport { line } from './line';\nexport type { LineGeometryOptions } from './line';\nexport { point } from './point';\nexport type { PointGeometryOptions } from './point';\nexport { interval } from './interval';\nexport type { IntervalGeometryOptions } from './interval';\nexport { polygon } from './polygon';\nexport type { PolygonGeometryOptions } from './polygon';\nexport { edge } from './edge';\nexport type { EdgeGeometryOptions } from './edge';\nexport { schema } from './schema';\nexport type { SchemaGeometryOptions } from './schema';\nexport { violin } from './violin';\nexport type { ViolinGeometryOptions } from './violin';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adaptor/geometries/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export type { GeometryOptions } from './base';\nexport { area } from './area';\nexport type { AreaGeometryOptions } from './area';\nexport { line } from './line';\nexport type { LineGeometryOptions } from './line';\nexport { point } from './point';\nexport type { PointGeometryOptions } from './point';\nexport { interval } from './interval';\nexport type { IntervalGeometryOptions } from './interval';\nexport { polygon } from './polygon';\nexport type { PolygonGeometryOptions } from './polygon';\nexport { edge } from './edge';\nexport type { EdgeGeometryOptions } from './edge';\nexport { schema } from './schema';\nexport type { SchemaGeometryOptions } from './schema';\nexport { violin } from './violin';\nexport type { ViolinGeometryOptions } from './violin';\n"]}
@@ -7,4 +7,4 @@ import { Options } from '../types';
7
7
  * @param key key of style property
8
8
  * @returns
9
9
  */
10
- export declare function pattern(key: string): <O extends Pick<Options, "label" | "legend" | "meta" | "padding" | "animation" | "color" | "height" | "width" | "appendPadding" | "renderer" | "pixelRatio" | "autoFit" | "syncViewPadding" | "supportCSSTransform" | "limitInPlot" | "locale" | "localRefresh" | "theme" | "pattern" | "xAxis" | "yAxis" | "tooltip" | "slider" | "scrollbar" | "interactions" | "annotations" | "state"> = Pick<Options, "label" | "legend" | "meta" | "padding" | "animation" | "color" | "height" | "width" | "appendPadding" | "renderer" | "pixelRatio" | "autoFit" | "syncViewPadding" | "supportCSSTransform" | "limitInPlot" | "locale" | "localRefresh" | "theme" | "pattern" | "xAxis" | "yAxis" | "tooltip" | "slider" | "scrollbar" | "interactions" | "annotations" | "state">>(params: Params<O>) => Params<O>;
10
+ export declare function pattern(key: string): <O extends Pick<Options, "label" | "legend" | "meta" | "padding" | "animation" | "color" | "height" | "width" | "appendPadding" | "renderer" | "pixelRatio" | "autoFit" | "syncViewPadding" | "supportCSSTransform" | "limitInPlot" | "locale" | "defaultInteractions" | "localRefresh" | "theme" | "pattern" | "xAxis" | "yAxis" | "tooltip" | "slider" | "scrollbar" | "interactions" | "annotations" | "state"> = Pick<Options, "label" | "legend" | "meta" | "padding" | "animation" | "color" | "height" | "width" | "appendPadding" | "renderer" | "pixelRatio" | "autoFit" | "syncViewPadding" | "supportCSSTransform" | "limitInPlot" | "locale" | "defaultInteractions" | "localRefresh" | "theme" | "pattern" | "xAxis" | "yAxis" | "tooltip" | "slider" | "scrollbar" | "interactions" | "annotations" | "state">>(params: Params<O>) => Params<O>;
@@ -3,7 +3,7 @@ import EE from '@antv/event-emitter';
3
3
  import { Options, StateName, StateCondition, StateObject, Annotation } from '../types';
4
4
  import { Adaptor } from './adaptor';
5
5
  /** 单独 pick 出来的用于基类的类型定义 */
6
- export declare type PickOptions = Pick<Options, 'width' | 'height' | 'padding' | 'appendPadding' | 'renderer' | 'pixelRatio' | 'autoFit' | 'syncViewPadding' | 'supportCSSTransform' | 'limitInPlot' | 'locale'>;
6
+ export declare type PickOptions = Pick<Options, 'width' | 'height' | 'padding' | 'appendPadding' | 'renderer' | 'pixelRatio' | 'autoFit' | 'syncViewPadding' | 'supportCSSTransform' | 'limitInPlot' | 'locale' | 'defaultInteractions'>;
7
7
  /** plot 图表容器的配置 */
8
8
  export declare const PLOT_CONTAINER_OPTIONS: string[];
9
9
  /**
package/esm/core/plot.js CHANGED
@@ -56,8 +56,8 @@ var Plot = /** @class */ (function (_super) {
56
56
  * 创建 G2 实例
57
57
  */
58
58
  Plot.prototype.createG2 = function () {
59
- var _a = this.options, width = _a.width, height = _a.height;
60
- this.chart = new Chart(__assign(__assign(__assign({ container: this.container, autoFit: false }, this.getChartSize(width, height)), { localRefresh: false }), pick(this.options, PLOT_CONTAINER_OPTIONS)));
59
+ var _a = this.options, width = _a.width, height = _a.height, defaultInteractions = _a.defaultInteractions;
60
+ this.chart = new Chart(__assign(__assign(__assign(__assign({ container: this.container, autoFit: false }, this.getChartSize(width, height)), { localRefresh: false }), pick(this.options, PLOT_CONTAINER_OPTIONS)), { defaultInteractions: defaultInteractions }));
61
61
  // 给容器增加标识,知道图表的来源区别于 G2
62
62
  this.container.setAttribute(SOURCE_ATTRIBUTE_NAME, 'G2Plot');
63
63
  };
@@ -1 +1 @@
1
- {"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/core/plot.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAmBzF,IAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD,mBAAmB;AACnB,MAAM,CAAC,IAAM,sBAAsB,GAAG;IACpC,SAAS;IACT,eAAe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Aa,EAAE,CAAC;iBACtB;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;OAEG;IACK,+BAAgB,GAAxB;QACE,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;SACzB;IACH,CAAC;IACH,WAAC;AAAD,CAAC,AAvTD,CAA0D,EAAE,GAuT3D","sourcesContent":["import { Chart, Event, Element } from '@antv/g2';\nimport { each } from '@antv/util';\nimport EE from '@antv/event-emitter';\nimport { bind } from 'size-sensor';\nimport { Options, StateName, StateCondition, Size, StateObject, Annotation } from '../types';\nimport { getContainerSize, getAllElementsRecursively, deepAssign, pick } from '../utils';\nimport { Adaptor } from './adaptor';\n\n/** 单独 pick 出来的用于基类的类型定义 */\nexport type PickOptions = Pick<\n Options,\n | 'width'\n | 'height'\n | 'padding'\n | 'appendPadding'\n | 'renderer'\n | 'pixelRatio'\n | 'autoFit'\n | 'syncViewPadding'\n | 'supportCSSTransform'\n | 'limitInPlot'\n | 'locale'\n>;\n\nconst SOURCE_ATTRIBUTE_NAME = 'data-chart-source-type';\n\n/** plot 图表容器的配置 */\nexport const PLOT_CONTAINER_OPTIONS = [\n 'padding',\n 'appendPadding',\n 'renderer',\n 'pixelRatio',\n 'syncViewPadding',\n 'supportCSSTransform',\n 'limitInPlot',\n];\n\n/**\n * 所有 plot 的基类\n */\nexport abstract class Plot<O extends PickOptions> extends EE {\n /**\n * 获取默认的 options 配置项\n * 每个组件都可以复写\n */\n static getDefaultOptions(): any {\n return {\n renderer: 'canvas',\n xAxis: {\n nice: true,\n label: {\n autoRotate: false,\n autoHide: { type: 'equidistance', cfg: { minGap: 6 } },\n },\n },\n yAxis: {\n nice: true,\n label: {\n autoHide: true,\n autoRotate: false,\n },\n },\n animation: true,\n };\n }\n\n /** plot 类型名称 */\n public abstract readonly type: string;\n /** plot 的 schema 配置 */\n public options: O;\n /** plot 绘制的 dom */\n public readonly container: HTMLElement;\n /** G2 chart 实例 */\n public chart: Chart;\n /** resizer unbind */\n private unbind: () => void;\n\n constructor(container: string | HTMLElement, options: O) {\n super();\n this.container = typeof container === 'string' ? document.getElementById(container) : container;\n\n this.options = deepAssign({}, this.getDefaultOptions(), options);\n\n this.createG2();\n\n this.bindEvents();\n }\n\n /**\n * 创建 G2 实例\n */\n private createG2() {\n const { width, height } = this.options;\n\n this.chart = new Chart({\n container: this.container,\n autoFit: false, // G2Plot 使用 size-sensor 进行 autoFit\n ...this.getChartSize(width, height),\n localRefresh: false, // 默认关闭,目前 G 还有一些位置问题,难以排查!\n ...pick(this.options, PLOT_CONTAINER_OPTIONS),\n });\n\n // 给容器增加标识,知道图表的来源区别于 G2\n this.container.setAttribute(SOURCE_ATTRIBUTE_NAME, 'G2Plot');\n }\n\n /**\n * 计算默认的 chart 大小。逻辑简化:如果存在 width 或 height,则直接使用,否则使用容器大小\n * @param width\n * @param height\n */\n private getChartSize(width: number, height: number): Size {\n const chartSize = getContainerSize(this.container);\n return { width: width || chartSize.width || 400, height: height || chartSize.height || 400 };\n }\n\n /**\n * 绑定代理所有 G2 的事件\n */\n private bindEvents() {\n if (this.chart) {\n this.chart.on('*', (e: Event) => {\n if (e?.type) {\n this.emit(e.type, e);\n }\n });\n }\n }\n\n /**\n * 获取默认的 options 配置项\n * 每个组件都可以复写\n */\n protected getDefaultOptions(): any {\n return Plot.getDefaultOptions();\n }\n\n /**\n * 每个组件有自己的 schema adaptor\n */\n protected abstract getSchemaAdaptor(): Adaptor<O>;\n\n /**\n * 绘制\n */\n public render() {\n // 暴力处理,先清空再渲染,需要 G2 层自行做好更新渲染\n this.chart.clear();\n // 因为子 view 会继承父 view 的 options 配置(包括 legend,所以会导致 legend 重复创建)\n // 所以这里给 chart 实例的 options 配置清空\n // 最好的解法是在 G2 view.clear 方法的时候,重置 options 配置。或者提供方法去 resetOptions\n // #1684 理论上在多 view 图形上,只要存在 custom legend,都存在类似问题(子弹图、双轴图)\n // @ts-ignore\n this.chart.options = {\n data: [],\n animate: true,\n };\n this.chart.views = []; // 删除已有的 views\n // 执行 adaptor\n this.execAdaptor();\n // 渲染\n this.chart.render();\n // 绑定\n this.bindSizeSensor();\n }\n\n /**\n * 更新: 更新配置且重新渲染\n * @param options\n */\n public update(options: Partial<O>) {\n this.updateOption(options);\n this.render();\n }\n\n /**\n * 更新配置\n * @param options\n */\n protected updateOption(options: Partial<O>) {\n this.options = deepAssign({}, this.options, options);\n }\n\n /**\n * 设置状态\n * @param type 状态类型,支持 'active' | 'inactive' | 'selected' 三种\n * @param conditions 条件,支持数组\n * @param status 是否激活,默认 true\n */\n public setState(type: StateName, condition: StateCondition, status: boolean = true) {\n const elements = getAllElementsRecursively(this.chart);\n\n each(elements, (ele: Element) => {\n if (condition(ele.getData())) {\n ele.setState(type, status);\n }\n });\n }\n\n /**\n * 获取状态\n */\n public getStates(): StateObject[] {\n const elements = getAllElementsRecursively(this.chart);\n\n const stateObjects: StateObject[] = [];\n each(elements, (element: Element) => {\n const data = element.getData();\n const states = element.getStates();\n each(states, (state) => {\n stateObjects.push({ data, state, geometry: element.geometry, element });\n });\n });\n\n return stateObjects;\n }\n\n /**\n * 更新数据\n * @override\n * @param options\n */\n public changeData(data: any) {\n // @ts-ignore\n this.update({ data });\n // TODO: 临时方案,最好使用下面的方式去更新数据\n // this.chart.changeData(data);\n }\n\n /**\n * 修改画布大小\n * @param width\n * @param height\n */\n public changeSize(width: number, height: number) {\n this.chart.changeSize(width, height);\n }\n\n /**\n * 增加图表标注。通过 id 标识,如果匹配到,就做更新\n */\n public addAnnotations(annotations: Annotation[]): void {\n const incoming = [...annotations];\n const controller = this.chart.getController('annotation');\n const current = controller.getComponents().map((co) => co.extra);\n\n controller.clear(true);\n for (let i = 0; i < current.length; i++) {\n let annotation = current[i];\n\n const findIndex = incoming.findIndex((item) => item.id && item.id === annotation.id);\n if (findIndex !== -1) {\n annotation = deepAssign({}, annotation, incoming[findIndex]);\n incoming.splice(findIndex, 1);\n }\n controller.annotation(annotation);\n }\n\n incoming.forEach((annotation) => controller.annotation(annotation));\n this.chart.render(true);\n }\n\n /**\n * 删除图表标注。通过 id 标识,如果匹配到,就做删除\n */\n public removeAnnotations(annotations: Array<{ id: string } & Partial<Annotation>>): void {\n const controller = this.chart.getController('annotation');\n const current = controller.getComponents().map((co) => co.extra);\n\n controller.clear(true);\n for (let i = 0; i < current.length; i++) {\n const annotation = current[i];\n\n if (!annotations.find((item) => item.id && item.id === annotation.id)) {\n controller.annotation(annotation);\n }\n }\n\n this.chart.render(true);\n }\n /**\n * 销毁\n */\n public destroy() {\n // 取消 size-sensor 的绑定\n this.unbindSizeSensor();\n // G2 的销毁\n this.chart.destroy();\n // 清空已经绑定的事件\n this.off();\n\n this.container.removeAttribute(SOURCE_ATTRIBUTE_NAME);\n }\n\n /**\n * 执行 adaptor 操作\n */\n protected execAdaptor() {\n const adaptor = this.getSchemaAdaptor();\n\n const { padding, appendPadding } = this.options;\n // 更新 padding\n this.chart.padding = padding;\n // 更新 appendPadding\n this.chart.appendPadding = appendPadding;\n\n // 转化成 G2 API\n adaptor({\n chart: this.chart,\n options: this.options,\n });\n }\n\n /**\n * 当图表容器大小变化的时候,执行的函数\n */\n protected triggerResize() {\n this.chart.forceFit();\n }\n\n /**\n * 绑定 dom 容器大小变化的事件\n */\n private bindSizeSensor() {\n if (this.unbind) {\n return;\n }\n\n const { autoFit = true } = this.options;\n if (autoFit) {\n this.unbind = bind(this.container, () => {\n // 获取最新的宽高信息\n const { width, height } = getContainerSize(this.container);\n\n // 主要是防止绑定的时候触发 resize 回调\n if (width !== this.chart.width || height !== this.chart.height) {\n this.triggerResize();\n }\n });\n }\n }\n\n /**\n * 取消绑定\n */\n private unbindSizeSensor() {\n if (this.unbind) {\n this.unbind();\n this.unbind = undefined;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/core/plot.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,E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CAAC,OAAO,QAAjB,EAAd,OAAO,mBAAG,IAAI,KAAA,CAAkB;QACxC,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACjC,YAAY;gBACN,IAAA,KAAoB,gBAAgB,CAAC,KAAI,CAAC,SAAS,CAAC,EAAlD,KAAK,WAAA,EAAE,MAAM,YAAqC,CAAC;gBAE3D,yBAAyB;gBACzB,IAAI,KAAK,KAAK,KAAI,CAAC,KAAK,CAAC,KAAK,IAAI,MAAM,KAAK,KAAI,CAAC,KAAK,CAAC,MAAM,EAAE;oBAC9D,KAAI,CAAC,aAAa,EAAE,CAAC;iBACtB;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;OAEG;IACK,+BAAgB,GAAxB;QACE,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;SACzB;IACH,CAAC;IACH,WAAC;AAAD,CAAC,AAxTD,CAA0D,EAAE,GAwT3D","sourcesContent":["import { Chart, Event, Element } from '@antv/g2';\nimport { each } from '@antv/util';\nimport EE from '@antv/event-emitter';\nimport { bind } from 'size-sensor';\nimport { Options, StateName, StateCondition, Size, StateObject, Annotation } from '../types';\nimport { getContainerSize, getAllElementsRecursively, deepAssign, pick } from '../utils';\nimport { Adaptor } from './adaptor';\n\n/** 单独 pick 出来的用于基类的类型定义 */\nexport type PickOptions = Pick<\n Options,\n | 'width'\n | 'height'\n | 'padding'\n | 'appendPadding'\n | 'renderer'\n | 'pixelRatio'\n | 'autoFit'\n | 'syncViewPadding'\n | 'supportCSSTransform'\n | 'limitInPlot'\n | 'locale'\n | 'defaultInteractions'\n>;\n\nconst SOURCE_ATTRIBUTE_NAME = 'data-chart-source-type';\n\n/** plot 图表容器的配置 */\nexport const PLOT_CONTAINER_OPTIONS = [\n 'padding',\n 'appendPadding',\n 'renderer',\n 'pixelRatio',\n 'syncViewPadding',\n 'supportCSSTransform',\n 'limitInPlot',\n];\n\n/**\n * 所有 plot 的基类\n */\nexport abstract class Plot<O extends PickOptions> extends EE {\n /**\n * 获取默认的 options 配置项\n * 每个组件都可以复写\n */\n static getDefaultOptions(): any {\n return {\n renderer: 'canvas',\n xAxis: {\n nice: true,\n label: {\n autoRotate: false,\n autoHide: { type: 'equidistance', cfg: { minGap: 6 } },\n },\n },\n yAxis: {\n nice: true,\n label: {\n autoHide: true,\n autoRotate: false,\n },\n },\n animation: true,\n };\n }\n\n /** plot 类型名称 */\n public abstract readonly type: string;\n /** plot 的 schema 配置 */\n public options: O;\n /** plot 绘制的 dom */\n public readonly container: HTMLElement;\n /** G2 chart 实例 */\n public chart: Chart;\n /** resizer unbind */\n private unbind: () => void;\n\n constructor(container: string | HTMLElement, options: O) {\n super();\n this.container = typeof container === 'string' ? document.getElementById(container) : container;\n\n this.options = deepAssign({}, this.getDefaultOptions(), options);\n\n this.createG2();\n\n this.bindEvents();\n }\n\n /**\n * 创建 G2 实例\n */\n private createG2() {\n const { width, height, defaultInteractions } = this.options;\n\n this.chart = new Chart({\n container: this.container,\n autoFit: false, // G2Plot 使用 size-sensor 进行 autoFit\n ...this.getChartSize(width, height),\n localRefresh: false, // 默认关闭,目前 G 还有一些位置问题,难以排查!\n ...pick(this.options, PLOT_CONTAINER_OPTIONS),\n defaultInteractions,\n });\n\n // 给容器增加标识,知道图表的来源区别于 G2\n this.container.setAttribute(SOURCE_ATTRIBUTE_NAME, 'G2Plot');\n }\n\n /**\n * 计算默认的 chart 大小。逻辑简化:如果存在 width 或 height,则直接使用,否则使用容器大小\n * @param width\n * @param height\n */\n private getChartSize(width: number, height: number): Size {\n const chartSize = getContainerSize(this.container);\n return { width: width || chartSize.width || 400, height: height || chartSize.height || 400 };\n }\n\n /**\n * 绑定代理所有 G2 的事件\n */\n private bindEvents() {\n if (this.chart) {\n this.chart.on('*', (e: Event) => {\n if (e?.type) {\n this.emit(e.type, e);\n }\n });\n }\n }\n\n /**\n * 获取默认的 options 配置项\n * 每个组件都可以复写\n */\n protected getDefaultOptions(): any {\n return Plot.getDefaultOptions();\n }\n\n /**\n * 每个组件有自己的 schema adaptor\n */\n protected abstract getSchemaAdaptor(): Adaptor<O>;\n\n /**\n * 绘制\n */\n public render() {\n // 暴力处理,先清空再渲染,需要 G2 层自行做好更新渲染\n this.chart.clear();\n // 因为子 view 会继承父 view 的 options 配置(包括 legend,所以会导致 legend 重复创建)\n // 所以这里给 chart 实例的 options 配置清空\n // 最好的解法是在 G2 view.clear 方法的时候,重置 options 配置。或者提供方法去 resetOptions\n // #1684 理论上在多 view 图形上,只要存在 custom legend,都存在类似问题(子弹图、双轴图)\n // @ts-ignore\n this.chart.options = {\n data: [],\n animate: true,\n };\n this.chart.views = []; // 删除已有的 views\n // 执行 adaptor\n this.execAdaptor();\n // 渲染\n this.chart.render();\n // 绑定\n this.bindSizeSensor();\n }\n\n /**\n * 更新: 更新配置且重新渲染\n * @param options\n */\n public update(options: Partial<O>) {\n this.updateOption(options);\n this.render();\n }\n\n /**\n * 更新配置\n * @param options\n */\n protected updateOption(options: Partial<O>) {\n this.options = deepAssign({}, this.options, options);\n }\n\n /**\n * 设置状态\n * @param type 状态类型,支持 'active' | 'inactive' | 'selected' 三种\n * @param conditions 条件,支持数组\n * @param status 是否激活,默认 true\n */\n public setState(type: StateName, condition: StateCondition, status: boolean = true) {\n const elements = getAllElementsRecursively(this.chart);\n\n each(elements, (ele: Element) => {\n if (condition(ele.getData())) {\n ele.setState(type, status);\n }\n });\n }\n\n /**\n * 获取状态\n */\n public getStates(): StateObject[] {\n const elements = getAllElementsRecursively(this.chart);\n\n const stateObjects: StateObject[] = [];\n each(elements, (element: Element) => {\n const data = element.getData();\n const states = element.getStates();\n each(states, (state) => {\n stateObjects.push({ data, state, geometry: element.geometry, element });\n });\n });\n\n return stateObjects;\n }\n\n /**\n * 更新数据\n * @override\n * @param options\n */\n public changeData(data: any) {\n // @ts-ignore\n this.update({ data });\n // TODO: 临时方案,最好使用下面的方式去更新数据\n // this.chart.changeData(data);\n }\n\n /**\n * 修改画布大小\n * @param width\n * @param height\n */\n public changeSize(width: number, height: number) {\n this.chart.changeSize(width, height);\n }\n\n /**\n * 增加图表标注。通过 id 标识,如果匹配到,就做更新\n */\n public addAnnotations(annotations: Annotation[]): void {\n const incoming = [...annotations];\n const controller = this.chart.getController('annotation');\n const current = controller.getComponents().map((co) => co.extra);\n\n controller.clear(true);\n for (let i = 0; i < current.length; i++) {\n let annotation = current[i];\n\n const findIndex = incoming.findIndex((item) => item.id && item.id === annotation.id);\n if (findIndex !== -1) {\n annotation = deepAssign({}, annotation, incoming[findIndex]);\n incoming.splice(findIndex, 1);\n }\n controller.annotation(annotation);\n }\n\n incoming.forEach((annotation) => controller.annotation(annotation));\n this.chart.render(true);\n }\n\n /**\n * 删除图表标注。通过 id 标识,如果匹配到,就做删除\n */\n public removeAnnotations(annotations: Array<{ id: string } & Partial<Annotation>>): void {\n const controller = this.chart.getController('annotation');\n const current = controller.getComponents().map((co) => co.extra);\n\n controller.clear(true);\n for (let i = 0; i < current.length; i++) {\n const annotation = current[i];\n\n if (!annotations.find((item) => item.id && item.id === annotation.id)) {\n controller.annotation(annotation);\n }\n }\n\n this.chart.render(true);\n }\n /**\n * 销毁\n */\n public destroy() {\n // 取消 size-sensor 的绑定\n this.unbindSizeSensor();\n // G2 的销毁\n this.chart.destroy();\n // 清空已经绑定的事件\n this.off();\n\n this.container.removeAttribute(SOURCE_ATTRIBUTE_NAME);\n }\n\n /**\n * 执行 adaptor 操作\n */\n protected execAdaptor() {\n const adaptor = this.getSchemaAdaptor();\n\n const { padding, appendPadding } = this.options;\n // 更新 padding\n this.chart.padding = padding;\n // 更新 appendPadding\n this.chart.appendPadding = appendPadding;\n\n // 转化成 G2 API\n adaptor({\n chart: this.chart,\n options: this.options,\n });\n }\n\n /**\n * 当图表容器大小变化的时候,执行的函数\n */\n protected triggerResize() {\n this.chart.forceFit();\n }\n\n /**\n * 绑定 dom 容器大小变化的事件\n */\n private bindSizeSensor() {\n if (this.unbind) {\n return;\n }\n\n const { autoFit = true } = this.options;\n if (autoFit) {\n this.unbind = bind(this.container, () => {\n // 获取最新的宽高信息\n const { width, height } = getContainerSize(this.container);\n\n // 主要是防止绑定的时候触发 resize 回调\n if (width !== this.chart.width || height !== this.chart.height) {\n this.triggerResize();\n }\n });\n }\n }\n\n /**\n * 取消绑定\n */\n private unbindSizeSensor() {\n if (this.unbind) {\n this.unbind();\n this.unbind = undefined;\n }\n }\n}\n"]}
package/esm/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "2.3.36";
1
+ export declare const version = "2.3.40";
2
2
  import * as G2 from '@antv/g2';
3
3
  export { G2 };
4
4
  import { registerLocale } from './core/locale';
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export var version = '2.3.36';
1
+ export var version = '2.3.40';
2
2
  // G2 自定义能力透出
3
3
  import * as G2 from '@antv/g2';
4
4
  export { G2 };
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,CAAC;AAEd,QAAQ;AACR,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,8BAA8B;AAC9B,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,uBAAuB;AACvB,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,WAAW;AACX,OAAO,EAAE,SAA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AC;AAEnD,eAAe;AACf,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/C,oBAAoB;AACpB,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC;AAGzC,2DAA2D;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjD,0CAA0C;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AASpF,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrG,MAAM,CAAC,IAAM,QAAQ,GAAG,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,OAAO,SAAA,EAAE,UAAU,YAAA,EAAE,WAAW,aAAA,EAAE,KAAK,OAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AAE9F,oDAAoD;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export const version = '2.3.36';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\nexport { G2 };\n\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n\n// 类型定义导出\nexport * from './types';\n\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\n\n// 已经废弃,更名为 Mix\nexport { Mix as MultiView } from './plots/mix';\nexport type { MixOptions as MultiViewOptions } from './plots/mix';\n/** 开放多图层图表 (mix) */\nexport { Mix as Mix } from './plots/mix';\nexport type { MixOptions } from './plots/mix';\n\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { line, interval, area, point, polygon, schema } from './adaptor/geometries';\nexport type {\n LineGeometryOptions,\n IntervalGeometryOptions,\n AreaGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { scale, legend, tooltip, annotation, interaction, theme, animation } from './adaptor/common';\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,aAAa;AACb,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,CAAC;AAEd,QAAQ;AACR,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,8BAA8B;AAC9B,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtC,uBAAuB;AACvB,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,WAAW;AACX,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,uBAAuB;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKnC,SAAS;AACT,cAAc,SAAS,CAAC;AA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AAE,MAAM,aAAa,CAAC;AAGzC,2DAA2D;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjD,0CAA0C;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AASpF,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrG,MAAM,CAAC,IAAM,QAAQ,GAAG,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,OAAO,SAAA,EAAE,UAAU,YAAA,EAAE,WAAW,aAAA,EAAE,KAAK,OAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AAE9F,oDAAoD;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export const version = '2.3.40';\n\n// G2 自定义能力透出\nimport * as G2 from '@antv/g2';\nexport { G2 };\n\n// 国际化处理\nimport { registerLocale } from './core/locale';\nimport { EN_US_LOCALE } from './locales/en_US';\nimport { ZH_CN_LOCALE } from './locales/zh_CN';\n/** default locale register */\nregisterLocale('en-US', EN_US_LOCALE);\nregisterLocale('zh-CN', ZH_CN_LOCALE);\n/** 透出 国际化 工具函数,便于使用 */\nexport { registerLocale };\n\n/** 全局变量 */\nexport { setGlobal } from './core/global';\n\n/** G2Plot 的 Plot 基类 */\nexport { Plot } from './core/plot';\n\n/** Adaptor 及其参数的类型定义 */\nexport type { Adaptor, Params } from './core/adaptor';\n\n// 类型定义导出\nexport * from './types';\n\n// 折线图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Line } from './plots/line';\nexport type { LineOptions } from './plots/line';\n\n// 面积图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Area } from './plots/area';\nexport type { AreaOptions } from './plots/area';\n\n// 柱形图及类型定义 | author by [zqlu](https://github.com/zqlu)\nexport { Column } from './plots/column';\nexport type { ColumnOptions } from './plots/column';\n\n// 条形图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ)\nexport { Bar } from './plots/bar';\nexport type { BarOptions } from './plots/bar';\n\n// 饼图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Pie } from './plots/pie';\nexport type { PieOptions } from './plots/pie';\n\n// 玫瑰图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { Rose } from './plots/rose';\nexport type { RoseOptions } from './plots/rose';\n\n// 词云图及类型定义 | author by [zhangzhonghe](https://github.com/zhangzhonghe)\nexport { WordCloud } from './plots/word-cloud';\nexport type { WordCloudOptions } from './plots/word-cloud';\n\n// 散点图及类型定义 | author by [lxfu1](https://github.com/lxfu1)\nexport { Scatter } from './plots/scatter';\nexport type { ScatterOptions } from './plots/scatter';\n\n// 雷达图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Radar } from './plots/radar';\nexport type { RadarOptions } from './plots/radar';\n\n// 混合图形 | author by [liuzhenying](https://github.com/liuzhenying)\nexport { DualAxes } from './plots/dual-axes';\nexport type { DualAxesOptions } from './plots/dual-axes';\n\n// 迷你折线图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyLine } from './plots/tiny-line';\nexport type { TinyLineOptions } from './plots/tiny-line';\n\n// 迷你柱形图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyColumn } from './plots/tiny-column';\nexport type { TinyColumnOptions } from './plots/tiny-column';\n\n// 迷你面积图及类型定义 | author by [connono](https://github.com/connono)\nexport { TinyArea } from './plots/tiny-area';\nexport type { TinyAreaOptions } from './plots/tiny-area';\n\n// 直方图及类型定义 | author by [arcsin1](https://github.com/arcsin1), [visiky](https://github.com/visiky)\nexport { Histogram } from './plots/histogram';\nexport type { HistogramOptions } from './plots/histogram';\n\n// 进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { Progress } from './plots/progress';\nexport type { ProgressOptions } from './plots/progress';\n\n// 环形进度图及类型定义 | author by [connono](https://github.com/connono)\nexport { RingProgress } from './plots/ring-progress';\nexport type { RingProgressOptions } from './plots/ring-progress';\n\n// 热力图及类型定义 | author by [jiazhewang](https://github.com/jiazhewang)\nexport { Heatmap } from './plots/heatmap';\nexport type { HeatmapOptions } from './plots/heatmap';\n\n// 箱线图及类型定义 | author by [BBSQQ](https://github.com/BBSQQ), [visiky](https://github.com/visiky)\nexport { Box } from './plots/box';\nexport type { BoxOptions } from './plots/box';\n\n// 小提琴图及类型定义 | author by [YiSiWang](https://github.com/YiSiWang), [visiky](https://github.com/visiky)\nexport { Violin } from './plots/violin';\nexport type { ViolinOptions } from './plots/violin';\n\n// 韦恩图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Venn } from './plots/venn';\nexport type { VennOptions } from './plots/venn';\n\n// K线图及类型定义 | author by [jhwong](https://github.com/jinhuiWong), [visiky](https://github.com/visiky)\nexport { Stock } from './plots/stock';\nexport type { StockOptions } from './plots/stock';\n\n// 漏斗图及类型定义\nexport { Funnel, FUNNEL_CONVERSATION_FIELD } from './plots/funnel';\nexport type { FunnelOptions } from './plots/funnel';\n\n// 水波图及类型定义 | author by [CarisL](https://github.com/CarisL), [hustcc](https://github.com/hustcc), [pearmini](https://github.com/pearmini)\nexport { Liquid } from './plots/liquid';\nexport type { LiquidOptions } from './plots/liquid';\n\n// 子弹图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { Bullet } from './plots/bullet';\nexport type { BulletOptions } from './plots/bullet';\n\n// 旭日图及类型定义 | author by [lxfu1](https://github.com/lxfu1), [visiky](https://github.com/visiky)\nexport { Sunburst } from './plots/sunburst';\nexport type { SunburstOptions } from './plots/sunburst';\n\n// 仪表盘及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Gauge } from './plots/gauge';\nexport type { GaugeOptions } from './plots/gauge';\n\n// 瀑布图 | author by [visiky](https://github.com/visiky)\nexport { Waterfall } from './plots/waterfall';\nexport type { WaterfallOptions } from './plots/waterfall';\n\n// 玉珏图 | author by [yujs](https://github.com/yujs) | updated by [visiky](https://github.com/visiky)\nexport { RadialBar } from './plots/radial-bar';\nexport type { RadialBarOptions } from './plots/radial-bar';\n\n// 对称条形图及类型定义 | author by [arcsin1](https://github.com/arcsin1)\nexport { BidirectionalBar } from './plots/bidirectional-bar';\nexport type { BidirectionalBarOptions } from './plots/bidirectional-bar';\n\n// 矩形树图\nexport { Treemap } from './plots/treemap';\nexport type { TreemapOptions } from './plots/treemap';\n\n// 桑基图及类型定义 | author by [hustcc](https://github.com/hustcc)\nexport { Sankey } from './plots/sankey';\nexport type { SankeyOptions } from './plots/sankey';\n\n// 弦图及类型定义 | author by [MrSmallLiu](https://github.com/MrSmallLiu), [visiky](https://github.com/visiky)\nexport { Chord } from './plots/chord';\nexport type { ChordOptions } from './plots/chord';\n\n// circle-packing 及类型定义 | author by [visiky](https://github.com/visiky), [Angeli](https://github.com/Angelii)\nexport { CirclePacking } from './plots/circle-packing';\nexport type { CirclePackingOptions } from './plots/circle-packing';\n\n// 以下开放自定义图表开发的能力(目前仅仅是孵化中)\n/** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */\nexport { P } from './plugin';\n\n/** 开放 getCanvasPatterng 方法 */\nexport { getCanvasPattern } from './utils/pattern';\n\n// 已经废弃,更名为 Mix\nexport { Mix as MultiView } from './plots/mix';\nexport type { MixOptions as MultiViewOptions } from './plots/mix';\n/** 开放多图层图表 (mix) */\nexport { Mix as Mix } from './plots/mix';\nexport type { MixOptions } from './plots/mix';\n\n// 分面图及类型定义 | author by [visiky](https://github.com/visiky)\nexport { Facet } from './plots/facet';\nexport type { FacetOptions } from './plots/facet';\n\n/** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */\nexport { flow, measureTextWidth } from './utils';\n\n/** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */\nexport { line, interval, area, point, polygon, schema } from './adaptor/geometries';\nexport type {\n LineGeometryOptions,\n IntervalGeometryOptions,\n AreaGeometryOptions,\n PointGeometryOptions,\n PolygonGeometryOptions,\n SchemaGeometryOptions,\n} from './adaptor/geometries';\n/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */\nimport { scale, legend, tooltip, annotation, interaction, theme, animation } from './adaptor/common';\nexport const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation };\n\n/** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */\nexport { Lab } from './lab';\n"]}
@@ -56,6 +56,10 @@ export declare class DrillDownAction extends Action {
56
56
  * 重置位置,初始化及触发 chart afterchangesize 回调时使用
57
57
  */
58
58
  resetPosition(): void;
59
+ /**
60
+ * 返回上一层
61
+ */
62
+ back(): void;
59
63
  /**
60
64
  * 重置
61
65
  */
@@ -69,7 +73,7 @@ export declare class DrillDownAction extends Action {
69
73
  * 回退事件,点击面包屑时触发
70
74
  * @param historyCache 当前要回退到的历史
71
75
  */
72
- protected back(historyCache: HistoryCache): void;
76
+ protected backTo(historyCache: HistoryCache): void;
73
77
  /**
74
78
  * 获取 mix 默认的配置和用户配置
75
79
  */
@@ -1,6 +1,6 @@
1
1
  import { __assign, __extends } from "tslib";
2
2
  import { Action, Util } from '@antv/g2';
3
- import { get, last, isNil } from '@antv/util';
3
+ import { get, last, isNil, size } from '@antv/util';
4
4
  import { deepAssign } from '../../utils/deep-assign';
5
5
  // 面包屑文字和分割符'/'之间的距离
6
6
  var PADDING = 4;
@@ -84,12 +84,20 @@ var DrillDownAction = /** @class */ (function (_super) {
84
84
  var matrix = Util.transform(null, [['t', point.x + PADDING_LEFT, point.y + bbox.height + PADDING_TOP]]);
85
85
  breadCrumbGroup.setMatrix(matrix);
86
86
  };
87
+ /**
88
+ * 返回上一层
89
+ */
90
+ DrillDownAction.prototype.back = function () {
91
+ if (size(this.historyCache)) {
92
+ this.backTo(this.historyCache.slice(0, -1));
93
+ }
94
+ };
87
95
  /**
88
96
  * 重置
89
97
  */
90
98
  DrillDownAction.prototype.reset = function () {
91
99
  if (this.historyCache[0]) {
92
- this.back(this.historyCache.slice(0, 1));
100
+ this.backTo(this.historyCache.slice(0, 1));
93
101
  }
94
102
  // 清空
95
103
  this.historyCache = [];
@@ -124,7 +132,7 @@ var DrillDownAction = /** @class */ (function (_super) {
124
132
  * 回退事件,点击面包屑时触发
125
133
  * @param historyCache 当前要回退到的历史
126
134
  */
127
- DrillDownAction.prototype.back = function (historyCache) {
135
+ DrillDownAction.prototype.backTo = function (historyCache) {
128
136
  if (!historyCache || historyCache.length <= 0) {
129
137
  return;
130
138
  }
@@ -191,7 +199,7 @@ var DrillDownAction = /** @class */ (function (_super) {
191
199
  var targetId = event.target.get('id');
192
200
  if (targetId !== ((_a = last(cache)) === null || _a === void 0 ? void 0 : _a.id)) {
193
201
  var newHistoryCache = cache.slice(0, cache.findIndex(function (d) { return d.id === targetId; }) + 1);
194
- _this.back(newHistoryCache);
202
+ _this.backTo(newHistoryCache);
195
203
  }
196
204
  });
197
205
  // active 效果内置
@@ -1 +1 @@
1
- {"version":3,"file":"drill-down.js","sourceRoot":"","sources":["../../../src/interactions/actions/drill-down.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAU,IAAI,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,oBAAoB;AACpB,IAAM,OAAO,GAAG,CAAC,CAAC;AAClB,eAAe;AACf,IAAM,YAAY,GAAG,CAAC,CAAC;AACvB,iBAAiB;AACjB,MAAM,CAAC,IAAM,WAAW,GAAG,CAAC,CAAC;AAE7B,oCAAoC;AACpC,MAAM,CAAC,IAAM,gBAAgB,GAAG,uBAAuB,CAAC;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AAC;IAClB,CAAC;IACH,sBAAC;AAAD,CAAC,AApOD,CAAqC,MAAM,GAoO1C","sourcesContent":["import { Action, IGroup, Util } from '@antv/g2';\nimport { get, last, isNil } from '@antv/util';\nimport { Data } from '../../types';\nimport { DrillDownCfg } from '../../types/drill-down';\nimport { deepAssign } from '../../utils/deep-assign';\n\n// 面包屑文字和分割符'/'之间的距离\nconst PADDING = 4;\n// 面包屑位置距离树图的距离\nconst PADDING_LEFT = 0;\n// 面包屑位置距离树图的顶部距离\nexport const PADDING_TOP = 5;\n\n/** Group name of breadCrumb: 面包屑 */\nexport const BREAD_CRUMB_NAME = 'drilldown-bread-crumb';\n\n// 面包屑默认配置\nexport const DEFAULT_BREAD_CRUMB_CONFIG: DrillDownCfg['breadCrumb'] = {\n /** 位置,默认:左上角 */\n position: 'top-left',\n dividerText: '/',\n textStyle: {\n fontSize: 12,\n fill: 'rgba(0, 0, 0, 0.65)',\n cursor: 'pointer',\n },\n activeTextStyle: {\n fill: '#87B5FF',\n },\n};\n\n/**\n * hierarchy 数据转换的参数\n */\nexport const HIERARCHY_DATA_TRANSFORM_PARAMS = 'hierarchy-data-transform-params';\n\n/**\n * Hierarchy plot 节点的数据\n */\nexport type HierarchyNode<N = any /** 节点 */> = {\n /** 节点的原始数据,树型结构(todo 是否更正 key 为 origin) */\n data: { name: string; value?: any; children: { name: string; value?: any }[] };\n /** 在构建节点数据时候,增加的扩展配置, 用于存储 transformData 的入参配置 */\n [HIERARCHY_DATA_TRANSFORM_PARAMS]: object;\n /** 当前的层级结构,每一次下钻都会更新. 不是 unique */\n depth: number;\n /** 当前所处高度,depth + height = 总的层级 */\n height: number;\n parent: N;\n children: N[];\n};\n\ntype HistoryCache = {\n name: string;\n id: string;\n children: Data;\n}[];\n\n/**\n * @description 下钻交互的 action\n * @author liuzhenying\n *\n * 适用于:hierarchy plot\n */\nexport class DrillDownAction extends Action {\n /** Action name */\n public name = 'drill-down';\n\n // 存储历史下钻数据\n protected historyCache: HistoryCache = [];\n // 面包屑 group\n private breadCrumbGroup: IGroup = null;\n // 面包屑基础配置\n private breadCrumbCfg: DrillDownCfg['breadCrumb'] = DEFAULT_BREAD_CRUMB_CONFIG;\n\n /**\n * 点击事件, 下钻数据,并绘制面包屑\n */\n public click() {\n const data = get(this.context, ['event', 'data', 'data']);\n if (!data) return false;\n\n this.drill(data);\n this.drawBreadCrumb();\n }\n\n /**\n * 重置位置,初始化及触发 chart afterchangesize 回调时使用\n */\n public resetPosition() {\n // 当在第一层级未绘制面包屑,此时 changedata 触发 resetPosition 函数,需判断 this.breadCrumbGroup 是否存在\n if (!this.breadCrumbGroup) return;\n const coordinate = this.context.view.getCoordinate();\n const breadCrumbGroup = this.breadCrumbGroup;\n const bbox = breadCrumbGroup.getBBox();\n\n const { position } = this.getButtonCfg();\n\n // @todo 后续抽取一个函数来处理,以及增加 margin 或者 padding 的设置\n // 非 polar 的,需要使用 coordinate,除却图表组件\n let point = { x: coordinate.start.x, y: coordinate.end.y - (bbox.height + PADDING_TOP * 2) };\n if (coordinate.isPolar) {\n // 默认,左上角直接出发\n point = { x: 0, y: 0 };\n }\n if (position === 'bottom-left') {\n // 涉及到坐标反转的问题\n point = { x: coordinate.start.x, y: coordinate.start.y };\n }\n /** PADDING_LEFT, PADDING_TOP 与画布边缘的距离 */\n const matrix = Util.transform(null, [['t', point.x + PADDING_LEFT, point.y + bbox.height + PADDING_TOP]]);\n breadCrumbGroup.setMatrix(matrix);\n }\n\n /**\n * 重置\n */\n public reset(): void {\n if (this.historyCache[0]) {\n this.back(this.historyCache.slice(0, 1));\n }\n // 清空\n this.historyCache = [];\n this.hideCrumbGroup();\n }\n\n /**\n * 下钻数据并更新 view 显示层\n * @param nodeInfo 下钻数据\n */\n protected drill(nodeInfo: HierarchyNode) {\n const { view } = this.context;\n const transformData = get(view, ['interactions', 'drill-down', 'cfg', 'transformData'], (v) => v);\n\n // 重新 update 数据\n const drillData = transformData({ data: nodeInfo.data, ...nodeInfo[HIERARCHY_DATA_TRANSFORM_PARAMS] });\n view.changeData(drillData);\n\n // 存储历史记录\n const historyCache: HistoryCache = [];\n\n let node = nodeInfo;\n while (node) {\n const nodeData = node.data;\n historyCache.unshift({\n id: `${nodeData.name}_${node.height}_${node.depth}`,\n name: nodeData.name,\n // children 是实际数据\n children: transformData({ data: nodeData, ...nodeInfo[HIERARCHY_DATA_TRANSFORM_PARAMS] }),\n });\n node = node.parent;\n }\n\n this.historyCache = (this.historyCache || []).slice(0, -1).concat(historyCache);\n }\n\n /**\n * 回退事件,点击面包屑时触发\n * @param historyCache 当前要回退到的历史\n */\n protected back(historyCache: HistoryCache) {\n if (!historyCache || historyCache.length <= 0) {\n return;\n }\n\n const { view } = this.context;\n const data = last(historyCache).children; // 处理后的数组\n view.changeData(data);\n\n if (historyCache.length > 1) {\n this.historyCache = historyCache;\n this.drawBreadCrumb();\n } else {\n // 清空\n this.historyCache = [];\n this.hideCrumbGroup();\n }\n }\n\n /**\n * 获取 mix 默认的配置和用户配置\n */\n private getButtonCfg() {\n const { view } = this.context;\n const drillDownConfig: DrillDownCfg = get(view, ['interactions', 'drill-down', 'cfg', 'drillDownConfig']);\n\n return deepAssign(this.breadCrumbCfg, drillDownConfig?.breadCrumb, this.cfg);\n }\n\n /**\n * 显示面包屑\n */\n private drawBreadCrumb() {\n this.drawBreadCrumbGroup();\n this.resetPosition();\n this.breadCrumbGroup.show();\n }\n\n /**\n * 绘制 Button 和 文本\n */\n private drawBreadCrumbGroup() {\n const config = this.getButtonCfg();\n const cache = this.historyCache;\n\n // 初始化面包屑 group\n if (!this.breadCrumbGroup) {\n this.breadCrumbGroup = this.context.view.foregroundGroup.addGroup({\n name: BREAD_CRUMB_NAME,\n });\n } else {\n this.breadCrumbGroup.clear();\n }\n\n // 绘制面包屑\n let left = 0;\n cache.forEach((record, index) => {\n // 添加文本\n const textShape = this.breadCrumbGroup.addShape({\n type: 'text',\n id: record.id,\n name: `${BREAD_CRUMB_NAME}_${record.name}_text`,\n attrs: {\n text: index === 0 && !isNil(config.rootText) ? config.rootText : record.name,\n ...config.textStyle,\n x: left,\n y: 0,\n },\n });\n\n const textShapeBox = textShape.getBBox();\n left += textShapeBox.width + PADDING;\n\n // 增加文本事件\n textShape.on('click', (event) => {\n const targetId = event.target.get('id');\n if (targetId !== last(cache)?.id) {\n const newHistoryCache = cache.slice(0, cache.findIndex((d) => d.id === targetId) + 1);\n this.back(newHistoryCache);\n }\n });\n // active 效果内置\n textShape.on('mouseenter', (event) => {\n const targetId = event.target.get('id');\n if (targetId !== last(cache)?.id) {\n textShape.attr(config.activeTextStyle);\n } else {\n textShape.attr({ cursor: 'default' });\n }\n });\n textShape.on('mouseleave', () => {\n textShape.attr(config.textStyle);\n });\n\n if (index < cache.length - 1) {\n // 添加反斜杠\n const dividerShape = this.breadCrumbGroup.addShape({\n type: 'text',\n name: `${config.name}_${record.name}_divider`,\n attrs: {\n text: config.dividerText,\n ...config.textStyle,\n x: left,\n y: 0,\n },\n });\n\n const dividerBox = dividerShape.getBBox();\n left += dividerBox.width + PADDING;\n }\n });\n }\n\n /**\n * 隐藏面包屑\n */\n private hideCrumbGroup() {\n if (this.breadCrumbGroup) {\n this.breadCrumbGroup.hide();\n }\n }\n\n /**\n * @override\n * destroy: 销毁资源\n */\n public destroy() {\n if (this.breadCrumbGroup) {\n this.breadCrumbGroup.remove();\n }\n super.destroy();\n }\n}\n"]}
1
+ {"version":3,"file":"drill-down.js","sourceRoot":"","sources":["../../../src/interactions/actions/drill-down.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAU,IAAI,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,oBAAoB;AACpB,IAAM,OAAO,GAAG,CAAC,CAAC;AAClB,eAAe;AACf,IAAM,YAAY,GAAG,CAAC,CAAC;AAC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AAK,GAAG,OAAO,CAAC;aACpC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,wCAAc,GAAtB;QACE,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;SAC7B;IACH,CAAC;IAED;;;OAGG;IACI,iCAAO,GAAd;QACE,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;SAC/B;QACD,iBAAM,OAAO,WAAE,CAAC;IAClB,CAAC;IACH,sBAAC;AAAD,CAAC,AA7OD,CAAqC,MAAM,GA6O1C","sourcesContent":["import { Action, IGroup, Util } from '@antv/g2';\nimport { get, last, isNil, size } from '@antv/util';\nimport { Data } from '../../types';\nimport { DrillDownCfg } from '../../types/drill-down';\nimport { deepAssign } from '../../utils/deep-assign';\n\n// 面包屑文字和分割符'/'之间的距离\nconst PADDING = 4;\n// 面包屑位置距离树图的距离\nconst PADDING_LEFT = 0;\n// 面包屑位置距离树图的顶部距离\nexport const PADDING_TOP = 5;\n\n/** Group name of breadCrumb: 面包屑 */\nexport const BREAD_CRUMB_NAME = 'drilldown-bread-crumb';\n\n// 面包屑默认配置\nexport const DEFAULT_BREAD_CRUMB_CONFIG: DrillDownCfg['breadCrumb'] = {\n /** 位置,默认:左上角 */\n position: 'top-left',\n dividerText: '/',\n textStyle: {\n fontSize: 12,\n fill: 'rgba(0, 0, 0, 0.65)',\n cursor: 'pointer',\n },\n activeTextStyle: {\n fill: '#87B5FF',\n },\n};\n\n/**\n * hierarchy 数据转换的参数\n */\nexport const HIERARCHY_DATA_TRANSFORM_PARAMS = 'hierarchy-data-transform-params';\n\n/**\n * Hierarchy plot 节点的数据\n */\nexport type HierarchyNode<N = any /** 节点 */> = {\n /** 节点的原始数据,树型结构(todo 是否更正 key 为 origin) */\n data: { name: string; value?: any; children: { name: string; value?: any }[] };\n /** 在构建节点数据时候,增加的扩展配置, 用于存储 transformData 的入参配置 */\n [HIERARCHY_DATA_TRANSFORM_PARAMS]: object;\n /** 当前的层级结构,每一次下钻都会更新. 不是 unique */\n depth: number;\n /** 当前所处高度,depth + height = 总的层级 */\n height: number;\n parent: N;\n children: N[];\n};\n\ntype HistoryCache = {\n name: string;\n id: string;\n children: Data;\n}[];\n\n/**\n * @description 下钻交互的 action\n * @author liuzhenying\n *\n * 适用于:hierarchy plot\n */\nexport class DrillDownAction extends Action {\n /** Action name */\n public name = 'drill-down';\n\n // 存储历史下钻数据\n protected historyCache: HistoryCache = [];\n // 面包屑 group\n private breadCrumbGroup: IGroup = null;\n // 面包屑基础配置\n private breadCrumbCfg: DrillDownCfg['breadCrumb'] = DEFAULT_BREAD_CRUMB_CONFIG;\n\n /**\n * 点击事件, 下钻数据,并绘制面包屑\n */\n public click() {\n const data = get(this.context, ['event', 'data', 'data']);\n if (!data) return false;\n\n this.drill(data);\n this.drawBreadCrumb();\n }\n\n /**\n * 重置位置,初始化及触发 chart afterchangesize 回调时使用\n */\n public resetPosition() {\n // 当在第一层级未绘制面包屑,此时 changedata 触发 resetPosition 函数,需判断 this.breadCrumbGroup 是否存在\n if (!this.breadCrumbGroup) return;\n const coordinate = this.context.view.getCoordinate();\n const breadCrumbGroup = this.breadCrumbGroup;\n const bbox = breadCrumbGroup.getBBox();\n\n const { position } = this.getButtonCfg();\n\n // @todo 后续抽取一个函数来处理,以及增加 margin 或者 padding 的设置\n // 非 polar 的,需要使用 coordinate,除却图表组件\n let point = { x: coordinate.start.x, y: coordinate.end.y - (bbox.height + PADDING_TOP * 2) };\n if (coordinate.isPolar) {\n // 默认,左上角直接出发\n point = { x: 0, y: 0 };\n }\n if (position === 'bottom-left') {\n // 涉及到坐标反转的问题\n point = { x: coordinate.start.x, y: coordinate.start.y };\n }\n /** PADDING_LEFT, PADDING_TOP 与画布边缘的距离 */\n const matrix = Util.transform(null, [['t', point.x + PADDING_LEFT, point.y + bbox.height + PADDING_TOP]]);\n breadCrumbGroup.setMatrix(matrix);\n }\n\n /**\n * 返回上一层\n */\n public back(): void {\n if (size(this.historyCache)) {\n this.backTo(this.historyCache.slice(0, -1));\n }\n }\n\n /**\n * 重置\n */\n public reset(): void {\n if (this.historyCache[0]) {\n this.backTo(this.historyCache.slice(0, 1));\n }\n // 清空\n this.historyCache = [];\n this.hideCrumbGroup();\n }\n\n /**\n * 下钻数据并更新 view 显示层\n * @param nodeInfo 下钻数据\n */\n protected drill(nodeInfo: HierarchyNode) {\n const { view } = this.context;\n const transformData = get(view, ['interactions', 'drill-down', 'cfg', 'transformData'], (v) => v);\n\n // 重新 update 数据\n const drillData = transformData({ data: nodeInfo.data, ...nodeInfo[HIERARCHY_DATA_TRANSFORM_PARAMS] });\n view.changeData(drillData);\n\n // 存储历史记录\n const historyCache: HistoryCache = [];\n\n let node = nodeInfo;\n while (node) {\n const nodeData = node.data;\n historyCache.unshift({\n id: `${nodeData.name}_${node.height}_${node.depth}`,\n name: nodeData.name,\n // children 是实际数据\n children: transformData({ data: nodeData, ...nodeInfo[HIERARCHY_DATA_TRANSFORM_PARAMS] }),\n });\n node = node.parent;\n }\n\n this.historyCache = (this.historyCache || []).slice(0, -1).concat(historyCache);\n }\n\n /**\n * 回退事件,点击面包屑时触发\n * @param historyCache 当前要回退到的历史\n */\n protected backTo(historyCache: HistoryCache) {\n if (!historyCache || historyCache.length <= 0) {\n return;\n }\n\n const { view } = this.context;\n const data = last(historyCache).children; // 处理后的数组\n view.changeData(data);\n\n if (historyCache.length > 1) {\n this.historyCache = historyCache;\n this.drawBreadCrumb();\n } else {\n // 清空\n this.historyCache = [];\n this.hideCrumbGroup();\n }\n }\n\n /**\n * 获取 mix 默认的配置和用户配置\n */\n private getButtonCfg() {\n const { view } = this.context;\n const drillDownConfig: DrillDownCfg = get(view, ['interactions', 'drill-down', 'cfg', 'drillDownConfig']);\n\n return deepAssign(this.breadCrumbCfg, drillDownConfig?.breadCrumb, this.cfg);\n }\n\n /**\n * 显示面包屑\n */\n private drawBreadCrumb() {\n this.drawBreadCrumbGroup();\n this.resetPosition();\n this.breadCrumbGroup.show();\n }\n\n /**\n * 绘制 Button 和 文本\n */\n private drawBreadCrumbGroup() {\n const config = this.getButtonCfg();\n const cache = this.historyCache;\n\n // 初始化面包屑 group\n if (!this.breadCrumbGroup) {\n this.breadCrumbGroup = this.context.view.foregroundGroup.addGroup({\n name: BREAD_CRUMB_NAME,\n });\n } else {\n this.breadCrumbGroup.clear();\n }\n\n // 绘制面包屑\n let left = 0;\n cache.forEach((record, index) => {\n // 添加文本\n const textShape = this.breadCrumbGroup.addShape({\n type: 'text',\n id: record.id,\n name: `${BREAD_CRUMB_NAME}_${record.name}_text`,\n attrs: {\n text: index === 0 && !isNil(config.rootText) ? config.rootText : record.name,\n ...config.textStyle,\n x: left,\n y: 0,\n },\n });\n\n const textShapeBox = textShape.getBBox();\n left += textShapeBox.width + PADDING;\n\n // 增加文本事件\n textShape.on('click', (event) => {\n const targetId = event.target.get('id');\n if (targetId !== last(cache)?.id) {\n const newHistoryCache = cache.slice(0, cache.findIndex((d) => d.id === targetId) + 1);\n this.backTo(newHistoryCache);\n }\n });\n // active 效果内置\n textShape.on('mouseenter', (event) => {\n const targetId = event.target.get('id');\n if (targetId !== last(cache)?.id) {\n textShape.attr(config.activeTextStyle);\n } else {\n textShape.attr({ cursor: 'default' });\n }\n });\n textShape.on('mouseleave', () => {\n textShape.attr(config.textStyle);\n });\n\n if (index < cache.length - 1) {\n // 添加反斜杠\n const dividerShape = this.breadCrumbGroup.addShape({\n type: 'text',\n name: `${config.name}_${record.name}_divider`,\n attrs: {\n text: config.dividerText,\n ...config.textStyle,\n x: left,\n y: 0,\n },\n });\n\n const dividerBox = dividerShape.getBBox();\n left += dividerBox.width + PADDING;\n }\n });\n }\n\n /**\n * 隐藏面包屑\n */\n private hideCrumbGroup() {\n if (this.breadCrumbGroup) {\n this.breadCrumbGroup.hide();\n }\n }\n\n /**\n * @override\n * destroy: 销毁资源\n */\n public destroy() {\n if (this.breadCrumbGroup) {\n this.breadCrumbGroup.remove();\n }\n super.destroy();\n }\n}\n"]}
@@ -8,11 +8,28 @@ export function isParentNode(context) {
8
8
  var data = get(context, ['event', 'data', 'data'], {});
9
9
  return isArray(data.children) && data.children.length > 0;
10
10
  }
11
+ /**
12
+ * 判断是否在中心
13
+ */
14
+ function inCenter(context) {
15
+ var coordinate = context.view.getCoordinate();
16
+ var innerRadius = coordinate.innerRadius;
17
+ if (innerRadius) {
18
+ var _a = context.event, x = _a.x, y = _a.y;
19
+ var _b = coordinate.center, centerX = _b.x, centerY = _b.y;
20
+ var r = coordinate.getRadius() * innerRadius;
21
+ var distance = Math.sqrt(Math.pow((centerX - x), 2) + Math.pow((centerY - y), 2));
22
+ return distance < r;
23
+ }
24
+ return false;
25
+ }
11
26
  registerAction('drill-down-action', DrillDownAction);
12
27
  registerInteraction('drill-down', {
13
28
  showEnable: [
14
29
  { trigger: 'element:mouseenter', action: 'cursor:pointer', isEnable: isParentNode },
15
30
  { trigger: 'element:mouseleave', action: 'cursor:default' },
31
+ // 中心处,肯定会触发 element:mouseleave 操作
32
+ { trigger: 'element:mouseleave', action: 'cursor:pointer', isEnable: inCenter },
16
33
  ],
17
34
  start: [
18
35
  {
@@ -24,6 +41,12 @@ registerInteraction('drill-down', {
24
41
  trigger: 'afterchangesize',
25
42
  action: ['drill-down-action:resetPosition'],
26
43
  },
44
+ {
45
+ // 点击中心,返回上一层
46
+ trigger: 'click',
47
+ isEnable: inCenter,
48
+ action: ['drill-down-action:back'],
49
+ },
27
50
  ],
28
51
  });
29
52
  //# sourceMappingURL=drill-down.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drill-down.js","sourceRoot":"","sources":["../../src/interactions/drill-down.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,OAAO;IAClC,IAAM,IAAI,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;AAC5D,CAAC;AAED,cAAc,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;AAErD,mBAAmB,CAAC,YAAY,EAAE;IAChC,UAAU,EAAE;QACV,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE;QACnF,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,gBAAgB,EAAE;KAC5D;IACD,KAAK,EAAE;QACL;YACE,OAAO,EAAE,eAAe;YACxB,QAAQ,EAAE,YAAY;YACtB,MAAM,EAAE,CAAC,yBAAyB,CAAC;SACpC;QACD;YACE,OAAO,EAAE,iBAAiB;YAC1B,MAAM,EAAE,CAAC,iCAAiC,CAAC;SAC5C;KACF;CACF,CAAC,CAAC","sourcesContent":["import { registerInteraction, registerAction } from '@antv/g2';\nimport { get, isArray } from '@antv/util';\nimport { DrillDownAction } from './actions/drill-down';\n\n/**\n * 判断是否为父节点\n */\nexport function isParentNode(context) {\n const data = get(context, ['event', 'data', 'data'], {});\n return isArray(data.children) && data.children.length > 0;\n}\n\nregisterAction('drill-down-action', DrillDownAction);\n\nregisterInteraction('drill-down', {\n showEnable: [\n { trigger: 'element:mouseenter', action: 'cursor:pointer', isEnable: isParentNode },\n { trigger: 'element:mouseleave', action: 'cursor:default' },\n ],\n start: [\n {\n trigger: 'element:click',\n isEnable: isParentNode,\n action: ['drill-down-action:click'],\n },\n {\n trigger: 'afterchangesize',\n action: ['drill-down-action:resetPosition'],\n },\n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,eAAe,CAAC,CAAC;AACrD,mBAAmB,CAAC,YAAY,EAAE;IAChC,UAAU,EAAE;QACV,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE;QACnF,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,gBAAgB,EAAE;QAC3D,kCAAkC;QAClC,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE;KAChF;IACD,KAAK,EAAE;QACL;YACE,OAAO,EAAE,eAAe;YACxB,QAAQ,EAAE,YAAY;YACtB,MAAM,EAAE,CAAC,yBAAyB,CAAC;SACpC;QACD;YACE,OAAO,EAAE,iBAAiB;YAC1B,MAAM,EAAE,CAAC,iCAAiC,CAAC;SAC5C;QACD;YACE,aAAa;YACb,OAAO,EAAE,OAAO;YAChB,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE,CAAC,wBAAwB,CAAC;SACnC;KACF;CACF,CAAC,CAAC","sourcesContent":["import { registerInteraction, registerAction } from '@antv/g2';\nimport { get, isArray } from '@antv/util';\nimport { DrillDownAction } from './actions/drill-down';\n\n/**\n * 判断是否为父节点\n */\nexport function isParentNode(context) {\n const data = get(context, ['event', 'data', 'data'], {});\n return isArray(data.children) && data.children.length > 0;\n}\n\n/**\n * 判断是否在中心\n */\nfunction inCenter(context) {\n const coordinate = context.view.getCoordinate();\n const { innerRadius } = coordinate;\n if (innerRadius) {\n const { x, y } = context.event;\n const { x: centerX, y: centerY } = coordinate.center;\n const r = coordinate.getRadius() * innerRadius;\n const distance = Math.sqrt((centerX - x) ** 2 + (centerY - y) ** 2);\n return distance < r;\n }\n return false;\n}\n\nregisterAction('drill-down-action', DrillDownAction);\nregisterInteraction('drill-down', {\n showEnable: [\n { trigger: 'element:mouseenter', action: 'cursor:pointer', isEnable: isParentNode },\n { trigger: 'element:mouseleave', action: 'cursor:default' },\n // 中心处,肯定会触发 element:mouseleave 操作\n { trigger: 'element:mouseleave', action: 'cursor:pointer', isEnable: inCenter },\n ],\n start: [\n {\n trigger: 'element:click',\n isEnable: isParentNode,\n action: ['drill-down-action:click'],\n },\n {\n trigger: 'afterchangesize',\n action: ['drill-down-action:resetPosition'],\n },\n {\n // 点击中心,返回上一层\n trigger: 'click',\n isEnable: inCenter,\n action: ['drill-down-action:back'],\n },\n ],\n});\n"]}
@@ -38,11 +38,14 @@ function geometry(params) {
38
38
  },
39
39
  },
40
40
  });
41
- var second = deepAssign({}, primary, { options: { tooltip: false } });
41
+ // 线默认 2px
42
+ var lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {
43
+ options: { sizeField: seriesField, tooltip: false },
44
+ });
42
45
  var pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
43
46
  // area geometry 处理
44
47
  area(primary);
45
- line(second);
48
+ line(lineParams);
46
49
  point(pointParams);
47
50
  return params;
48
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/area/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,CAAC;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oBACN,EAAE,IAAI,EAAE,eAAe,EAAE;oBACzB,EAAE,IAAI,EAAE,sBAAsB,EAAE;oBAChC,EAAE,IAAI,EAAE,uBAAuB,EAAE;oBACjC,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;iBACnD,IACE,cAAc,CAAC,GAAG,CAAC,CACvB;SACF,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,MAAM,CAAC,MAA2B;IACjC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,OAAO,GAA6B,OAAO,QAApC,EAAE,SAAS,GAAkB,OAAO,UAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IACpD,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,WAAW,EAAE;QACzC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAC,CAAW;YACjC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,MAA2B;IACjD,0BAA0B;IAC1B,OAAO,IAAI,CACT,KAAK,EACL,OAAO,CAAC,WAAW,CAAC,EACpB,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,UAAU,EAAE,EACZ,WAAW,EACX,SAAS,EACT,WAAW,CACZ,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { each } from '@antv/util';\nimport { tooltip, slider, interaction, animation, theme, annotation, limitInPlot, pattern } from '../../adaptor/common';\nimport { findGeometry } from '../../utils';\nimport { Params } from '../../core/adaptor';\nimport { area, point, line } from '../../adaptor/geometries';\nimport { flow, transformLabel, deepAssign } from '../../utils';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { Datum } from '../../types';\nimport { meta, legend, axis } from '../line/adaptor';\nimport { AreaOptions } from './types';\n\nexport { meta };\n\n/**\n * geometry 处理\n * @param params\n */\nfunction geometry(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const {\n data,\n areaStyle,\n color,\n point: pointMapping,\n line: lineMapping,\n isPercent,\n xField,\n yField,\n tooltip,\n seriesField,\n startOnZero,\n } = options;\n const pointState = pointMapping?.state;\n\n const chartData = getDataWhetherPecentage(data, yField, xField, yField, isPercent);\n chart.data(chartData);\n // 百分比堆积图,默认会给一个 % 格式化逻辑, 用户可自定义\n const tooltipOptions = isPercent\n ? {\n formatter: (datum: Datum) => ({\n name: datum[seriesField] || datum[xField],\n value: (Number(datum[yField]) * 100).toFixed(2) + '%',\n }),\n ...tooltip,\n }\n : tooltip;\n const primary = deepAssign({}, params, {\n options: {\n area: { color, style: areaStyle },\n // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。\n // 如果存在,才设置,否则为空\n line: lineMapping && {\n color,\n ...lineMapping,\n },\n point: pointMapping && {\n color,\n ...pointMapping,\n },\n tooltip: tooltipOptions,\n // label 不传递给各个 geometry adaptor,由 label adaptor 处理\n label: undefined,\n args: {\n startOnZero,\n },\n },\n });\n const second = deepAssign({}, primary, { options: { tooltip: false } });\n const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n\n // area geometry 处理\n area(primary);\n line(second);\n point(pointParams);\n\n return params;\n}\n\n/**\n * 数据标签\n * @param params\n */\nfunction label(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { label, yField } = options;\n\n const areaGeometry = findGeometry(chart, 'area');\n\n // label 为 false, 空 则不显示 label\n if (!label) {\n areaGeometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n areaGeometry.label({\n fields: [yField],\n callback,\n cfg: {\n layout: [\n { type: 'limit-in-plot' },\n { type: 'path-adjust-position' },\n { type: 'point-adjust-position' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ],\n ...transformLabel(cfg),\n },\n });\n }\n\n return params;\n}\n\n/**\n * 处理 adjust\n * @param params\n */\nfunction adjust(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { isStack, isPercent, seriesField } = options;\n if ((isPercent || isStack) && seriesField) {\n each(chart.geometries, (g: Geometry) => {\n g.adjust('stack');\n });\n }\n\n return params;\n}\n\n/**\n * 折线图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<AreaOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n theme,\n pattern('areaStyle'),\n geometry,\n meta,\n adjust,\n axis,\n legend,\n tooltip,\n label,\n slider,\n annotation(),\n interaction,\n animation,\n limitInPlot\n )(params);\n}\n"]}
1
+ {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/area/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB;;;GAGG;AACH,SAAS,QAAQ,CAAC,MAA2B;IACnC,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,CAAC;YAChB,QAAQ,UAAA;YACR,GAAG,aACD,MAAM,EAAE;oBACN,EAAE,IAAI,EAAE,eAAe,EAAE;oBACzB,EAAE,IAAI,EAAE,sBAAsB,EAAE;oBAChC,EAAE,IAAI,EAAE,uBAAuB,EAAE;oBACjC,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;iBACnD,IACE,cAAc,CAAC,GAAG,CAAC,CACvB;SACF,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,MAAM,CAAC,MAA2B;IACjC,IAAA,KAAK,GAAc,MAAM,MAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC1B,IAAA,OAAO,GAA6B,OAAO,QAApC,EAAE,SAAS,GAAkB,OAAO,UAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IACpD,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,WAAW,EAAE;QACzC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAC,CAAW;YACjC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,MAA2B;IACjD,0BAA0B;IAC1B,OAAO,IAAI,CACT,KAAK,EACL,OAAO,CAAC,WAAW,CAAC,EACpB,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,UAAU,EAAE,EACZ,WAAW,EACX,SAAS,EACT,WAAW,CACZ,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { each } from '@antv/util';\nimport { tooltip, slider, interaction, animation, theme, annotation, limitInPlot, pattern } from '../../adaptor/common';\nimport { findGeometry } from '../../utils';\nimport { Params } from '../../core/adaptor';\nimport { area, point, line } from '../../adaptor/geometries';\nimport { flow, transformLabel, deepAssign } from '../../utils';\nimport { getDataWhetherPecentage } from '../../utils/transform/percent';\nimport { Datum } from '../../types';\nimport { meta, legend, axis } from '../line/adaptor';\nimport { AreaOptions } from './types';\n\nexport { meta };\n\n/**\n * geometry 处理\n * @param params\n */\nfunction geometry(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const {\n data,\n areaStyle,\n color,\n point: pointMapping,\n line: lineMapping,\n isPercent,\n xField,\n yField,\n tooltip,\n seriesField,\n startOnZero,\n } = options;\n const pointState = pointMapping?.state;\n\n const chartData = getDataWhetherPecentage(data, yField, xField, yField, isPercent);\n chart.data(chartData);\n // 百分比堆积图,默认会给一个 % 格式化逻辑, 用户可自定义\n const tooltipOptions = isPercent\n ? {\n formatter: (datum: Datum) => ({\n name: datum[seriesField] || datum[xField],\n value: (Number(datum[yField]) * 100).toFixed(2) + '%',\n }),\n ...tooltip,\n }\n : tooltip;\n const primary = deepAssign({}, params, {\n options: {\n area: { color, style: areaStyle },\n // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。\n // 如果存在,才设置,否则为空\n line: lineMapping && {\n color,\n ...lineMapping,\n },\n point: pointMapping && {\n color,\n ...pointMapping,\n },\n tooltip: tooltipOptions,\n // label 不传递给各个 geometry adaptor,由 label adaptor 处理\n label: undefined,\n args: {\n startOnZero,\n },\n },\n });\n // 线默认 2px\n const lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {\n options: { sizeField: seriesField, tooltip: false },\n });\n const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });\n\n // area geometry 处理\n area(primary);\n line(lineParams);\n point(pointParams);\n\n return params;\n}\n\n/**\n * 数据标签\n * @param params\n */\nfunction label(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { label, yField } = options;\n\n const areaGeometry = findGeometry(chart, 'area');\n\n // label 为 false, 空 则不显示 label\n if (!label) {\n areaGeometry.label(false);\n } else {\n const { callback, ...cfg } = label;\n areaGeometry.label({\n fields: [yField],\n callback,\n cfg: {\n layout: [\n { type: 'limit-in-plot' },\n { type: 'path-adjust-position' },\n { type: 'point-adjust-position' },\n { type: 'limit-in-plot', cfg: { action: 'hide' } },\n ],\n ...transformLabel(cfg),\n },\n });\n }\n\n return params;\n}\n\n/**\n * 处理 adjust\n * @param params\n */\nfunction adjust(params: Params<AreaOptions>): Params<AreaOptions> {\n const { chart, options } = params;\n const { isStack, isPercent, seriesField } = options;\n if ((isPercent || isStack) && seriesField) {\n each(chart.geometries, (g: Geometry) => {\n g.adjust('stack');\n });\n }\n\n return params;\n}\n\n/**\n * 折线图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<AreaOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n theme,\n pattern('areaStyle'),\n geometry,\n meta,\n adjust,\n axis,\n legend,\n tooltip,\n label,\n slider,\n annotation(),\n interaction,\n animation,\n limitInPlot\n )(params);\n}\n"]}
@@ -1,8 +1,7 @@
1
- import { PointGeometryOptions } from '../../adaptor/geometries';
1
+ import { GeometryOptions, LineGeometryOptions, PointGeometryOptions } from '../../adaptor/geometries';
2
2
  import { Options, StyleAttr } from '../../types';
3
- import { LineGeometryOptions } from '../../adaptor/geometries';
4
3
  /** 面积图的配置类型定义 */
5
- export interface AreaOptions extends Options {
4
+ export interface AreaOptions extends Options, Pick<GeometryOptions, 'customInfo'> {
6
5
  /** x 轴字段 */
7
6
  readonly xField?: string;
8
7
  /** y 轴字段 */