@antv/g2plot 2.4.3 → 2.4.8

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 (142) hide show
  1. package/CHANGELOG.md +42 -9
  2. package/dist/g2plot.min.js +4 -4
  3. package/dist/g2plot.min.js.map +1 -1
  4. package/esm/index.d.ts +1 -9
  5. package/esm/index.js +1 -9
  6. package/esm/index.js.map +1 -1
  7. package/esm/plots/area/adaptor.js +22 -22
  8. package/esm/plots/area/adaptor.js.map +1 -1
  9. package/esm/plots/area/constants.d.ts +0 -2
  10. package/esm/plots/area/constants.js +1 -2
  11. package/esm/plots/area/constants.js.map +1 -1
  12. package/esm/plots/area/index.js +4 -11
  13. package/esm/plots/area/index.js.map +1 -1
  14. package/esm/plots/area/types.d.ts +1 -1
  15. package/esm/plots/area/types.js.map +1 -1
  16. package/esm/plots/bar/constants.js +3 -0
  17. package/esm/plots/bar/constants.js.map +1 -1
  18. package/esm/plots/column/constants.js +3 -0
  19. package/esm/plots/column/constants.js.map +1 -1
  20. package/esm/plots/dual-axes/util/render-sider.js +1 -1
  21. package/esm/plots/dual-axes/util/render-sider.js.map +1 -1
  22. package/esm/plots/gauge/adaptor.js +1 -0
  23. package/esm/plots/gauge/adaptor.js.map +1 -1
  24. package/esm/plots/line/adaptor.js +19 -33
  25. package/esm/plots/line/adaptor.js.map +1 -1
  26. package/esm/plots/line/constants.d.ts +0 -2
  27. package/esm/plots/line/constants.js +1 -3
  28. package/esm/plots/line/constants.js.map +1 -1
  29. package/esm/plots/line/index.js +1 -8
  30. package/esm/plots/line/index.js.map +1 -1
  31. package/esm/plots/line/interactions/marker-active.js +6 -7
  32. package/esm/plots/line/interactions/marker-active.js.map +1 -1
  33. package/esm/plots/line/types.d.ts +1 -1
  34. package/esm/plots/line/types.js.map +1 -1
  35. package/esm/plots/liquid/adaptor.js +2 -1
  36. package/esm/plots/liquid/adaptor.js.map +1 -1
  37. package/esm/plots/liquid/shapes/liquid.js +5 -3
  38. package/esm/plots/liquid/shapes/liquid.js.map +1 -1
  39. package/esm/plots/liquid/types.d.ts +1 -0
  40. package/esm/plots/liquid/types.js.map +1 -1
  41. package/esm/plots/pie/adaptor.js +2 -0
  42. package/esm/plots/pie/adaptor.js.map +1 -1
  43. package/esm/plots/pie/contants.js +1 -0
  44. package/esm/plots/pie/contants.js.map +1 -1
  45. package/esm/plots/progress/adaptor.js +1 -0
  46. package/esm/plots/progress/adaptor.js.map +1 -1
  47. package/esm/plots/rose/constant.js +1 -0
  48. package/esm/plots/rose/constant.js.map +1 -1
  49. package/esm/plots/sankey/adaptor.js +31 -2
  50. package/esm/plots/sankey/adaptor.js.map +1 -1
  51. package/esm/plots/sankey/types.d.ts +8 -0
  52. package/esm/plots/sankey/types.js.map +1 -1
  53. package/esm/plots/scatter/adaptor.d.ts +1 -1
  54. package/esm/plots/scatter/adaptor.js +2 -2
  55. package/esm/plots/scatter/adaptor.js.map +1 -1
  56. package/esm/utils/geometry.js +1 -2
  57. package/esm/utils/geometry.js.map +1 -1
  58. package/esm/utils/transform/percent.js +2 -2
  59. package/esm/utils/transform/percent.js.map +1 -1
  60. package/lib/index.d.ts +1 -9
  61. package/lib/index.js +5 -13
  62. package/lib/index.js.map +1 -1
  63. package/lib/plots/area/adaptor.js +20 -20
  64. package/lib/plots/area/adaptor.js.map +1 -1
  65. package/lib/plots/area/constants.d.ts +0 -2
  66. package/lib/plots/area/constants.js +2 -3
  67. package/lib/plots/area/constants.js.map +1 -1
  68. package/lib/plots/area/index.js +3 -10
  69. package/lib/plots/area/index.js.map +1 -1
  70. package/lib/plots/area/types.d.ts +1 -1
  71. package/lib/plots/area/types.js.map +1 -1
  72. package/lib/plots/bar/constants.js +3 -0
  73. package/lib/plots/bar/constants.js.map +1 -1
  74. package/lib/plots/column/constants.js +3 -0
  75. package/lib/plots/column/constants.js.map +1 -1
  76. package/lib/plots/dual-axes/util/render-sider.js +1 -1
  77. package/lib/plots/dual-axes/util/render-sider.js.map +1 -1
  78. package/lib/plots/gauge/adaptor.js +1 -0
  79. package/lib/plots/gauge/adaptor.js.map +1 -1
  80. package/lib/plots/line/adaptor.js +16 -30
  81. package/lib/plots/line/adaptor.js.map +1 -1
  82. package/lib/plots/line/constants.d.ts +0 -2
  83. package/lib/plots/line/constants.js +2 -4
  84. package/lib/plots/line/constants.js.map +1 -1
  85. package/lib/plots/line/index.js +0 -7
  86. package/lib/plots/line/index.js.map +1 -1
  87. package/lib/plots/line/interactions/marker-active.js +6 -7
  88. package/lib/plots/line/interactions/marker-active.js.map +1 -1
  89. package/lib/plots/line/types.d.ts +1 -1
  90. package/lib/plots/line/types.js.map +1 -1
  91. package/lib/plots/liquid/adaptor.js +2 -1
  92. package/lib/plots/liquid/adaptor.js.map +1 -1
  93. package/lib/plots/liquid/shapes/liquid.js +5 -3
  94. package/lib/plots/liquid/shapes/liquid.js.map +1 -1
  95. package/lib/plots/liquid/types.d.ts +1 -0
  96. package/lib/plots/liquid/types.js.map +1 -1
  97. package/lib/plots/pie/adaptor.js +2 -0
  98. package/lib/plots/pie/adaptor.js.map +1 -1
  99. package/lib/plots/pie/contants.js +1 -0
  100. package/lib/plots/pie/contants.js.map +1 -1
  101. package/lib/plots/progress/adaptor.js +1 -0
  102. package/lib/plots/progress/adaptor.js.map +1 -1
  103. package/lib/plots/rose/constant.js +1 -0
  104. package/lib/plots/rose/constant.js.map +1 -1
  105. package/lib/plots/sankey/adaptor.js +30 -1
  106. package/lib/plots/sankey/adaptor.js.map +1 -1
  107. package/lib/plots/sankey/types.d.ts +8 -0
  108. package/lib/plots/sankey/types.js.map +1 -1
  109. package/lib/plots/scatter/adaptor.d.ts +1 -1
  110. package/lib/plots/scatter/adaptor.js +1 -1
  111. package/lib/plots/scatter/adaptor.js.map +1 -1
  112. package/lib/utils/geometry.js +1 -2
  113. package/lib/utils/geometry.js.map +1 -1
  114. package/lib/utils/transform/percent.js +2 -2
  115. package/lib/utils/transform/percent.js.map +1 -1
  116. package/package.json +2 -2
  117. package/src/index.ts +1 -9
  118. package/src/plots/area/adaptor.ts +25 -26
  119. package/src/plots/area/constants.ts +1 -3
  120. package/src/plots/area/index.ts +3 -10
  121. package/src/plots/area/types.ts +1 -1
  122. package/src/plots/bar/constants.ts +3 -0
  123. package/src/plots/column/constants.ts +3 -0
  124. package/src/plots/dual-axes/util/render-sider.ts +1 -1
  125. package/src/plots/gauge/adaptor.ts +1 -0
  126. package/src/plots/line/adaptor.ts +28 -37
  127. package/src/plots/line/constants.ts +1 -4
  128. package/src/plots/line/index.ts +1 -8
  129. package/src/plots/line/interactions/marker-active.ts +7 -8
  130. package/src/plots/line/types.ts +1 -1
  131. package/src/plots/liquid/adaptor.ts +2 -1
  132. package/src/plots/liquid/shapes/liquid.ts +6 -3
  133. package/src/plots/liquid/types.ts +1 -0
  134. package/src/plots/pie/adaptor.ts +2 -0
  135. package/src/plots/pie/contants.ts +1 -0
  136. package/src/plots/progress/adaptor.ts +1 -0
  137. package/src/plots/rose/constant.ts +1 -0
  138. package/src/plots/sankey/adaptor.ts +35 -2
  139. package/src/plots/sankey/types.ts +8 -0
  140. package/src/plots/scatter/adaptor.ts +3 -1
  141. package/src/utils/geometry.ts +1 -2
  142. package/src/utils/transform/percent.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"percent.js","sourceRoot":"","sources":["../../../src/utils/transform/percent.ts"],"names":[],"mappings":";;;;AAAA,mCAAyC;AAEzC,oCAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,IAAU,EAAE,OAAe,EAAE,UAAkB,EAAE,EAAU;IACjF,qBAAqB;IACrB,IAAM,MAAM,GAAG,aAAM,CACnB,IAAI,EACJ,UAAC,GAAG,EAAE,KAAY;QAChB,IAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QACrC,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CA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AExD,IAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAEzB,GAAG,GAAG,qBAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACtC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAEzB,OAAO,GAAG,CAAC;IACb,CAAC,EACD,IAAI,GAAG,EAAkB,CAC1B,CAAC;IAEF,eAAe;IACf,OAAO,UAAG,CAAC,IAAI,EAAE,UAAC,KAAY;;QAC5B,IAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACzB,gBAAgB;QAChB,IAAM,UAAU,GAAG,aAAM,CAAC,MAAM,EAAE,UAAC,KAAK,EAAE,KAAK,IAAK,OAAA,KAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAG,EAAzB,CAAyB,EAAE,EAAE,CAAC,CAAC;QAEnF,IAAM,UAAU,GAAG,qBAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpE,6CACK,KAAK,gBACP,OAAO,IAAG,UAAU,OACrB;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAhCD,wCAgCC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,IAA2B,EAC3B,MAAc,EACd,UAAkB,EAClB,OAAe,EACf,SAAmB;IAEnB,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AARD,0DAQC","sourcesContent":["import { map, reduce } from '@antv/util';\nimport { Data, Datum } from '../../types';\nimport { isRealNumber } from '../number';\n\n/**\n * 对数据进行百分比化\n * @param data\n * @param measure\n * @param groupField\n * @param as\n */\nexport function percent(data: Data, measure: string, groupField: string, as: string) {\n // 1. 先计算每一个分组的 max 值\n const sumMap = reduce(\n data,\n (map, datum: Datum) => {\n const groupValue = datum[groupField];\n let sum = map.has(groupValue) ? map.get(groupValue) : 0;\n\n const v = datum[measure];\n\n sum = isRealNumber(v) ? sum + v : sum;\n map.set(groupValue, sum);\n\n return map;\n },\n new Map<string, number>()\n );\n\n // 2. 循环数组,计算占比\n return map(data, (datum: Datum) => {\n const v = datum[measure];\n const groupValue = datum[groupField];\n const percentage = isRealNumber(v) ? v / sumMap.get(groupValue) : 0;\n\n return {\n ...datum,\n [as]: percentage,\n };\n });\n}\n\n/**\n * 对数据进行深层百分比化\n * @param data\n * @param measure // 数值\n * @param fields // 需要分组的 field值\n * @param as // 存储percent 百分比的值\n */\nexport function getDeepPercent(data: Record<string, any>[], measure: string, fields: string[], percent: string) {\n const sumMap = reduce(\n data,\n (map, datum: Datum) => {\n // 获取分组得到的枚举key值\n const groupValue = reduce(fields, (value, field) => `${value}${datum[field]}`, '');\n\n let sum = map.has(groupValue) ? map.get(groupValue) : 0;\n\n const v = datum[measure];\n\n sum = isRealNumber(v) ? sum + v : sum;\n map.set(groupValue, sum);\n\n return map;\n },\n new Map<string, number>()\n );\n\n // 2. 循环数组,计算占比\n return map(data, (datum: Datum) => {\n const v = datum[measure];\n // 获取分组得到的枚举key值\n const groupValue = reduce(fields, (value, field) => `${value}${datum[field]}`, '');\n\n const percentage = isRealNumber(v) ? v / sumMap.get(groupValue) : 0;\n\n return {\n ...datum,\n [percent]: percentage,\n };\n });\n}\n\n/**\n * 获取数据,如果是百分比,进行数据转换 (适用于面积图、柱状图、条形图)\n * @param isPercent 是否百分比\n */\nexport function getDataWhetherPecentage(\n data: Record<string, any>[],\n yField: string,\n groupField: string,\n asField: string,\n isPercent?: boolean\n) {\n return !isPercent ? data : percent(data, yField, groupField, asField);\n}\n"]}
