@antv/g2plot 2.4.8 → 2.4.11

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 (273) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +1 -1
  3. package/dist/g2plot.min.js +4 -4
  4. package/dist/g2plot.min.js.map +1 -1
  5. package/esm/core/plot.d.ts +2 -2
  6. package/esm/core/plot.js +4 -3
  7. package/esm/core/plot.js.map +1 -1
  8. package/esm/index.d.ts +2 -2
  9. package/esm/index.js +2 -2
  10. package/esm/index.js.map +1 -1
  11. package/esm/plots/area/types.d.ts +35 -10
  12. package/esm/plots/area/types.js.map +1 -1
  13. package/esm/plots/bar/types.d.ts +16 -3
  14. package/esm/plots/bar/types.js.map +1 -1
  15. package/esm/plots/bidirectional-bar/types.d.ts +21 -6
  16. package/esm/plots/bidirectional-bar/types.js.map +1 -1
  17. package/esm/plots/box/types.d.ts +20 -6
  18. package/esm/plots/box/types.js.map +1 -1
  19. package/esm/plots/bullet/types.d.ts +36 -9
  20. package/esm/plots/bullet/types.js.map +1 -1
  21. package/esm/plots/chord/types.d.ts +14 -10
  22. package/esm/plots/chord/types.js.map +1 -1
  23. package/esm/plots/circle-packing/types.d.ts +25 -8
  24. package/esm/plots/circle-packing/types.js.map +1 -1
  25. package/esm/plots/column/types.d.ts +57 -16
  26. package/esm/plots/column/types.js.map +1 -1
  27. package/esm/plots/dual-axes/types.d.ts +31 -6
  28. package/esm/plots/dual-axes/types.js.map +1 -1
  29. package/esm/plots/facet/types.d.ts +54 -34
  30. package/esm/plots/facet/types.js.map +1 -1
  31. package/esm/plots/funnel/geometries/compare.js +2 -1
  32. package/esm/plots/funnel/geometries/compare.js.map +1 -1
  33. package/esm/plots/funnel/geometries/facet.js +2 -1
  34. package/esm/plots/funnel/geometries/facet.js.map +1 -1
  35. package/esm/plots/funnel/types.d.ts +45 -11
  36. package/esm/plots/funnel/types.js.map +1 -1
  37. package/esm/plots/gauge/adaptor.js +31 -3
  38. package/esm/plots/gauge/adaptor.js.map +1 -1
  39. package/esm/plots/gauge/types.d.ts +84 -22
  40. package/esm/plots/gauge/types.js.map +1 -1
  41. package/esm/plots/heatmap/types.d.ts +47 -12
  42. package/esm/plots/heatmap/types.js.map +1 -1
  43. package/esm/plots/histogram/types.d.ts +17 -6
  44. package/esm/plots/histogram/types.js.map +1 -1
  45. package/esm/plots/line/types.d.ts +42 -12
  46. package/esm/plots/line/types.js.map +1 -1
  47. package/esm/plots/liquid/index.d.ts +1 -0
  48. package/esm/plots/liquid/index.js +1 -0
  49. package/esm/plots/liquid/index.js.map +1 -1
  50. package/esm/plots/liquid/shapes/liquid.d.ts +16 -1
  51. package/esm/plots/liquid/shapes/liquid.js +13 -8
  52. package/esm/plots/liquid/shapes/liquid.js.map +1 -1
  53. package/esm/plots/liquid/types.d.ts +56 -16
  54. package/esm/plots/liquid/types.js.map +1 -1
  55. package/esm/plots/mix/types.d.ts +31 -22
  56. package/esm/plots/mix/types.js.map +1 -1
  57. package/esm/plots/pie/types.d.ts +27 -10
  58. package/esm/plots/pie/types.js.map +1 -1
  59. package/esm/plots/progress/types.d.ts +13 -4
  60. package/esm/plots/progress/types.js.map +1 -1
  61. package/esm/plots/radar/types.d.ts +39 -12
  62. package/esm/plots/radar/types.js.map +1 -1
  63. package/esm/plots/radial-bar/types.d.ts +39 -12
  64. package/esm/plots/radial-bar/types.js.map +1 -1
  65. package/esm/plots/ring-progress/types.d.ts +18 -6
  66. package/esm/plots/ring-progress/types.js.map +1 -1
  67. package/esm/plots/rose/types.d.ts +32 -12
  68. package/esm/plots/rose/types.js.map +1 -1
  69. package/esm/plots/sankey/types.d.ts +51 -32
  70. package/esm/plots/sankey/types.js.map +1 -1
  71. package/esm/plots/scatter/types.d.ts +76 -22
  72. package/esm/plots/scatter/types.js.map +1 -1
  73. package/esm/plots/stock/types.d.ts +20 -7
  74. package/esm/plots/stock/types.js.map +1 -1
  75. package/esm/plots/sunburst/types.d.ts +40 -12
  76. package/esm/plots/sunburst/types.js.map +1 -1
  77. package/esm/plots/tiny-area/types.d.ts +16 -5
  78. package/esm/plots/tiny-area/types.js.map +1 -1
  79. package/esm/plots/tiny-column/types.d.ts +10 -3
  80. package/esm/plots/tiny-column/types.js.map +1 -1
  81. package/esm/plots/tiny-line/types.d.ts +17 -5
  82. package/esm/plots/tiny-line/types.js.map +1 -1
  83. package/esm/plots/treemap/types.d.ts +17 -6
  84. package/esm/plots/treemap/types.js.map +1 -1
  85. package/esm/plots/venn/types.d.ts +20 -6
  86. package/esm/plots/venn/types.js.map +1 -1
  87. package/esm/plots/violin/types.d.ts +52 -17
  88. package/esm/plots/violin/types.js.map +1 -1
  89. package/esm/plots/waterfall/types.d.ts +42 -10
  90. package/esm/plots/waterfall/types.js.map +1 -1
  91. package/esm/plots/word-cloud/types.d.ts +91 -44
  92. package/esm/plots/word-cloud/types.js.map +1 -1
  93. package/esm/types/button.d.ts +8 -4
  94. package/esm/types/button.js.map +1 -1
  95. package/esm/types/common.d.ts +145 -33
  96. package/esm/types/common.js.map +1 -1
  97. package/esm/types/drill-down.d.ts +28 -7
  98. package/esm/types/drill-down.js.map +1 -1
  99. package/esm/types/interaction.d.ts +26 -6
  100. package/esm/types/interaction.js.map +1 -1
  101. package/esm/types/label.d.ts +11 -3
  102. package/esm/types/label.js.map +1 -1
  103. package/esm/types/meta.d.ts +4 -7
  104. package/esm/types/meta.js.map +1 -1
  105. package/esm/types/pattern.d.ts +58 -18
  106. package/esm/types/pattern.js.map +1 -1
  107. package/esm/types/state.d.ts +11 -3
  108. package/esm/types/state.js.map +1 -1
  109. package/esm/types/statistic.d.ts +38 -6
  110. package/esm/types/statistic.js.map +1 -1
  111. package/esm/types/tooltip.d.ts +7 -2
  112. package/esm/types/tooltip.js.map +1 -1
  113. package/lib/core/plot.d.ts +2 -2
  114. package/lib/core/plot.js +4 -3
  115. package/lib/core/plot.js.map +1 -1
  116. package/lib/index.d.ts +2 -2
  117. package/lib/index.js +2 -1
  118. package/lib/index.js.map +1 -1
  119. package/lib/plots/area/types.d.ts +35 -10
  120. package/lib/plots/area/types.js.map +1 -1
  121. package/lib/plots/bar/types.d.ts +16 -3
  122. package/lib/plots/bar/types.js.map +1 -1
  123. package/lib/plots/bidirectional-bar/types.d.ts +21 -6
  124. package/lib/plots/bidirectional-bar/types.js.map +1 -1
  125. package/lib/plots/box/types.d.ts +20 -6
  126. package/lib/plots/box/types.js.map +1 -1
  127. package/lib/plots/bullet/types.d.ts +36 -9
  128. package/lib/plots/bullet/types.js.map +1 -1
  129. package/lib/plots/chord/types.d.ts +14 -10
  130. package/lib/plots/chord/types.js.map +1 -1
  131. package/lib/plots/circle-packing/types.d.ts +25 -8
  132. package/lib/plots/circle-packing/types.js.map +1 -1
  133. package/lib/plots/column/types.d.ts +57 -16
  134. package/lib/plots/column/types.js.map +1 -1
  135. package/lib/plots/dual-axes/types.d.ts +31 -6
  136. package/lib/plots/dual-axes/types.js.map +1 -1
  137. package/lib/plots/facet/types.d.ts +54 -34
  138. package/lib/plots/facet/types.js.map +1 -1
  139. package/lib/plots/funnel/geometries/compare.js +2 -1
  140. package/lib/plots/funnel/geometries/compare.js.map +1 -1
  141. package/lib/plots/funnel/geometries/facet.js +2 -1
  142. package/lib/plots/funnel/geometries/facet.js.map +1 -1
  143. package/lib/plots/funnel/types.d.ts +45 -11
  144. package/lib/plots/funnel/types.js.map +1 -1
  145. package/lib/plots/gauge/adaptor.js +30 -2
  146. package/lib/plots/gauge/adaptor.js.map +1 -1
  147. package/lib/plots/gauge/types.d.ts +84 -22
  148. package/lib/plots/gauge/types.js.map +1 -1
  149. package/lib/plots/heatmap/types.d.ts +47 -12
  150. package/lib/plots/heatmap/types.js.map +1 -1
  151. package/lib/plots/histogram/types.d.ts +17 -6
  152. package/lib/plots/histogram/types.js.map +1 -1
  153. package/lib/plots/line/types.d.ts +42 -12
  154. package/lib/plots/line/types.js.map +1 -1
  155. package/lib/plots/liquid/index.d.ts +1 -0
  156. package/lib/plots/liquid/index.js +2 -0
  157. package/lib/plots/liquid/index.js.map +1 -1
  158. package/lib/plots/liquid/shapes/liquid.d.ts +16 -1
  159. package/lib/plots/liquid/shapes/liquid.js +14 -7
  160. package/lib/plots/liquid/shapes/liquid.js.map +1 -1
  161. package/lib/plots/liquid/types.d.ts +56 -16
  162. package/lib/plots/liquid/types.js.map +1 -1
  163. package/lib/plots/mix/types.d.ts +31 -22
  164. package/lib/plots/mix/types.js.map +1 -1
  165. package/lib/plots/pie/types.d.ts +27 -10
  166. package/lib/plots/pie/types.js.map +1 -1
  167. package/lib/plots/progress/types.d.ts +13 -4
  168. package/lib/plots/progress/types.js.map +1 -1
  169. package/lib/plots/radar/types.d.ts +39 -12
  170. package/lib/plots/radar/types.js.map +1 -1
  171. package/lib/plots/radial-bar/types.d.ts +39 -12
  172. package/lib/plots/radial-bar/types.js.map +1 -1
  173. package/lib/plots/ring-progress/types.d.ts +18 -6
  174. package/lib/plots/ring-progress/types.js.map +1 -1
  175. package/lib/plots/rose/types.d.ts +32 -12
  176. package/lib/plots/rose/types.js.map +1 -1
  177. package/lib/plots/sankey/types.d.ts +51 -32
  178. package/lib/plots/sankey/types.js.map +1 -1
  179. package/lib/plots/scatter/types.d.ts +76 -22
  180. package/lib/plots/scatter/types.js.map +1 -1
  181. package/lib/plots/stock/types.d.ts +20 -7
  182. package/lib/plots/stock/types.js.map +1 -1
  183. package/lib/plots/sunburst/types.d.ts +40 -12
  184. package/lib/plots/sunburst/types.js.map +1 -1
  185. package/lib/plots/tiny-area/types.d.ts +16 -5
  186. package/lib/plots/tiny-area/types.js.map +1 -1
  187. package/lib/plots/tiny-column/types.d.ts +10 -3
  188. package/lib/plots/tiny-column/types.js.map +1 -1
  189. package/lib/plots/tiny-line/types.d.ts +17 -5
  190. package/lib/plots/tiny-line/types.js.map +1 -1
  191. package/lib/plots/treemap/types.d.ts +17 -6
  192. package/lib/plots/treemap/types.js.map +1 -1
  193. package/lib/plots/venn/types.d.ts +20 -6
  194. package/lib/plots/venn/types.js.map +1 -1
  195. package/lib/plots/violin/types.d.ts +52 -17
  196. package/lib/plots/violin/types.js.map +1 -1
  197. package/lib/plots/waterfall/types.d.ts +42 -10
  198. package/lib/plots/waterfall/types.js.map +1 -1
  199. package/lib/plots/word-cloud/types.d.ts +91 -44
  200. package/lib/plots/word-cloud/types.js.map +1 -1
  201. package/lib/types/button.d.ts +8 -4
  202. package/lib/types/button.js.map +1 -1
  203. package/lib/types/common.d.ts +145 -33
  204. package/lib/types/common.js.map +1 -1
  205. package/lib/types/drill-down.d.ts +28 -7
  206. package/lib/types/drill-down.js.map +1 -1
  207. package/lib/types/interaction.d.ts +26 -6
  208. package/lib/types/interaction.js.map +1 -1
  209. package/lib/types/label.d.ts +11 -3
  210. package/lib/types/label.js.map +1 -1
  211. package/lib/types/meta.d.ts +4 -7
  212. package/lib/types/meta.js.map +1 -1
  213. package/lib/types/pattern.d.ts +58 -18
  214. package/lib/types/pattern.js.map +1 -1
  215. package/lib/types/state.d.ts +11 -3
  216. package/lib/types/state.js.map +1 -1
  217. package/lib/types/statistic.d.ts +38 -6
  218. package/lib/types/statistic.js.map +1 -1
  219. package/lib/types/tooltip.d.ts +7 -2
  220. package/lib/types/tooltip.js.map +1 -1
  221. package/package.json +1 -1
  222. package/src/core/plot.ts +5 -4
  223. package/src/index.ts +2 -2
  224. package/src/plots/area/types.ts +35 -10
  225. package/src/plots/bar/types.ts +16 -3
  226. package/src/plots/bidirectional-bar/types.ts +21 -6
  227. package/src/plots/box/types.ts +20 -6
  228. package/src/plots/bullet/types.ts +36 -17
  229. package/src/plots/chord/types.ts +14 -11
  230. package/src/plots/circle-packing/types.ts +25 -14
  231. package/src/plots/column/types.ts +57 -20
  232. package/src/plots/dual-axes/types.ts +31 -16
  233. package/src/plots/facet/types.ts +54 -49
  234. package/src/plots/funnel/geometries/compare.ts +2 -0
  235. package/src/plots/funnel/geometries/facet.ts +2 -1
  236. package/src/plots/funnel/types.ts +45 -14
  237. package/src/plots/gauge/adaptor.ts +38 -2
  238. package/src/plots/gauge/types.ts +87 -28
  239. package/src/plots/heatmap/types.ts +49 -14
  240. package/src/plots/histogram/types.ts +17 -9
  241. package/src/plots/line/types.ts +42 -14
  242. package/src/plots/liquid/index.ts +2 -0
  243. package/src/plots/liquid/shapes/liquid.ts +16 -8
  244. package/src/plots/liquid/types.ts +56 -16
  245. package/src/plots/mix/types.ts +31 -35
  246. package/src/plots/pie/types.ts +27 -10
  247. package/src/plots/progress/types.ts +13 -4
  248. package/src/plots/radar/types.ts +39 -12
  249. package/src/plots/radial-bar/types.ts +39 -12
  250. package/src/plots/ring-progress/types.ts +18 -6
  251. package/src/plots/rose/types.ts +32 -12
  252. package/src/plots/sankey/types.ts +52 -32
  253. package/src/plots/scatter/types.ts +77 -24
  254. package/src/plots/stock/types.ts +21 -8
  255. package/src/plots/sunburst/types.ts +42 -12
  256. package/src/plots/tiny-area/types.ts +16 -5
  257. package/src/plots/tiny-column/types.ts +10 -3
  258. package/src/plots/tiny-line/types.ts +17 -5
  259. package/src/plots/treemap/types.ts +17 -7
  260. package/src/plots/venn/types.ts +21 -6
  261. package/src/plots/violin/types.ts +52 -17
  262. package/src/plots/waterfall/types.ts +42 -10
  263. package/src/plots/word-cloud/types.ts +91 -44
  264. package/src/types/button.ts +8 -4
  265. package/src/types/common.ts +145 -37
  266. package/src/types/drill-down.ts +28 -7
  267. package/src/types/interaction.ts +26 -6
  268. package/src/types/label.ts +11 -3
  269. package/src/types/meta.ts +4 -7
  270. package/src/types/pattern.ts +58 -18
  271. package/src/types/state.ts +11 -3
  272. package/src/types/statistic.ts +38 -6
  273. package/src/types/tooltip.ts +7 -2