1
+ {"version":3,"file":"percent.js","sourceRoot":"","sources":["../../../src/utils/transform/percent.ts"],"names":[],"mapp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ACK,KAAK,gBACP,OAAO,IAAG,UAAU,OACrB;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAhCD,wCAgCC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,IAA2B,EAC3B,MAAc,EACd,UAAkB,EAClB,OAAe,EACf,SAAmB;IAEnB,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AARD,0DAQC","sourcesContent":["import { map, reduce } from '@antv/util';\nimport { Data, Datum } from '../../types';\nimport { isRealNumber } from '../number';\n\n/**\n * 对数据进行百分比化\n * @param data\n * @param measure\n * @param groupField\n * @param as\n */\nexport function percent(data: Data, measure: string, groupField: string, as: string) {\n // 1. 先计算每一个分组的 max 值\n const sumMap = reduce(\n data,\n (map, datum: Datum) => {\n const groupValue = datum[groupField];\n let sum = map.has(groupValue) ? map.get(groupValue) : 0;\n\n const v = datum[measure];\n\n sum = isRealNumber(v) ? sum + v : sum;\n map.set(groupValue, sum);\n\n return map;\n },\n new Map<string, number>()\n );\n\n // 2. 循环数组,计算占比\n return map(data, (datum: Datum) => {\n const v = datum[measure];\n const groupValue = datum[groupField];\n const percentage = isRealNumber(v) && sumMap.get(groupValue) !== 0 ? v / sumMap.get(groupValue) : 0;\n\n return {\n ...datum,\n [as]: percentage,\n };\n });\n}\n\n/**\n * 对数据进行深层百分比化\n * @param data\n * @param measure // 数值\n * @param fields // 需要分组的 field值\n * @param as // 存储percent 百分比的值\n */\nexport function getDeepPercent(data: Record<string, any>[], measure: string, fields: string[], percent: string) {\n const sumMap = reduce(\n data,\n (map, datum: Datum) => {\n // 获取分组得到的枚举key值\n const groupValue = reduce(fields, (value, field) => `${value}${datum[field]}`, '');\n\n let sum = map.has(groupValue) ? map.get(groupValue) : 0;\n\n const v = datum[measure];\n\n sum = isRealNumber(v) ? sum + v : sum;\n map.set(groupValue, sum);\n\n return map;\n },\n new Map<string, number>()\n );\n\n // 2. 循环数组,计算占比\n return map(data, (datum: Datum) => {\n const v = datum[measure];\n // 获取分组得到的枚举key值\n const groupValue = reduce(fields, (value, field) => `${value}${datum[field]}`, '');\n\n const percentage = isRealNumber(v) && sumMap.get(groupValue) !== 0 ? v / sumMap.get(groupValue) : 0;\n\n return {\n ...datum,\n [percent]: percentage,\n };\n });\n}\n\n/**\n * 获取数据,如果是百分比,进行数据转换 (适用于面积图、柱状图、条形图)\n * @param isPercent 是否百分比\n */\nexport function getDataWhetherPecentage(\n data: Record<string, any>[],\n yField: string,\n groupField: string,\n asField: string,\n isPercent?: boolean\n) {\n return !isPercent ? data : percent(data, yField, groupField, asField);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g2plot",
3
- "version": "2.4.3",
3
+ "version": "2.4.8",
4
4
  "description": "An interactive and responsive charting library",
5
5
  "keywords": [
6
6
  "chart",
@@ -145,7 +145,7 @@
145
145
  "limit-size": [
146
146
  {
147
147
  "path": "dist/g2plot.min.js",
148
- "limit": "998 Kb"
148
+ "limit": "1000 Kb"
149
149
  },
150
150
  {
151
151
  "path": "dist/g2plot.min.js",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '2.4.3';
1
+ export const version = '2.4.8';
2
2
 
3
3
  // G2 自定义能力透出
4
4
  import * as G2 from '@antv/g2';
@@ -176,14 +176,6 @@ export type { MixOptions } from './plots/mix';
176
176
  export { Facet } from './plots/facet';
177
177
  export type { FacetOptions } from './plots/facet';
178
178
 
179
- /** 提供一些工具方法 */
180
- import { findGeometry, getAllGeometriesRecursively, findViewById } from './utils';
181
- const Util = {
182
- findGeometry,
183
- findViewById,
184
- getAllGeometriesRecursively,
185
- };
186
- export { Util };
187
179
  /** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */
188
180
  export { flow, measureTextWidth } from './utils';
189
181
 
@@ -1,14 +1,13 @@
1
1
  import { Geometry } from '@antv/g2';
2
- import { each, isNil } from '@antv/util';
2
+ import { each, omit } from '@antv/util';
3
3
  import { tooltip, slider, interaction, animation, theme, annotation, limitInPlot, pattern } from '../../adaptor/common';
4
- import { findGeometry, getAllGeometriesRecursively } from '../../utils';
4
+ import { findGeometry } from '../../utils';
5
5
  import { Params } from '../../core/adaptor';
6
6
  import { area, point, line } from '../../adaptor/geometries';
7
7
  import { flow, transformLabel, deepAssign } from '../../utils';
8
8
  import { getDataWhetherPecentage } from '../../utils/transform/percent';
9
9
  import { Datum } from '../../types';
10
10
  import { meta, legend, axis } from '../line/adaptor';
11
- import { POINT_VIEW_ID } from './constants';
12
11
  import { AreaOptions } from './types';
13
12
 
14
13
  export { meta };
@@ -49,12 +48,6 @@ function geometry(params: Params<AreaOptions>): Params<AreaOptions> {
49
48
  const primary = deepAssign({}, params, {
50
49
  options: {
51
50
  area: { color, style: areaStyle },
52
- // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。
53
- // 如果存在,才设置,否则为空
54
- line: lineMapping && {
55
- color,
56
- ...lineMapping,
57
- },
58
51
  point: pointMapping && {
59
52
  color,
60
53
  ...pointMapping,
@@ -67,25 +60,32 @@ function geometry(params: Params<AreaOptions>): Params<AreaOptions> {
67
60
  },
68
61
  },
69
62
  });
70
- // 线默认 2px
71
- const lineParams = deepAssign({ options: { line: { size: 2 } } }, primary, {
72
- options: { sizeField: seriesField, tooltip: false },
73
- });
63
+ // 线默认 2px (折线不能复用面积图的 state,因为 fill 和 stroke 不匹配)
64
+ const lineParams = {
65
+ chart,
66
+ options: deepAssign({ line: { size: 2 } }, omit(options as any, ['state']), {
67
+ // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。
68
+ // 如果存在,才设置,否则为空
69
+ line: lineMapping && {
70
+ color,
71
+ ...lineMapping,
72
+ },
73
+ sizeField: seriesField,
74
+ state: lineMapping?.state,
75
+ tooltip: false,
76
+ // label 不传递给各个 geometry adaptor,由 label adaptor 处理
77
+ label: undefined,
78
+ args: {
79
+ startOnZero,
80
+ },
81
+ }),
82
+ };
83
+ const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
74
84
 
75
85
  // area geometry 处理
76
86
  area(primary);
77
87
  line(lineParams);
78
-
79
- const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
80
- if (pointMapping) {
81
- const pointView = chart.createView({ id: POINT_VIEW_ID });
82
- pointView.axis(false);
83
- pointView.tooltip(false);
84
- pointView.legend(false);
85
- // [PERFORMANCE] 🚀 数据为空的 point 标注点都不渲染(不包括:数据为 0)
86
- pointView.data(data.filter((d) => !isNil(d[yField])));
87
- point({ ...pointParams, chart: pointView });
88
- }
88
+ point(pointParams);
89
89
 
90
90
  return params;
91
91
  }
@@ -131,8 +131,7 @@ function adjust(params: Params<AreaOptions>): Params<AreaOptions> {
131
131
  const { chart, options } = params;
132
132
  const { isStack, isPercent, seriesField } = options;
133
133
  if ((isPercent || isStack) && seriesField) {
134
- const geometries = getAllGeometriesRecursively(chart);
135
- each(geometries, (g: Geometry) => {
134
+ each(chart.geometries, (g: Geometry) => {
136
135
  g.adjust('stack');
137
136
  });
138
137
  }
@@ -1,9 +1,6 @@
1
1
  import { Plot } from '../../core/plot';
2
2
  import { deepAssign } from '../../utils';
3
3
 
4
- /** point 标注点视图 */
5
- export const POINT_VIEW_ID = 'point-view';
6
-
7
4
  /**
8
5
  * 面积图默认配置项
9
6
  */
@@ -21,5 +18,6 @@ export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
21
18
  line: {},
22
19
  legend: {
23
20
  position: 'top-left',
21
+ radio: {},
24
22
  },
25
23
  });
@@ -1,11 +1,9 @@
1
- import { isNil } from '@antv/util';
2
1
  import { Plot } from '../../core/plot';
3
2
  import { Adaptor } from '../../core/adaptor';
4
3
  import { getDataWhetherPecentage } from '../../utils/transform/percent';
5
- import { findViewById } from '../../utils';
6
4
  import { AreaOptions } from './types';
7
5
  import { adaptor, meta } from './adaptor';
8
- import { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';
6
+ import { DEFAULT_OPTIONS } from './constants';
9
7
 
10
8
  export type { AreaOptions };
11
9
 
@@ -34,15 +32,10 @@ export class Area extends Plot<AreaOptions> {
34
32
  */
35
33
  public changeData(data: AreaOptions['data']) {
36
34
  this.updateOption({ data });
35
+ const { isPercent, xField, yField } = this.options;
37
36
  const { chart, options } = this;
38
- const { isPercent, xField, yField } = options;
39
37
  meta({ chart, options });
40
- const chartdata = getDataWhetherPecentage(data, yField, xField, yField, isPercent);
41
- this.chart.changeData(chartdata);
42
- const pointView = findViewById(this.chart, POINT_VIEW_ID);
43
- if (pointView) {
44
- pointView.changeData(data.filter((d) => !isNil(d[yField])));
45
- }
38
+ this.chart.changeData(getDataWhetherPecentage(data, yField, xField, yField, isPercent));
46
39
  }
47
40
 
48
41
  /**
@@ -18,7 +18,7 @@ export interface AreaOptions extends Options, Pick<GeometryOptions, 'customInfo'
18
18
  /** 面积图形样式 */
19
19
  readonly areaStyle?: StyleAttr;
20
20
  /** 面积中折线的样式 */
21
- readonly line?: LineGeometryOptions['line'];
21
+ readonly line?: LineGeometryOptions['line'] & Pick<PointGeometryOptions, 'state'>;
22
22
  /** 面积图数据点图形样式 */
23
23
  readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;
24
24
  /** 积图是否从 0 基准线开始填充 */
@@ -12,5 +12,8 @@ export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
12
12
  showMarkers: false,
13
13
  offset: 20,
14
14
  },
15
+ legend: {
16
+ radio: {},
17
+ },
15
18
  interactions: [{ type: 'active-region' }],
16
19
  });
@@ -12,5 +12,8 @@ export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
12
12
  showMarkers: false,
13
13
  offset: 20,
14
14
  },
15
+ legend: {
16
+ radio: {},
17
+ },
15
18
  interactions: [{ type: 'active-region' }],
16
19
  });
@@ -29,5 +29,5 @@ export const doSliderFilter = (view: View, sliderValue: [number, number]) => {
29
29
  const idx: number = xValues.indexOf(value);
30
30
  return idx > -1 ? isBetween(idx, minIndex, maxIndex) : true;
31
31
  });
32
- view.render(true);
32
+ view.getRootView().render(true);
33
33
  };
@@ -70,6 +70,7 @@ function geometry(params: Params<GaugeOptions>): Params<GaugeOptions> {
70
70
  },
71
71
  args: {
72
72
  zIndexReversed: true,
73
+ sortZIndex: true,
73
74
  },
74
75
  minColumnWidth: rangeWidth,
75
76
  maxColumnWidth: rangeWidth,
@@ -1,11 +1,21 @@
1
1
  import { Geometry } from '@antv/g2';
2
- import { each, isArray, isNil, uniq } from '@antv/util';
2
+ import { each, isArray } from '@antv/util';
3
3
  import { Params } from '../../core/adaptor';
4
- import { tooltip, slider, interaction, animation, theme, scale, annotation, limitInPlot } from '../../adaptor/common';
5
- import { flow, findGeometry, transformLabel, deepAssign, getAllGeometriesRecursively } from '../../utils';
4
+ import {
5
+ tooltip,
6
+ slider,
7
+ interaction,
8
+ animation,
9
+ theme,
10
+ scale,
11
+ annotation,
12
+ limitInPlot,
13
+ scrollbar,
14
+ } from '../../adaptor/common';
15
+ import { findGeometry, transformLabel, deepAssign } from '../../utils';
6
16
  import { point, line, area } from '../../adaptor/geometries';
17
+ import { flow } from '../../utils';
7
18
  import { adjustYMetaByZero } from '../../utils/data';
8
- import { POINT_VIEW_ID } from './constants';
9
19
  import { LineOptions } from './types';
10
20
 
11
21
  /**
@@ -14,8 +24,9 @@ import { LineOptions } from './types';
14
24
  */
15
25
  function geometry(params: Params<LineOptions>): Params<LineOptions> {
16
26
  const { chart, options } = params;
17
- const { data, color, lineStyle, lineShape, point: pointMapping, area: areaMapping, yField, seriesField } = options;
27
+ const { data, color, lineStyle, lineShape, point: pointMapping, area: areaMapping, seriesField } = options;
18
28
  const pointState = pointMapping?.state;
29
+ const areaState = areaMapping?.state;
19
30
 
20
31
  chart.data(data);
21
32
 
@@ -44,23 +55,13 @@ function geometry(params: Params<LineOptions>): Params<LineOptions> {
44
55
  label: undefined,
45
56
  },
46
57
  });