@@ -1,5 +1,5 @@
1
1
  import { __assign } from "tslib";
2
- import { isString } from '@antv/util';
2
+ import { get, isString } from '@antv/util';
3
3
  import { interaction, animation, theme, scale, annotation } from '../../adaptor/common';
4
4
  import { interval } from '../../adaptor/geometries';
5
5
  import { AXIS_META_CONFIG_KEYS } from '../../constant';
@@ -124,6 +124,35 @@ function statistic(params, updated) {
124
124
  }
125
125
  return params;
126
126
  }
127
+ /**
128
+ * tooltip 配置
129
+ */
130
+ function tooltip(params) {
131
+ var chart = params.chart, options = params.options;
132
+ var tooltip = options.tooltip;
133
+ if (tooltip) {
134
+ chart.tooltip(deepAssign({
135
+ showTitle: false,
136
+ showMarkers: false,
137
+ containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
138
+ domStyles: {
139
+ 'g2-tooltip': {
140
+ padding: '4px 8px',
141
+ fontSize: '10px',
142
+ },
143
+ },
144
+ customContent: function (x, data) {
145
+ var percent = get(data, [0, 'data', PERCENT], 0);
146
+ return (percent * 100).toFixed(2) + "%";
147
+ },
148
+ }, tooltip));
149
+ }
150
+ else {
151
+ // 默认,不展示 tooltip
152
+ chart.tooltip(false);
153
+ }
154
+ return params;
155
+ }
127
156
  /**
128
157
  * other 配置
129
158
  * @param params
@@ -131,7 +160,6 @@ function statistic(params, updated) {
131
160
  function other(params) {
132
161
  var chart = params.chart;
133
162
  chart.legend(false);
134
- chart.tooltip(false);
135
163
  return params;
136
164
  }
137
165
  /**
@@ -147,7 +175,7 @@ export function adaptor(params) {
147
175
  // flow 的方式处理所有的配置到 G2 API
148
176
  return flow(theme,
149
177
  // animation 配置必须在 createView 之前,不然无法让子 View 生效
150
- animation, geometry, meta, statistic, interaction, annotation(), other
178
+ animation, geometry, meta, tooltip, statistic, interaction, annotation(), other
151
179
  // ... 其他的 adaptor flow
152
180
  )(params);
153
181
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/gauge/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;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;gBACzC,KAAK,EAAE;oBACL,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,MAAM;oBAChB,UAAU,EAAE,CAAC;oBACb,SAAS,EAAE,QAAQ;oBACnB,KAAK,EAAE,qBAAqB;iBAC7B;aACF,EACD,aAAa,CACd,CAAC;SACH;QACD,oBAAoB,CAAC,KAAK,EAAE,EAAE,SAAS,wBAAO,SAAS,KAAE,OAAO,EAAE,gBAAgB,GAAE,EAAE,EAAE,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;KACtG;IAED,IAAI,OAAO,EAAE;QACX,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KACpB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,KAAK,CAAC,MAA4B;IACjC,IAAA,KAAK,GAAK,MAAM,MAAX,CAAY;IAEzB,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAErB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,MAA4B;IAClD,0BAA0B;IAC1B,OAAO,IAAI,CACT,KAAK;IACL,+CAA+C;IAC/C,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,WAAW,EACX,UAAU,EAAE,EACZ,KAAK;IACL,uBAAuB;KACxB,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { isString } from '@antv/util';\nimport { interaction, animation, theme, scale, annotation } from '../../adaptor/common';\nimport { interval } from '../../adaptor/geometries';\nimport { AXIS_META_CONFIG_KEYS } from '../../constant';\nimport { Params } from '../../core/adaptor';\nimport { deepAssign, flow, pick, renderGaugeStatistic } from '../../utils';\nimport { RANGE_TYPE, RANGE_VALUE, PERCENT, DEFAULT_COLOR, INDICATEOR_VIEW_ID, RANGE_VIEW_ID } from './constants';\nimport { GaugeOptions } from './types';\nimport { getIndicatorData, getRangeData } from './utils';\n\n/**\n * geometry 处理\n * @param params\n */\nfunction geometry(params: Params<GaugeOptions>): Params<GaugeOptions> {\n const { chart, options } = params;\n const { percent, range, radius, innerRadius, startAngle, endAngle, axis, indicator, gaugeStyle, type, meter } =\n options;\n const { color, width: rangeWidth } = range;\n\n // 指标 & 指针\n // 如果开启在应用\n if (indicator) {\n const indicatorData = getIndicatorData(percent);\n\n const v1 = chart.createView({ id: INDICATEOR_VIEW_ID });\n v1.data(indicatorData);\n\n v1.point()\n .position(`${PERCENT}*1`)\n .shape(indicator.shape || 'gauge-indicator')\n // 传入指针的样式到自定义 shape 中\n .customInfo({\n defaultColor: chart.getTheme().defaultColor,\n indicator,\n });\n\n v1.coordinate('polar', {\n startAngle,\n endAngle,\n radius: innerRadius * radius, // 外部的 innerRadius * radius = 这里的 radius\n });\n\n v1.axis(PERCENT, axis);\n // 一部分应用到 scale 中\n v1.scale(PERCENT, pick(axis, AXIS_META_CONFIG_KEYS));\n }\n\n // 辅助 range\n // [{ range: 1, type: '0', percent: 原始进度百分比 }]\n const rangeData = getRangeData(percent, options.range);\n const v2 = chart.createView({ id: RANGE_VIEW_ID });\n v2.data(rangeData);\n\n const rangeColor = isString(color) ? [color, DEFAULT_COLOR] : color;\n\n const { ext } = interval({\n chart: v2,\n options: {\n xField: '1',\n yField: RANGE_VALUE,\n seriesField: RANGE_TYPE,\n rawFields: [PERCENT],\n isStack: true,\n interval: {\n color: rangeColor,\n style: gaugeStyle,\n shape: type === 'meter' ? 'meter-gauge' : null,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n minColumnWidth: rangeWidth,\n maxColumnWidth: rangeWidth,\n },\n });\n\n const geometry = ext.geometry as Geometry;\n // 传入到自定义 shape 中\n geometry.customInfo({ meter });\n\n v2.coordinate('polar', {\n innerRadius,\n radius,\n startAngle,\n endAngle,\n }).transpose();\n\n return params;\n}\n\n/**\n * meta 配置\n * @param params\n */\nfunction meta(params: Params<GaugeOptions>): Params<GaugeOptions> {\n return flow(\n scale({\n range: {\n min: 0,\n max: 1,\n maxLimit: 1,\n minLimit: 0,\n },\n [PERCENT]: {},\n })\n )(params);\n}\n\n/**\n * 统计指标文档\n * @param params\n */\nfunction statistic(params: Params<GaugeOptions>, updated?: boolean): Params<GaugeOptions> {\n const { chart, options } = params;\n const { statistic, percent } = options;\n\n // 先清空标注,再重新渲染\n chart.getController('annotation').clear(true);\n if (statistic) {\n const { content: contentOption } = statistic;\n let transformContent;\n // 当设置 content 的时候,设置默认样式\n if (contentOption) {\n transformContent = deepAssign(\n {},\n {\n content: `${(percent * 100).toFixed(2)}%`,\n style: {\n opacity: 0.75,\n fontSize: '30px',\n lineHeight: 1,\n textAlign: 'center',\n color: 'rgba(44,53,66,0.85)',\n },\n },\n contentOption\n );\n }\n renderGaugeStatistic(chart, { statistic: { ...statistic, content: transformContent } }, { percent });\n }\n\n if (updated) {\n chart.render(true);\n }\n\n return params;\n}\n\n/**\n * other 配置\n * @param params\n */\nfunction other(params: Params<GaugeOptions>): Params<GaugeOptions> {\n const { chart } = params;\n\n chart.legend(false);\n chart.tooltip(false);\n\n return params;\n}\n\n/**\n * 对外暴露的 adaptor\n */\nexport { statistic };\n\n/**\n * 图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<GaugeOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n theme,\n // animation 配置必须在 createView 之前,不然无法让子 View 生效\n animation,\n geometry,\n meta,\n statistic,\n interaction,\n annotation(),\n other\n // ... 其他的 adaptor flow\n )(params);\n}\n"]}
1
+ {"version":3,"file":"adaptor.js","sourceRoot":"","sources":["../../../src/plots/gauge/adaptor.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,K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L,iBAAiB;QACjB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;KACtB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,KAAK,CAAC,MAA4B;IACjC,IAAA,KAAK,GAAK,MAAM,MAAX,CAAY;IAEzB,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,MAA4B;IAClD,0BAA0B;IAC1B,OAAO,IAAI,CACT,KAAK;IACL,+CAA+C;IAC/C,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,SAAS,EACT,WAAW,EACX,UAAU,EAAE,EACZ,KAAK;IACL,uBAAuB;KACxB,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { Geometry } from '@antv/g2';\nimport { get, isString } from '@antv/util';\nimport { interaction, animation, theme, scale, annotation } from '../../adaptor/common';\nimport { interval } from '../../adaptor/geometries';\nimport { AXIS_META_CONFIG_KEYS } from '../../constant';\nimport { Params } from '../../core/adaptor';\nimport { deepAssign, flow, pick, renderGaugeStatistic } from '../../utils';\nimport { RANGE_TYPE, RANGE_VALUE, PERCENT, DEFAULT_COLOR, INDICATEOR_VIEW_ID, RANGE_VIEW_ID } from './constants';\nimport { GaugeOptions } from './types';\nimport { getIndicatorData, getRangeData } from './utils';\n\n/**\n * geometry 处理\n * @param params\n */\nfunction geometry(params: Params<GaugeOptions>): Params<GaugeOptions> {\n const { chart, options } = params;\n const { percent, range, radius, innerRadius, startAngle, endAngle, axis, indicator, gaugeStyle, type, meter } =\n options;\n const { color, width: rangeWidth } = range;\n\n // 指标 & 指针\n // 如果开启在应用\n if (indicator) {\n const indicatorData = getIndicatorData(percent);\n\n const v1 = chart.createView({ id: INDICATEOR_VIEW_ID });\n v1.data(indicatorData);\n\n v1.point()\n .position(`${PERCENT}*1`)\n .shape(indicator.shape || 'gauge-indicator')\n // 传入指针的样式到自定义 shape 中\n .customInfo({\n defaultColor: chart.getTheme().defaultColor,\n indicator,\n });\n\n v1.coordinate('polar', {\n startAngle,\n endAngle,\n radius: innerRadius * radius, // 外部的 innerRadius * radius = 这里的 radius\n });\n\n v1.axis(PERCENT, axis);\n // 一部分应用到 scale 中\n v1.scale(PERCENT, pick(axis, AXIS_META_CONFIG_KEYS));\n }\n\n // 辅助 range\n // [{ range: 1, type: '0', percent: 原始进度百分比 }]\n const rangeData = getRangeData(percent, options.range);\n const v2 = chart.createView({ id: RANGE_VIEW_ID });\n v2.data(rangeData);\n\n const rangeColor = isString(color) ? [color, DEFAULT_COLOR] : color;\n\n const { ext } = interval({\n chart: v2,\n options: {\n xField: '1',\n yField: RANGE_VALUE,\n seriesField: RANGE_TYPE,\n rawFields: [PERCENT],\n isStack: true,\n interval: {\n color: rangeColor,\n style: gaugeStyle,\n shape: type === 'meter' ? 'meter-gauge' : null,\n },\n args: {\n zIndexReversed: true,\n sortZIndex: true,\n },\n minColumnWidth: rangeWidth,\n maxColumnWidth: rangeWidth,\n },\n });\n\n const geometry = ext.geometry as Geometry;\n // 传入到自定义 shape 中\n geometry.customInfo({ meter });\n\n v2.coordinate('polar', {\n innerRadius,\n radius,\n startAngle,\n endAngle,\n }).transpose();\n\n return params;\n}\n\n/**\n * meta 配置\n * @param params\n */\nfunction meta(params: Params<GaugeOptions>): Params<GaugeOptions> {\n return flow(\n scale({\n range: {\n min: 0,\n max: 1,\n maxLimit: 1,\n minLimit: 0,\n },\n [PERCENT]: {},\n })\n )(params);\n}\n\n/**\n * 统计指标文档\n * @param params\n */\nfunction statistic(params: Params<GaugeOptions>, updated?: boolean): Params<GaugeOptions> {\n const { chart, options } = params;\n const { statistic, percent } = options;\n\n // 先清空标注,再重新渲染\n chart.getController('annotation').clear(true);\n if (statistic) {\n const { content: contentOption } = statistic;\n let transformContent;\n // 当设置 content 的时候,设置默认样式\n if (contentOption) {\n transformContent = deepAssign(\n {},\n {\n content: `${(percent * 100).toFixed(2)}%`,\n style: {\n opacity: 0.75,\n fontSize: '30px',\n lineHeight: 1,\n textAlign: 'center',\n color: 'rgba(44,53,66,0.85)',\n },\n },\n contentOption\n );\n }\n renderGaugeStatistic(chart, { statistic: { ...statistic, content: transformContent } }, { percent });\n }\n\n if (updated) {\n chart.render(true);\n }\n\n return params;\n}\n\n/**\n * tooltip 配置\n */\nfunction tooltip(params: Params<GaugeOptions>): Params<GaugeOptions> {\n const { chart, options } = params;\n const { tooltip } = options;\n\n if (tooltip) {\n chart.tooltip(\n deepAssign(\n {\n showTitle: false,\n showMarkers: false,\n containerTpl: '<div class=\"g2-tooltip\"><div class=\"g2-tooltip-list\"></div></div>',\n domStyles: {\n 'g2-tooltip': {\n padding: '4px 8px',\n fontSize: '10px',\n },\n },\n customContent: (x: string, data: any[]) => {\n const percent = get(data, [0, 'data', PERCENT], 0);\n return `${(percent * 100).toFixed(2)}%`;\n },\n },\n tooltip\n )\n );\n } else {\n // 默认,不展示 tooltip\n chart.tooltip(false);\n }\n\n return params;\n}\n\n/**\n * other 配置\n * @param params\n */\nfunction other(params: Params<GaugeOptions>): Params<GaugeOptions> {\n const { chart } = params;\n\n chart.legend(false);\n\n return params;\n}\n\n/**\n * 对外暴露的 adaptor\n */\nexport { statistic };\n\n/**\n * 图适配器\n * @param chart\n * @param options\n */\nexport function adaptor(params: Params<GaugeOptions>) {\n // flow 的方式处理所有的配置到 G2 API\n return flow(\n theme,\n // animation 配置必须在 createView 之前,不然无法让子 View 生效\n animation,\n geometry,\n meta,\n tooltip,\n statistic,\n interaction,\n annotation(),\n other\n // ... 其他的 adaptor flow\n )(params);\n}\n"]}
@@ -3,66 +3,128 @@ import { Axis } from '../../types/axis';
3
3
  import { PERCENT, RANGE_TYPE, RANGE_VALUE } from './constants';
4
4
  /** 指标指标的配置 */
5
5
  export declare type Indicator = {
6
+ /**
7
+ * @title 指针
8
+ * @description 只允许静态的 object
9
+ */
6
10
  readonly pointer?: {
7
11
  readonly style?: ShapeStyle;
8
12
  };
13
+ /**
14
+ * @title 圆环
15
+ * @description 只允许静态的 object
16
+ */
9
17
  readonly pin?: {
10
18
  readonly style?: ShapeStyle;
11
19
  };
20
+ /**
21
+ * @title 自定义指针 shape
22
+ * @default 'gauge-indicator'
23
+ */
12
24
  readonly shape?: string;
13
25
  };
14
26
  export declare type Range = {
15
- /** 辅助的刻度值 0 ~ 1 的数字 */
27
+ /**
28
+ * @title 辅助的刻度值
29
+ * @description 0 ~ 1 的数字
30
+ */
16
31
  readonly ticks?: number[];
17
- /** 辅助刻度的颜色配置 */
32
+ /**
33
+ * @title 辅助刻度的颜色配置
34
+ */
18
35
  readonly color?: string | string[];
19
- /** 仪表盘辅助背景的宽度 */
36
+ /**
37
+ * @title 仪表盘辅助背景的宽度
38
+ */
20
39
  readonly width?: number;
21
40
  };
22
41
  /**
23
- * 仪表盘辅助生成的 rangeData
42
+ * @title 仪表盘辅助生成的 rangeData
24
43
  */
25
44
  export declare type GaugeRangeData = {
26
45
  readonly [RANGE_VALUE]?: number;
27
46
  readonly [RANGE_TYPE]: string;
28
47
  readonly [PERCENT]: number;
29
48
  }[];
30
- /** 仪表盘配置类型定义 */
31
- export interface GaugeOptions extends Omit<Options, 'data' | 'tooltip' | 'legend' | 'xAxis' | 'yAxis' | 'xField' | 'yField' | 'color'> {
32
- /** 指标的比例 0 ~ 1 */
49
+ /**
50
+ * @title 仪表盘配置类型定义
51
+ */
52
+ export interface GaugeOptions extends Omit<Options, 'data' | 'legend' | 'xAxis' | 'yAxis' | 'xField' | 'yField' | 'color'> {
53
+ /**
54
+ * @title 指标的比例
55
+ * @description 范围0 ~ 1
56
+ */
33
57
  readonly percent: number;
34
- /** 外弧度 0 ~ 1 */
58
+ /**
59
+ * @title 外弧度
60
+ * @description 范围0 ~ 1
61
+ */
35
62
  readonly radius?: number;
36
- /** 内弧度 0 ~ 1 */
63
+ /**
64
+ * @title 内弧度
65
+ * @description 范围0 ~ 1
66
+ */
37
67
  readonly innerRadius?: number;
38
- /** 弧度起始 */
68
+ /**
69
+ * @title 弧度起始
70
+ */
39
71
  readonly startAngle?: number;
40
- /** 弧度结束 */
72
+ /**
73
+ * @title 弧度结束
74
+ */
41
75
  readonly endAngle?: number;
42
- /** 辅助的 range 组件 */
76
+ /**
77
+ * @title 辅助的 range 组件
78
+ */
43
79
  readonly range?: Range;
44
- /** 坐标轴配置 */
80
+ /**
81
+ * @title 坐标轴配置
82
+ */
45
83
  readonly axis?: Axis;
46
- /** 指针的配置 */
84
+ /**
85
+ * @title 指针的配置
86
+ */
47
87
  readonly indicator?: false | Indicator;
48
- /** 统计文本 */
88
+ /**
89
+ * @title 统计文本
90
+ */
49
91
  readonly statistic?: Statistic;
50
- /** 仪表盘样式 */
92
+ /**
93
+ * @title 仪表盘样式
94
+ */
51
95
  readonly gaugeStyle?: StyleAttr;
52
- /** 仪表盘类型, 可选项: 'meter', default 为空 */
96
+ /**
97
+ * @title meter gauge 相关配置
98
+ */
99
+ /**
100
+ * @title 仪表盘类型
101
+ * @description 可选项: 'meter', default 为空
102
+ */
53
103
  readonly type?: string;
54
- /** 当仪表盘类型 = 'meter' 生效 */
104
+ /**
105
+ * @title 仪表盘配置
106
+ * @description 当仪表盘类型 = 'meter' 生效
107
+ */
55
108
  readonly meter?: {
56
- /** 仪表盘总步数, default: 50 */
109
+ /**
110
+ * @title 仪表盘总步数
111
+ * @default "50"
112
+ */
57
113
  readonly steps?: number;
58
- /** step 与 gap 的宽度占比, default: 0.5 */
114
+ /**
115
+ * @title step 与 gap 的宽度占比
116
+ * @default "0.5"
117
+ */
59
118
  readonly stepRatio?: number;
60
119
  };
61
120
  }
62
121
  /**
63
- * 仪表盘 自定义 shape 使用的 customInfo
122
+ * @title 仪表盘
123
+ * @description 自定义 shape 使用的 customInfo
64
124
  */
65
125
  export declare type GaugeCustomInfo = {
66
- /** 仪表盘 meter 类型的相关配置 */
126
+ /**
127
+ * @title 仪表盘 meter 类型的相关配置
128
+ */
67
129
  readonly meter?: GaugeOptions['meter'];
68
130
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/gauge/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import { Options, ShapeStyle, Statistic, StyleAttr } from '../../types';\nimport { Axis } from '../../types/axis';\nimport { PERCENT, RANGE_TYPE, RANGE_VALUE } from './constants';\n\n/** 指标指标的配置 */\nexport type Indicator = {\n // 指针\n readonly pointer?: {\n readonly style?: ShapeStyle; // 只允许静态的 object\n };\n // 圆环\n readonly pin?: {\n readonly style?: ShapeStyle; // 只允许静态的 object\n };\n // 自定义指针 shape. 默认: 'gauge-indicator'\n readonly shape?: string;\n};\n\nexport type Range = {\n /** 辅助的刻度值 0 ~ 1 的数字 */\n readonly ticks?: number[];\n /** 辅助刻度的颜色配置 */\n readonly color?: string | string[];\n /** 仪表盘辅助背景的宽度 */\n readonly width?: number;\n};\n\n/**\n * 仪表盘辅助生成的 rangeData\n */\nexport type GaugeRangeData = {\n readonly [RANGE_VALUE]?: number;\n readonly [RANGE_TYPE]: string;\n readonly [PERCENT]: number;\n}[];\n\n/** 仪表盘配置类型定义 */\nexport interface GaugeOptions\n extends Omit<Options, 'data' | 'tooltip' | 'legend' | 'xAxis' | 'yAxis' | 'xField' | 'yField' | 'color'> {\n /** 指标的比例 0 ~ 1 */\n readonly percent: number;\n /** 外弧度 0 ~ 1 */\n readonly radius?: number;\n /** 内弧度 0 ~ 1 */\n readonly innerRadius?: number;\n /** 弧度起始 */\n readonly startAngle?: number;\n /** 弧度结束 */\n readonly endAngle?: number;\n /** 辅助的 range 组件 */\n readonly range?: Range;\n /** 坐标轴配置 */\n readonly axis?: Axis;\n /** 指针的配置 */\n readonly indicator?: false | Indicator;\n /** 统计文本 */\n readonly statistic?: Statistic;\n /** 仪表盘样式 */\n readonly gaugeStyle?: StyleAttr;\n\n // meter gauge 相关配置\n /** 仪表盘类型, 可选项: 'meter', default 为空 */\n readonly type?: string;\n /** 当仪表盘类型 = 'meter' 生效 */\n readonly meter?: {\n /** 仪表盘总步数, default: 50 */\n readonly steps?: number;\n /** step 与 gap 的宽度占比, default: 0.5 */\n readonly stepRatio?: number;\n };\n}\n\n/**\n * 仪表盘 自定义 shape 使用的 customInfo\n */\nexport type GaugeCustomInfo = {\n /** 仪表盘 meter 类型的相关配置 */\n readonly meter?: GaugeOptions['meter'];\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/gauge/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import { Options, ShapeStyle, Statistic, StyleAttr } from '../../types';\nimport { Axis } from '../../types/axis';\nimport { PERCENT, RANGE_TYPE, RANGE_VALUE } from './constants';\n\n/** 指标指标的配置 */\nexport type Indicator = {\n /**\n * @title 指针\n * @description 只允许静态的 object\n */\n readonly pointer?: {\n readonly style?: ShapeStyle;\n };\n /**\n * @title 圆环\n * @description 只允许静态的 object\n */\n readonly pin?: {\n readonly style?: ShapeStyle;\n };\n /**\n * @title 自定义指针 shape\n * @default 'gauge-indicator'\n */\n readonly shape?: string;\n};\n\nexport type Range = {\n /**\n * @title 辅助的刻度值\n * @description 0 ~ 1 的数字\n */\n readonly ticks?: number[];\n /**\n * @title 辅助刻度的颜色配置\n */\n readonly color?: string | string[];\n /**\n * @title 仪表盘辅助背景的宽度\n */\n readonly width?: number;\n};\n\n/**\n * @title 仪表盘辅助生成的 rangeData\n */\nexport type GaugeRangeData = {\n readonly [RANGE_VALUE]?: number;\n readonly [RANGE_TYPE]: string;\n readonly [PERCENT]: number;\n}[];\n\n/**\n * @title 仪表盘配置类型定义\n */\nexport interface GaugeOptions\n extends Omit<Options, 'data' | 'legend' | 'xAxis' | 'yAxis' | 'xField' | 'yField' | 'color'> {\n /**\n * @title 指标的比例\n * @description 范围0 ~ 1\n */\n readonly percent: number;\n /**\n * @title 外弧度\n * @description 范围0 ~ 1\n */\n readonly radius?: number;\n /**\n * @title 内弧度\n * @description 范围0 ~ 1\n */\n readonly innerRadius?: number;\n /**\n * @title 弧度起始\n */\n readonly startAngle?: number;\n /**\n * @title 弧度结束\n */\n readonly endAngle?: number;\n /**\n * @title 辅助的 range 组件\n */\n readonly range?: Range;\n /**\n * @title 坐标轴配置\n */\n readonly axis?: Axis;\n /**\n * @title 指针的配置\n */\n readonly indicator?: false | Indicator;\n /**\n * @title 统计文本\n */\n readonly statistic?: Statistic;\n /**\n * @title 仪表盘样式\n */\n readonly gaugeStyle?: StyleAttr;\n\n /**\n * @title meter gauge 相关配置\n */\n\n /**\n * @title 仪表盘类型\n * @description 可选项: 'meter', default 为空\n */\n readonly type?: string;\n /**\n * @title 仪表盘配置\n * @description 当仪表盘类型 = 'meter' 生效\n */\n readonly meter?: {\n /**\n * @title 仪表盘总步数\n * @default \"50\"\n */\n readonly steps?: number;\n /**\n * @title step 与 gap 的宽度占比\n * @default \"0.5\"\n */\n readonly stepRatio?: number;\n };\n}\n\n/**\n * @title 仪表盘\n * @description 自定义 shape 使用的 customInfo\n */\nexport type GaugeCustomInfo = {\n /**\n * @title 仪表盘 meter 类型的相关配置\n */\n readonly meter?: GaugeOptions['meter'];\n};\n"]}
@@ -1,28 +1,63 @@
1
1
  import { Types } from '@antv/g2';
2
2
  import { Options, StyleAttr } from '../../types';
3
3
  export interface HeatmapOptions extends Options {
4
- /** 热力图类型 */
4
+ /**
5
+ * @title 热力图类型
6
+ * @description 'polygon' | 'density'
7
+ */
5
8
  readonly type?: 'polygon' | 'density';
6
- /** x 轴字段 */
9
+ /**
10
+ * @title x轴字段
11
+ */
7
12
  readonly xField: string;
8
- /** y 轴字段 */
13
+ /**
14
+ * @title y轴字段
15
+ */
9
16
  readonly yField: string;
10
- /** 颜色字段,可选 */
17
+ /**
18
+ * @title 颜色字段
19
+ */
11
20
  readonly colorField?: string;
12
- /** 热力格子中的形状,可选 */
21
+ /**
22
+ * @title 热力格子中的形状
23
+ */
13
24
  readonly shape?: string;
14
- /** 热力格子中图形的尺寸比例,可选,只有当 shape 和 sizeField 至少指定一项后才生效 */
25
+ /**
26
+ * @title 热力格子中图形的尺寸比例
27
+ * @description 只有当 shape 和 sizeField 至少指定一项后才生效
28
+ */
15
29
  readonly sizeRatio?: number;
16
- /** 坐标轴映射 */
30
+ /**
31
+ * @title 坐标轴映射
32
+ * @description 坐标轴映射 'x' | 'y'
33
+ */
17
34
  readonly reflect?: 'x' | 'y';
18
- /** 极坐标属性 */
35
+ /**
36
+ * @title 极坐标属性
37
+ */
19
38
  readonly coordinate?: Types.CoordinateOption;
20
- /** 点大小映射对应的数据字段名,可选 */
39
+ /**
40
+ * @title 图例相关
41
+ */
42
+ /**
43
+ * @title 数据字段名
44
+ * @description 点大小映射对应的数据字段名
45
+ */
21
46
  readonly sizeField?: string;
22
- /** size 对应的图例 */
47
+ /**
48
+ * @title size 对应的图例
49
+ */
23
50
  readonly sizeLegend?: Options['legend'];
24
- /** 热力图形样式 */
51
+ /**
52
+ * @title 样式相关
53
+ */
54
+ /**
55
+ * @title 热力图形样式
56
+ */
25
57
  readonly heatmapStyle?: StyleAttr;
26
- /** 贴图图案, 在 type="density" 时不支持 */
58
+ /**
59
+ * @title 贴图图案
60
+ * @description 在 type="density" 时不支持
61
+ */
27
62
  readonly pattern?: Options['pattern'];
28
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/heatmap/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Options, StyleAttr } from '../../types';\n\nexport interface HeatmapOptions extends Options {\n /** 热力图类型 */\n readonly type?: 'polygon' | 'density';\n /** x 轴字段 */\n readonly xField: string;\n /** y 轴字段 */\n readonly yField: string;\n /** 颜色字段,可选 */\n readonly colorField?: string;\n /** 热力格子中的形状,可选 */\n readonly shape?: string;\n /** 热力格子中图形的尺寸比例,可选,只有当 shape 和 sizeField 至少指定一项后才生效 */\n readonly sizeRatio?: number;\n /** 坐标轴映射 */\n readonly reflect?: 'x' | 'y';\n /** 极坐标属性 */\n readonly coordinate?: Types.CoordinateOption;\n\n // 图例相关\n /** 点大小映射对应的数据字段名,可选 */\n readonly sizeField?: string;\n /** size 对应的图例 */\n readonly sizeLegend?: Options['legend'];\n\n // 样式相关\n /** 热力图形样式 */\n readonly heatmapStyle?: StyleAttr;\n /** 贴图图案, 在 type=\"density\" 时不支持 */\n readonly pattern?: Options['pattern'];\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/heatmap/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Options, StyleAttr } from '../../types';\n\nexport interface HeatmapOptions extends Options {\n /**\n * @title 热力图类型\n * @description 'polygon' | 'density'\n */\n readonly type?: 'polygon' | 'density';\n /**\n * @title x轴字段\n */\n readonly xField: string;\n /**\n * @title y轴字段\n */\n readonly yField: string;\n /**\n * @title 颜色字段\n */\n readonly colorField?: string;\n /**\n * @title 热力格子中的形状\n */\n readonly shape?: string;\n /**\n * @title 热力格子中图形的尺寸比例\n * @description 只有当 shape 和 sizeField 至少指定一项后才生效\n */\n readonly sizeRatio?: number;\n /**\n * @title 坐标轴映射\n * @description 坐标轴映射 'x' | 'y'\n */\n readonly reflect?: 'x' | 'y';\n /**\n * @title 极坐标属性\n */\n readonly coordinate?: Types.CoordinateOption;\n\n /**\n * @title 图例相关\n */\n\n /**\n * @title 数据字段名\n * @description 点大小映射对应的数据字段名\n */\n readonly sizeField?: string;\n /**\n * @title size 对应的图例\n */\n readonly sizeLegend?: Options['legend'];\n\n /**\n * @title 样式相关\n */\n\n /**\n * @title 热力图形样式\n */\n readonly heatmapStyle?: StyleAttr;\n /**\n * @title 贴图图案\n * @description 在 type=\"density\" 时不支持\n */\n readonly pattern?: Options['pattern'];\n}\n"]}
@@ -1,16 +1,27 @@
1
1
  import { Options, StyleAttr } from '../../types';
2
2
  export interface HistogramOptions extends Options {
3
- /** 设置直方图绘制 (进行分箱) 的字段 */
3
+ /**
4
+ * @title 直方图绘制字段
5
+ * @description 设置直方图绘制 (进行分箱) 的字段
6
+ */
4
7
  readonly binField: string;
5
8
  /**
6
- * 设置直方图的分箱宽度,binWidth 影响直方图分成多少箱,
7
- * 不能与binNumber一起使用
9
+ * @title 设置直方图的分箱宽度
10
+ * @description binWidth 影响直方图分成多少箱,不能与binNumber一起使用
8
11
  */
9
12
  readonly binWidth?: number;
10
- /** 设置直方图的分箱数量,binNumber 影响直方图分箱后每个柱子的宽度 */
13
+ /**
14
+ * @title 设置直方图的分箱数量
15
+ * @description binNumber 影响直方图分箱后每个柱子的宽度
16
+ */
11
17
  readonly binNumber?: number;
12
- /** 指定层叠字段,通过该字段的值,柱子将会被分割为多个部分,通过颜色进行区分 */
18
+ /**
19
+ * @title 指定层叠字段
20
+ * @description 通过该字段的值,柱子将会被分割为多个部分,通过颜色进行区分
21
+ */
13
22
  readonly stackField?: string;
14
- /** 柱子样式配置,可选 */
23
+ /**
24
+ * @title 柱子样式配置
25
+ */
15
26
  readonly columnStyle?: StyleAttr;
16
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/histogram/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Options, StyleAttr } from '../../types';\n\nexport interface HistogramOptions extends Options {\n /** 设置直方图绘制 (进行分箱) 的字段 */\n readonly binField: string;\n\n /**\n * 设置直方图的分箱宽度,binWidth 影响直方图分成多少箱,\n * 不能与binNumber一起使用\n */\n readonly binWidth?: number;\n\n /** 设置直方图的分箱数量,binNumber 影响直方图分箱后每个柱子的宽度 */\n readonly binNumber?: number;\n\n /** 指定层叠字段,通过该字段的值,柱子将会被分割为多个部分,通过颜色进行区分 */\n readonly stackField?: string;\n\n /** 柱子样式配置,可选 */\n readonly columnStyle?: StyleAttr;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/histogram/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Options, StyleAttr } from '../../types';\n\nexport interface HistogramOptions extends Options {\n /**\n * @title 直方图绘制字段\n * @description 设置直方图绘制 (进行分箱) 的字段\n */\n readonly binField: string;\n\n /**\n * @title 设置直方图的分箱宽度\n * @description binWidth 影响直方图分成多少箱,不能与binNumber一起使用\n */\n readonly binWidth?: number;\n /**\n * @title 设置直方图的分箱数量\n * @description binNumber 影响直方图分箱后每个柱子的宽度\n */\n readonly binNumber?: number;\n /**\n * @title 指定层叠字段\n * @description 通过该字段的值,柱子将会被分割为多个部分,通过颜色进行区分\n */\n readonly stackField?: string;\n /**\n * @title 柱子样式配置\n */\n readonly columnStyle?: StyleAttr;\n}\n"]}
@@ -1,28 +1,58 @@
1
1
  import { GeometryOptions, AreaGeometryOptions, LineGeometryOptions, PointGeometryOptions } from '../../adaptor/geometries';
2
2
  import { Options, StyleAttr } from '../../types';
3
3
  export interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'> {
4
- /** 阶梯折线图类型 */
4
+ /**
5
+ * @title 阶梯折线图类型
6
+ */
5
7
  readonly stepType?: string;
6
- /** x 轴字段 */
8
+ /**
9
+ * @title x轴字段
10
+ */
7
11
  readonly xField?: string;
8
- /** y 轴字段 */
12
+ /**
13
+ * @title y轴字段
14
+ */
9
15
  readonly yField?: string;
10
- /** 分组字段 */
16
+ /**
17
+ * @title 分组字段
18
+ */
11
19
  readonly seriesField?: string;
12
- /** 是否堆积 */
20
+ /**
21
+ * @title 是否堆积
22
+ * @default false
23
+ */
13
24
  readonly isStack?: boolean;
14
- /** 是否平滑 */
25
+ /**
26
+ * @title 是否平滑
27
+ * @default false
28
+ */
15
29
  readonly smooth?: boolean;
16
- /** 是否连接空数据 */
30
+ /**
31
+ * @title 是否连接空数据
32
+ * @default false
33
+ */
17
34
  readonly connectNulls?: boolean;
18
- /** 折线图形样式 */
35
+ /**
36
+ * @title 折线图形样式
37
+ */
19
38
  readonly lineStyle?: StyleAttr;
20
- /** 折线 shape 配置 */
39
+ /**
40
+ * @title 折线 shape 配置
41
+ */
21
42
  readonly lineShape?: Required<LineGeometryOptions>['line']['shape'];
22
- /** 折线数据点:1、图形映射属性 2、状态样式 */
43
+ /**
44
+ * @title 折线数据点
45
+ * @description 1、图形映射属性 2、状态样式
46
+ */
23
47
  readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;
24
- /** 折线趋势填充色:1、图形映射属性 */
48
+ /**
49
+ * @title 折线趋势填充色
50
+ * @description 1、图形映射属性
51
+ */
25
52
  readonly area?: AreaGeometryOptions['area'] & Pick<PointGeometryOptions, 'state'>;
26
- /** 坐标轴反转配置 */
53
+ /**
54
+ * @title 坐标轴反转配置
55
+ * @description 坐标轴反转配置 'x' | 'y' | ['x', 'y']
56
+ */
27
57
  readonly reflect?: 'x' | 'y' | ['x', 'y'];
28
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/line/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n GeometryOptions,\n AreaGeometryOptions,\n LineGeometryOptions,\n PointGeometryOptions,\n} from '../../adaptor/geometries';\nimport { Options, StyleAttr } from '../../types';\n\nexport interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'> {\n /** 阶梯折线图类型 */\n readonly stepType?: string;\n /** x 轴字段 */\n readonly xField?: string;\n /** y 轴字段 */\n readonly yField?: string;\n /** 分组字段 */\n readonly seriesField?: string;\n /** 是否堆积 */\n readonly isStack?: boolean;\n /** 是否平滑 */\n readonly smooth?: boolean;\n /** 是否连接空数据 */\n readonly connectNulls?: boolean;\n /** 折线图形样式 */\n readonly lineStyle?: StyleAttr;\n /** 折线 shape 配置 */\n readonly lineShape?: Required<LineGeometryOptions>['line']['shape'];\n /** 折线数据点:1、图形映射属性 2、状态样式 */\n readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;\n /** 折线趋势填充色:1、图形映射属性 */\n readonly area?: AreaGeometryOptions['area'] & Pick<PointGeometryOptions, 'state'>;\n\n // 其他\n /** 坐标轴反转配置 */\n readonly reflect?: 'x' | 'y' | ['x', 'y'];\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/line/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n GeometryOptions,\n AreaGeometryOptions,\n LineGeometryOptions,\n PointGeometryOptions,\n} from '../../adaptor/geometries';\nimport { Options, StyleAttr } from '../../types';\n\nexport interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'> {\n /**\n * @title 阶梯折线图类型\n */\n readonly stepType?: string;\n /**\n * @title x轴字段\n */\n readonly xField?: string;\n /**\n * @title y轴字段\n */\n readonly yField?: string;\n /**\n * @title 分组字段\n */\n readonly seriesField?: string;\n /**\n * @title 是否堆积\n * @default false\n */\n readonly isStack?: boolean;\n /**\n * @title 是否平滑\n * @default false\n */\n readonly smooth?: boolean;\n /**\n * @title 是否连接空数据\n * @default false\n */\n readonly connectNulls?: boolean;\n /**\n * @title 折线图形样式\n */\n readonly lineStyle?: StyleAttr;\n /**\n * @title 折线 shape 配置\n */\n readonly lineShape?: Required<LineGeometryOptions>['line']['shape'];\n /**\n * @title 折线数据点\n * @description 1、图形映射属性 2、状态样式\n */\n readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;\n /**\n * @title 折线趋势填充色\n * @description 1、图形映射属性\n */\n readonly area?: AreaGeometryOptions['area'] & Pick<PointGeometryOptions, 'state'>;\n /**\n * @title 坐标轴反转配置\n * @description 坐标轴反转配置 'x' | 'y' | ['x', 'y']\n */\n readonly reflect?: 'x' | 'y' | ['x', 'y'];\n}\n"]}
@@ -2,6 +2,7 @@ import { Plot } from '../../core/plot';
2
2
  import { Adaptor } from '../../core/adaptor';
3
3
  import { LiquidOptions } from './types';
4
4
  import './shapes/liquid';
5
+ export { addWaterWave } from './shapes/liquid';
5
6
  export type { LiquidOptions };
6
7
  /**
7
8
  * 传说中的水波图
@@ -6,6 +6,7 @@ import { DEFAULT_OPTIONS } from './constants';
6
6
  import { getLiquidData } from './utils';
7
7
  // register liquid shape
8
8
  import './shapes/liquid';
9
+ export { addWaterWave } from './shapes/liquid';
9
10
  /**
10
11
  * 传说中的水波图
11
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/liquid/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,wBAAwB;AACxB,OAAO,iBAAiB,CAAC;AAIzB;;GAEG;AACH;IAA4B,0BAAmB;IAA/C;QAAA,qEA6CC;QApCC,WAAW;QACJ,UAAI,GAAW,QAAQ,CAAC;;IAmCjC,CAAC;IA5CC;;;OAGG;IACI,wBAAiB,GAAxB;QACE,OAAO,eAAe,CAAC;IACzB,CAAC;IAKD;;OAEG;IACO,kCAAiB,GAA3B;QACE,OAAO,MAAM,CAAC,iBAAiB,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,2BAAU,GAAjB,UAAkB,OAAe;QAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,CACb,gBAAgB,CAAC,kBAAkB,EACnC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CACtE,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;QAE/B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;QAE9D,IAAI,CAAC,KAAK,CAAC,IAAI,CACb,gBAAgB,CAAC,iBAAiB,EAClC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,iBAAiB,EAAE,IAAI,CAAC,CACrE,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,iCAAgB,GAA1B;QACE,OAAO,OAAO,CAAC;IACjB,CAAC;IACH,aAAC;AAAD,CAAC,AA7CD,CAA4B,IAAI,GA6C/B","sourcesContent":["import { VIEW_LIFE_CIRCLE, Event } from '@antv/g2';\nimport { Plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { LiquidOptions } from './types';\nimport { adaptor, statistic } from './adaptor';\nimport { DEFAULT_OPTIONS } from './constants';\nimport { getLiquidData } from './utils';\n// register liquid shape\nimport './shapes/liquid';\n\nexport type { LiquidOptions };\n\n/**\n * 传说中的水波图\n */\nexport class Liquid extends Plot<LiquidOptions> {\n /**\n * 获取 饼图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<LiquidOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public type: string = 'liquid';\n\n /**\n * 获取 水波图 默认配置项, 供 base 获取\n */\n protected getDefaultOptions(): Partial<LiquidOptions> {\n return Liquid.getDefaultOptions();\n }\n\n /**\n * 更新数据\n * @param percent\n */\n public changeData(percent: number) {\n this.chart.emit(\n VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA,\n Event.fromData(this.chart, VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA, null)\n );\n this.updateOption({ percent });\n\n this.chart.data(getLiquidData(percent));\n statistic({ chart: this.chart, options: this.options }, true);\n\n this.chart.emit(\n VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA,\n Event.fromData(this.chart, VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA, null)\n );\n }\n\n /**\n * 获取适配器\n */\n protected getSchemaAdaptor(): Adaptor<LiquidOptions> {\n return adaptor;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/liquid/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,wBAAwB;AACxB,OAAO,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C;;GAEG;AACH;IAA4B,0BAAmB;IAA/C;QAAA,qEA6CC;QApCC,WAAW;QACJ,UAAI,GAAW,QAAQ,CAAC;;IAmCjC,CAAC;IA5CC;;;OAGG;IACI,wBAAiB,GAAxB;QACE,OAAO,eAAe,CAAC;IACzB,CAAC;IAKD;;OAEG;IACO,kCAAiB,GAA3B;QACE,OAAO,MAAM,CAAC,iBAAiB,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,2BAAU,GAAjB,UAAkB,OAAe;QAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,CACb,gBAAgB,CAAC,kBAAkB,EACnC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CACtE,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;QAE/B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;QAE9D,IAAI,CAAC,KAAK,CAAC,IAAI,CACb,gBAAgB,CAAC,iBAAiB,EAClC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,iBAAiB,EAAE,IAAI,CAAC,CACrE,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,iCAAgB,GAA1B;QACE,OAAO,OAAO,CAAC;IACjB,CAAC;IACH,aAAC;AAAD,CAAC,AA7CD,CAA4B,IAAI,GA6C/B","sourcesContent":["import { VIEW_LIFE_CIRCLE, Event } from '@antv/g2';\nimport { Plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { LiquidOptions } from './types';\nimport { adaptor, statistic } from './adaptor';\nimport { DEFAULT_OPTIONS } from './constants';\nimport { getLiquidData } from './utils';\n// register liquid shape\nimport './shapes/liquid';\n\nexport { addWaterWave } from './shapes/liquid';\n\nexport type { LiquidOptions };\n\n/**\n * 传说中的水波图\n */\nexport class Liquid extends Plot<LiquidOptions> {\n /**\n * 获取 饼图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<LiquidOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public type: string = 'liquid';\n\n /**\n * 获取 水波图 默认配置项, 供 base 获取\n */\n protected getDefaultOptions(): Partial<LiquidOptions> {\n return Liquid.getDefaultOptions();\n }\n\n /**\n * 更新数据\n * @param percent\n */\n public changeData(percent: number) {\n this.chart.emit(\n VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA,\n Event.fromData(this.chart, VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA, null)\n );\n this.updateOption({ percent });\n\n this.chart.data(getLiquidData(percent));\n statistic({ chart: this.chart, options: this.options }, true);\n\n this.chart.emit(\n VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA,\n Event.fromData(this.chart, VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA, null)\n );\n }\n\n /**\n * 获取适配器\n */\n protected getSchemaAdaptor(): Adaptor<LiquidOptions> {\n return adaptor;\n }\n}\n"]}
@@ -1 +1,16 @@
1
- export {};
1
+ import { IGroup, IShape } from '@antv/g-base';
2
+ import { ShapeStyle } from '../../../types';
3
+ import { LiquidOptions } from '../types';
4
+ /**
5
+ * 添加水波
6
+ * @param x 中心x
7
+ * @param y 中心y
8
+ * @param level 水位等级 0~1
9
+ * @param waveCount 水波数
10
+ * @param waveAttrs 色值
11
+ * @param group 图组
12
+ * @param clip 用于剪切的图形
13
+ * @param radius 绘制图形的高度
14
+ * @param waveLength 波的长度
15
+ */
16
+ export declare function addWaterWave(x: number, y: number, level: number, waveCount: number, waveAttrs: ShapeStyle, group: IGroup, clip: IShape, radius: number, waveLength: number, animation: LiquidOptions['animation']): void;
@@ -178,16 +178,20 @@ function getWaterWavePath(radius, waterLevel, waveLength, phase, amplitude, cx,
178
178
  * @param radius 绘制图形的高度
179
179
  * @param waveLength 波的长度
180
180
  */
181
- function addWaterWave(x, y, level, waveCount, waveAttrs, group, clip, radius, waveLength, animation) {
181
+ export function addWaterWave(x, y, level, waveCount, waveAttrs, group, clip, radius, waveLength, animation) {
182
+ // 盒子属性 颜色 宽高
182
183
  var fill = waveAttrs.fill, opacity = waveAttrs.opacity;
183
184
  var bbox = clip.getBBox();
184
185
  var width = bbox.maxX - bbox.minX;
185
186
  var height = bbox.maxY - bbox.minY;
187
+ // 循环 waveCount 个数
186
188
  for (var idx = 0; idx < waveCount; idx++) {
187
189
  var factor = waveCount <= 1 ? 0 : idx / (waveCount - 1);
190
+ // 画波
188
191
  var wave = group.addShape('path', {
189
192
  name: "waterwave-path",
190
193
  attrs: {
194
+ // 波形路径配置
191
195
  path: getWaterWavePath(radius, bbox.minY + height * level, waveLength, 0, width / 32, // 波幅高度
192
196
  x, y),
193
197
  fill: fill,
@@ -195,6 +199,7 @@ function addWaterWave(x, y, level, waveCount, waveAttrs, group, clip, radius, wa
195
199
  },
196
200
  });
197
201
  try {
202
+ // 默认 underfind 开启动画
198
203
  if (animation === false)
199
204
  return;
200
205
  var matrix = transform([['t', waveLength, 0]]);
@@ -284,6 +289,13 @@ function rect(x, y, width, height) {
284
289
  var w = (width / 2) * GOLDEN_SECTION_RATIO;
285
290
  return "\n M " + (x - w) + " " + (y - h) + "\n L " + (x + w) + " " + (y - h) + "\n L " + (x + w) + " " + (y + h) + "\n L " + (x - w) + " " + (y + h) + "\n Z\n ";
286
291
  }
292
+ var builtInShapeByName = {
293
+ pin: pin,
294
+ circle: circle,
295
+ diamond: diamond,
296
+ triangle: triangle,
297
+ rect: rect,
298
+ };
287
299
  registerShape('interval', 'liquid-fill-gauge', {
288
300
  draw: function (cfg, container) {
289
301
  var cx = 0.5;
@@ -306,13 +318,6 @@ registerShape('interval', 'liquid-fill-gauge', {
306
318
  var waveAttrs = getFillAttrs(cfg);
307
319
  var outlineAttrs = getLineAttrs(mix({}, cfg, outline));
308
320
  var innerRadius = radius - border / 2;
309
- var builtInShapeByName = {
310
- pin: pin,
311
- circle: circle,
312
- diamond: diamond,
313
- triangle: triangle,
314
- rect: rect,
315
- };
316
321
  var buildPath = typeof shape === 'function' ? shape : builtInShapeByName[shape] || builtInShapeByName['circle'];
317
322
  var shapePath = buildPath(center.x, center.y, innerRadius * 2, innerRadius * 2);
318
323
  // 1. 绘制一个波