47
-
48
- const areaParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
58
+ const second = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
59
+ const areaParams = deepAssign({}, primary, { options: { tooltip: false, state: areaState } });
49
60
 
50
61
  line(primary);
62
+ point(second);
51
63
  area(areaParams);
52
64
 
53
- const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
54
- if (pointMapping) {
55
- const pointView = chart.createView({ id: POINT_VIEW_ID });
56
- pointView.axis(false);
57
- pointView.tooltip(false);
58
- pointView.legend(false);
59
- // [PERFORMANCE] 🚀 数据为空的 point 标注点都不渲染(不包括:数据为 0)
60
- pointView.data(data.filter((d) => !isNil(d[yField])));
61
- point({ ...pointParams, chart: pointView });
62
- }
63
-
64
65
  return params;
65
66
  }
66
67
 
@@ -70,21 +71,7 @@ function geometry(params: Params<LineOptions>): Params<LineOptions> {
70
71
  */
71
72
  export function meta(params: Params<LineOptions>): Params<LineOptions> {
72
73
  const { options } = params;
73
- const { xAxis, yAxis, xField, yField, data, seriesField } = options;
74
- const defaultMeta = {
75
- [xField]: {
76
- type: 'cat',
77
- sync: true,
78
- values: uniq(data.map((d) => d[xField])),
79
- },
80
- [yField]: {
81
- ...adjustYMetaByZero(data, yField),
82
- sync: true,
83
- },
84
- };
85
- if (seriesField) {
86
- defaultMeta[seriesField] = { sync: true };
87
- }
74
+ const { xAxis, yAxis, xField, yField, data } = options;
88
75
 
89
76
  return flow(
90
77
  scale(
@@ -92,7 +79,12 @@ export function meta(params: Params<LineOptions>): Params<LineOptions> {
92
79
  [xField]: xAxis,
93
80
  [yField]: yAxis,
94
81
  },
95
- defaultMeta
82
+ {
83
+ [xField]: {
84
+ type: 'cat',
85
+ },
86
+ [yField]: adjustYMetaByZero(data, yField),
87
+ }
96
88
  )
97
89
  )(params);
98
90
  }
@@ -199,10 +191,8 @@ export function adjust(params: Params<Pick<LineOptions, 'isStack'>>): Params<any
199
191
  const { chart, options } = params;
200
192
  const { isStack } = options;
201
193
 
202
- const geometries = getAllGeometriesRecursively(chart);
203
-
204
194
  if (isStack) {
205
- each(geometries, (g: Geometry) => {
195
+ each(chart.geometries, (g: Geometry) => {
206
196
  g.adjust('stack');
207
197
  });
208
198
  }
@@ -228,6 +218,7 @@ export function adaptor(params: Params<LineOptions>) {
228
218
  tooltip,
229
219
  label,
230
220
  slider,
221
+ scrollbar,
231
222
  interaction,
232
223
  animation,
233
224
  annotation(),
@@ -1,14 +1,10 @@
1
1
  import { Plot } from '../../core/plot';
2
2
  import { deepAssign } from '../../utils';
3
3
 
4
- /** point 标注点视图 */
5
- export const POINT_VIEW_ID = 'point-view';
6
-
7
4
  /**
8
5
  * 折线图默认配置项
9
6
  */
10
7
  export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
11
- syncViewPadding: true,
12
8
  tooltip: {
13
9
  shared: true,
14
10
  showMarkers: true,
@@ -19,6 +15,7 @@ export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
19
15
  },
20
16
  legend: {
21
17
  position: 'top-left',
18
+ radio: {},
22
19
  },
23
20
  isStack: false,
24
21
  });
@@ -1,10 +1,8 @@
1
- import { isNil } from '@antv/util';
2
1
  import { Plot } from '../../core/plot';
3
2
  import { Adaptor } from '../../core/adaptor';
4
- import { findViewById } from '../../utils';
5
3
  import { LineOptions } from './types';
6
4
  import { adaptor, meta } from './adaptor';
7
- import { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';
5
+ import { DEFAULT_OPTIONS } from './constants';
8
6
  import './interactions';
9
7
 
10
8
  export type { LineOptions };
@@ -28,13 +26,8 @@ export class Line extends Plot<LineOptions> {
28
26
  public changeData(data: LineOptions['data']) {
29
27
  this.updateOption({ data });
30
28
  const { chart, options } = this;
31
- const { yField } = options;
32
29
  meta({ chart, options });
33
30
  this.chart.changeData(data);
34
- const pointView = findViewById(this.chart, POINT_VIEW_ID);
35
- if (pointView) {
36
- pointView.changeData(data.filter((d) => !isNil(d[yField])));
37
- }
38
31
  }
39
32
 
40
33
  /**
@@ -1,6 +1,5 @@
1
1
  import { each, findIndex } from '@antv/util';
2
- import { InteractionAction, View } from '@antv/g2';
3
- import { findGeometry } from '../../../utils';
2
+ import { InteractionAction, View, Geometry } from '@antv/g2';
4
3
 
5
4
  export class MarkerActiveAction extends InteractionAction {
6
5
  public active() {
@@ -9,24 +8,24 @@ export class MarkerActiveAction extends InteractionAction {
9
8
  if (evt.data) {
10
9
  // items: 数组对象,当前 tooltip 显示的每条内容
11
10
  const { items } = evt.data;
12
- const point = findGeometry(view, 'point');
13
- if (point) {
11
+ const points = view.geometries.filter((geom) => geom.type === 'point');
12
+ each(points, (point: Geometry) => {
14
13
  each(point.elements, (element) => {
15
14
  const active = findIndex(items, (item) => (item as any).data === element.data) !== -1;
16
15
  element.setState('active', active);
17
16
  });
18
- }
17
+ });
19
18
  }
20
19
  }
21
20
 
22
21
  public reset() {
23
22
  const view = this.getView();
24
- const point = findGeometry(view, 'point');
25
- if (point) {
23
+ const points = view.geometries.filter((geom) => geom.type === 'point');
24
+ each(points, (point: Geometry) => {
26
25
  each(point.elements, (element) => {
27
26
  element.setState('active', false);
28
27
  });
29
- }
28
+ });
30
29
  }
31
30
 
32
31
  private getView(): View {
@@ -28,7 +28,7 @@ export interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'
28
28
  /** 折线数据点:1、图形映射属性 2、状态样式 */
29
29
  readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;
30
30
  /** 折线趋势填充色:1、图形映射属性 */
31
- readonly area?: AreaGeometryOptions['area'];
31
+ readonly area?: AreaGeometryOptions['area'] & Pick<PointGeometryOptions, 'state'>;
32
32
 
33
33
  // 其他
34
34
  /** 坐标轴反转配置 */
@@ -13,7 +13,7 @@ import { getLiquidData } from './utils';
13
13
  */
14
14
  function geometry(params: Params<LiquidOptions>): Params<LiquidOptions> {
15
15
  const { chart, options } = params;
16
- const { percent, liquidStyle, radius, outline, wave, shape } = options;
16
+ const { percent, liquidStyle, radius, outline, wave, shape, animation } = options;
17
17
 
18
18
  chart.scale({
19
19
  percent: {
@@ -49,6 +49,7 @@ function geometry(params: Params<LiquidOptions>): Params<LiquidOptions> {
49
49
  wave,
50
50
  shape,
51
51
  background,
52
+ animation,
52
53
  };
53
54
 
54
55
  // 将 radius 传入到自定义 shape 中
@@ -212,7 +212,8 @@ function addWaterWave(
212
212
  group: IGroup,
213
213
  clip: IShape,
214
214
  radius: number,
215
- waveLength: number
215
+ waveLength: number,
216
+ animation: LiquidOptions['animation']
216
217
  ) {
217
218
  const { fill, opacity } = waveAttrs;
218
219
  const bbox = clip.getBBox();
@@ -239,6 +240,7 @@ function addWaterWave(
239
240
  });
240
241
 
241
242
  try {
243
+ if (animation === false) return;
242
244
  const matrix = transform([['t', waveLength, 0]]);
243
245
 
244
246
  wave.stopAnimate();
@@ -373,7 +375,7 @@ registerShape('interval', 'liquid-fill-gauge', {
373
375
  const cy = 0.5;
374
376
 
375
377
  const { customInfo } = cfg;
376
- const { radius: radio, shape, background } = customInfo as CustomInfo;
378
+ const { radius: radio, shape, background, animation } = customInfo as CustomInfo;
377
379
  const outline: LiquidOptions['outline'] = customInfo.outline;
378
380
  const wave: LiquidOptions['wave'] = customInfo.wave;
379
381
  const { border, distance } = outline;
@@ -430,7 +432,8 @@ registerShape('interval', 'liquid-fill-gauge', {
430
432
  waves,
431
433
  clipPath,
432
434
  radius * 2,
433
- waveLength
435
+ waveLength,
436
+ animation
434
437
  );
435
438
 
436
439
  // 2. 绘制一个 distance 宽的 border
@@ -49,4 +49,5 @@ export type CustomInfo = {
49
49
  wave?: LiquidOptions['wave'];
50
50
  shape?: LiquidOptions['shape'];
51
51
  background?: string;
52
+ animation?: LiquidOptions['animation'];
52
53
  };
@@ -42,6 +42,7 @@ function geometry(params: Params<PieOptions>): Params<PieOptions> {
42
42
  },
43
43
  args: {
44
44
  zIndexReversed: true,
45
+ sortZIndex: true,
45
46
  },
46
47
  },
47
48
  });
@@ -62,6 +63,7 @@ function geometry(params: Params<PieOptions>): Params<PieOptions> {
62
63
  },
63
64
  args: {
64
65
  zIndexReversed: true,
66
+ sortZIndex: true,
65
67
  },
66
68
  },
67
69
  });
@@ -7,6 +7,7 @@ import { deepAssign } from '../../utils';
7
7
  export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
8
8
  legend: {
9
9
  position: 'right',
10
+ radio: {},
10
11
  },
11
12
  tooltip: {
12
13
  shared: false,
@@ -30,6 +30,7 @@ export function geometry(params: Params<ProgressOptions>): Params<ProgressOption
30
30
  },
31
31
  args: {
32
32
  zIndexReversed: true,
33
+ sortZIndex: true,
33
34
  },
34
35
  },
35
36
  });
@@ -9,6 +9,7 @@ export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
9
9
  yAxis: false,
10
10
  legend: {
11
11
  position: 'right',
12
+ radio: {},
12
13
  },
13
14
  sectorStyle: {
14
15
  stroke: '#fff',
@@ -1,7 +1,7 @@
1
1
  import { uniq } from '@antv/util';
2
- import { interaction, theme } from '../../adaptor/common';
2
+ import { theme } from '../../adaptor/common';
3
3
  import { Params } from '../../core/adaptor';
4
- import { deepAssign, flow } from '../../utils';
4
+ import { deepAssign, findViewById, flow } from '../../utils';
5
5
  import { polygon, edge } from '../../adaptor/geometries';
6
6
  import { transformToViewsData } from './helper';
7
7
  import { SankeyOptions } from './types';
@@ -146,6 +146,39 @@ export function nodeDraggable(params: Params<SankeyOptions>): Params<SankeyOptio
146
146
  return params;
147
147
  }
148
148
 
149
+ /**
150
+ * Interaction 配置
151
+ * @param params
152
+ */
153
+ function interaction(params: Params<SankeyOptions>): Params<SankeyOptions> {
154
+ const { chart, options } = params;
155
+ const { interactions = [] } = options;
156
+
157
+ const nodeInteractions = [].concat(interactions, options.nodeInteractions || []);
158
+ const edgeInteractions = [].concat(interactions, options.edgeInteractions || []);
159
+
160
+ const nodeView = findViewById(chart, NODES_VIEW_ID);
161
+ const edgeView = findViewById(chart, EDGES_VIEW_ID);
162
+
163
+ nodeInteractions.forEach((i) => {
164
+ if (i?.enable === false) {
165
+ nodeView.removeInteraction(i.type);
166
+ } else {
167
+ nodeView.interaction(i.type, i.cfg || {});
168
+ }
169
+ });
170
+
171
+ edgeInteractions.forEach((i) => {
172
+ if (i?.enable === false) {
173
+ edgeView.removeInteraction(i.type);
174
+ } else {
175
+ edgeView.interaction(i.type, i.cfg || {});
176
+ }
177
+ });
178
+
179
+ return params;
180
+ }
181
+
149
182
  /**
150
183
  * 图适配器
151
184
  * @param chart
@@ -115,4 +115,12 @@ export interface SankeyOptions extends Omit<Options, 'data' | 'xField' | 'yField
115
115
  * 节点位置是否可以拖拽,默认为 false
116
116
  */
117
117
  readonly nodeDraggable?: boolean;
118
+ /**
119
+ * 边交互
120
+ */
121
+ readonly edgeInteractions?: Options['interactions'];
122
+ /**
123
+ * 节点交互
124
+ */
125
+ readonly nodeInteractions?: Options['interactions'];
118
126
  }
@@ -3,7 +3,7 @@ import { Params } from '../../core/adaptor';
3
3
  import { flow, deepAssign, pick } from '../../utils';
4
4
  import { point } from '../../adaptor/geometries';
5
5
  import { brushInteraction } from '../../adaptor/brush';
6
- import { interaction, animation, theme, scale, annotation } from '../../adaptor/common';
6
+ import { interaction, animation, theme, scale, annotation, slider, scrollbar } from '../../adaptor/common';
7
7
  import { findGeometry, transformLabel } from '../../utils';
8
8
  import { getQuadrantDefaultConfig, getPath, getMeta } from './util';
9
9
  import { ScatterOptions } from './types';
@@ -327,6 +327,8 @@ export function adaptor(params: Params<ScatterOptions>) {
327
327
  label,
328
328
  // 需要在 interaction 前面
329
329
  brushInteraction,
330
+ slider,
331
+ scrollbar,
330
332
  interaction,
331
333
  scatterAnnotation,
332
334
  animation,