@antv/g2 4.1.32 → 4.1.34

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 (120) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.en-US.md +1 -1
  3. package/README.md +1 -1
  4. package/dist/g2.min.js +4 -18
  5. package/dist/g2.min.js.map +1 -1
  6. package/esm/chart/controller/scrollbar.js.map +1 -1
  7. package/esm/chart/controller/tooltip.js +2 -2
  8. package/esm/chart/controller/tooltip.js.map +1 -1
  9. package/esm/chart/layout/constraint/bounds.js.map +1 -1
  10. package/esm/chart/layout/constraint/constraint.js.map +1 -1
  11. package/esm/chart/layout/constraint/gauss.js +3 -3
  12. package/esm/chart/layout/constraint/gauss.js.map +1 -1
  13. package/esm/chart/layout/constraint/solver.js.map +1 -1
  14. package/esm/chart/layout/constraint/types.js.map +1 -1
  15. package/esm/chart/layout/constraint/variable.js.map +1 -1
  16. package/esm/chart/util/scale-pool.js +1 -1
  17. package/esm/chart/util/scale-pool.js.map +1 -1
  18. package/esm/chart/util/sync-view-padding.js.map +1 -1
  19. package/esm/chart/view.js.map +1 -1
  20. package/esm/core.d.ts +5 -1
  21. package/esm/core.js +6 -1
  22. package/esm/core.js.map +1 -1
  23. package/esm/dependents.d.ts +1 -1
  24. package/esm/dependents.js +1 -1
  25. package/esm/dependents.js.map +1 -1
  26. package/esm/geometry/label/interval.js.map +1 -1
  27. package/esm/geometry/label/layout/limit-in-plot.js.map +1 -1
  28. package/esm/geometry/shape/edge/util.js +1 -6
  29. package/esm/geometry/shape/edge/util.js.map +1 -1
  30. package/esm/geometry/shape/line/index.d.ts +6 -0
  31. package/esm/geometry/shape/line/index.js +4 -1
  32. package/esm/geometry/shape/line/index.js.map +1 -1
  33. package/esm/geometry/shape/violin/hollow.js.map +1 -1
  34. package/esm/geometry/shape/violin/index.js.map +1 -1
  35. package/esm/geometry/util/shape-size.js +1 -1
  36. package/esm/geometry/util/shape-size.js.map +1 -1
  37. package/esm/interaction/action/component/list-checked.js +1 -1
  38. package/esm/interaction/action/component/list-checked.js.map +1 -1
  39. package/esm/interaction/action/view/mousewheel-scroll.js +1 -1
  40. package/esm/interaction/action/view/mousewheel-scroll.js.map +1 -1
  41. package/esm/interface.js.map +1 -1
  42. package/esm/util/axis.js.map +1 -1
  43. package/esm/util/bbox.js +1 -2
  44. package/esm/util/bbox.js.map +1 -1
  45. package/esm/util/legend.js +3 -1
  46. package/esm/util/legend.js.map +1 -1
  47. package/esm/util/scale.js.map +1 -1
  48. package/esm/util/stat.js +1 -1
  49. package/esm/util/stat.js.map +1 -1
  50. package/lib/chart/controller/scrollbar.js.map +1 -1
  51. package/lib/chart/controller/tooltip.js +2 -2
  52. package/lib/chart/controller/tooltip.js.map +1 -1
  53. package/lib/chart/layout/constraint/bounds.js.map +1 -1
  54. package/lib/chart/layout/constraint/constraint.js.map +1 -1
  55. package/lib/chart/layout/constraint/gauss.js +3 -3
  56. package/lib/chart/layout/constraint/gauss.js.map +1 -1
  57. package/lib/chart/layout/constraint/solver.js.map +1 -1
  58. package/lib/chart/layout/constraint/types.js.map +1 -1
  59. package/lib/chart/layout/constraint/variable.js.map +1 -1
  60. package/lib/chart/util/scale-pool.js +1 -1
  61. package/lib/chart/util/scale-pool.js.map +1 -1
  62. package/lib/chart/util/sync-view-padding.js.map +1 -1
  63. package/lib/chart/view.js.map +1 -1
  64. package/lib/core.d.ts +5 -1
  65. package/lib/core.js +6 -1
  66. package/lib/core.js.map +1 -1
  67. package/lib/dependents.d.ts +1 -1
  68. package/lib/dependents.js.map +1 -1
  69. package/lib/geometry/label/interval.js.map +1 -1
  70. package/lib/geometry/label/layout/limit-in-plot.js.map +1 -1
  71. package/lib/geometry/shape/edge/util.js +1 -6
  72. package/lib/geometry/shape/edge/util.js.map +1 -1
  73. package/lib/geometry/shape/line/index.d.ts +6 -0
  74. package/lib/geometry/shape/line/index.js +5 -0
  75. package/lib/geometry/shape/line/index.js.map +1 -1
  76. package/lib/geometry/shape/violin/hollow.js.map +1 -1
  77. package/lib/geometry/shape/violin/index.js.map +1 -1
  78. package/lib/geometry/util/shape-size.js +1 -1
  79. package/lib/geometry/util/shape-size.js.map +1 -1
  80. package/lib/interaction/action/component/list-checked.js +1 -1
  81. package/lib/interaction/action/component/list-checked.js.map +1 -1
  82. package/lib/interaction/action/view/mousewheel-scroll.js.map +1 -1
  83. package/lib/interface.js.map +1 -1
  84. package/lib/util/axis.js.map +1 -1
  85. package/lib/util/bbox.js +1 -2
  86. package/lib/util/bbox.js.map +1 -1
  87. package/lib/util/legend.js +3 -1
  88. package/lib/util/legend.js.map +1 -1
  89. package/lib/util/scale.js.map +1 -1
  90. package/lib/util/stat.js +1 -1
  91. package/lib/util/stat.js.map +1 -1
  92. package/package.json +17 -15
  93. package/src/chart/controller/scrollbar.ts +12 -12
  94. package/src/chart/controller/tooltip.ts +2 -2
  95. package/src/chart/layout/constraint/bounds.ts +3 -4
  96. package/src/chart/layout/constraint/constraint.ts +4 -5
  97. package/src/chart/layout/constraint/gauss.ts +7 -7
  98. package/src/chart/layout/constraint/solver.ts +5 -6
  99. package/src/chart/layout/constraint/types.ts +2 -2
  100. package/src/chart/layout/constraint/variable.ts +2 -2
  101. package/src/chart/util/scale-pool.ts +8 -4
  102. package/src/chart/util/sync-view-padding.ts +1 -1
  103. package/src/chart/view.ts +10 -6
  104. package/src/core.ts +7 -1
  105. package/src/dependents.ts +11 -3
  106. package/src/geometry/label/interval.ts +3 -3
  107. package/src/geometry/label/layout/limit-in-plot.ts +6 -4
  108. package/src/geometry/shape/edge/util.ts +1 -6
  109. package/src/geometry/shape/line/index.ts +4 -1
  110. package/src/geometry/shape/violin/hollow.ts +1 -1
  111. package/src/geometry/shape/violin/index.ts +2 -2
  112. package/src/geometry/util/shape-size.ts +2 -5
  113. package/src/interaction/action/component/list-checked.ts +1 -1
  114. package/src/interaction/action/view/mousewheel-scroll.ts +3 -4
  115. package/src/interface.ts +5 -3
  116. package/src/util/axis.ts +9 -4
  117. package/src/util/bbox.ts +1 -2
  118. package/src/util/legend.ts +6 -4
  119. package/src/util/scale.ts +9 -4
  120. package/src/util/stat.ts +9 -5
@@ -12,7 +12,7 @@ export default class IntervalLabel extends GeometryLabel {
12
12
  * 获取 interval label 的方向,取决于 value 的值是正还是负
13
13
  * @param labelCfg
14
14
  */
15
- private getLabelValueDir(mappingData: MappingDatum) {
15
+ private getLabelValueDir(mappingData: MappingDatum) {
16
16
  // points 中的 x/y 和 transpose 无关
17
17
  const dim = 'y';
18
18
  const { points } = mappingData;
@@ -38,13 +38,13 @@ export default class IntervalLabel extends GeometryLabel {
38
38
  point = {
39
39
  ...point,
40
40
  x: point.x * -1,
41
- }
41
+ };
42
42
  }
43
43
  if (coordinate.isReflect('y')) {
44
44
  point = {
45
45
  ...point,
46
46
  y: point.y * -1,
47
- }
47
+ };
48
48
  }
49
49
 
50
50
  return point;
@@ -38,10 +38,12 @@ export function limitInPlot(
38
38
  if (!coordinate) {
39
39
  return;
40
40
  }
41
- const { minX: regionMinX, minY: regionMinY, maxX: regionMaxX, maxY: regionMaxY } = getCoordinateBBox(
42
- coordinate,
43
- margin
44
- );
41
+ const {
42
+ minX: regionMinX,
43
+ minY: regionMinY,
44
+ maxX: regionMaxX,
45
+ maxY: regionMaxY,
46
+ } = getCoordinateBBox(coordinate, margin);
45
47
 
46
48
  each(labels, (label: IGroup) => {
47
49
  const { minX, minY, maxX, maxY, x, y, width, height } = label.getCanvasBBox();
@@ -9,12 +9,7 @@ import { Point } from '../../../interface';
9
9
  * @returns
10
10
  */
11
11
  export function getCPath(from: Point, to: Point) {
12
- return [
13
- 'C',
14
- (from.x * 1) / 2 + (to.x * 1) / 2, from.y,
15
- (from.x * 1) / 2 + (to.x * 1) / 2, to.y,
16
- to.x, to.y,
17
- ];
12
+ return ['C', (from.x * 1) / 2 + (to.x * 1) / 2, from.y, (from.x * 1) / 2 + (to.x * 1) / 2, to.y, to.x, to.y];
18
13
  }
19
14
 
20
15
  /**
@@ -82,7 +82,10 @@ function getRangePath(
82
82
  return topPath.concat(bottomPath);
83
83
  }
84
84
 
85
- function getPath(
85
+ /**
86
+ * 获取折线图 path
87
+ */
88
+ export function getPath(
86
89
  points: Point[] | RangePoint[],
87
90
  isInCircle: boolean,
88
91
  isStack?: boolean,
@@ -34,7 +34,7 @@ registerShape('violin', 'hollow', {
34
34
  /**
35
35
  * 平滑边界的空心小提琴图
36
36
  */
37
- registerShape('violin', 'hollow-smooth', {
37
+ registerShape('violin', 'hollow-smooth', {
38
38
  draw(cfg: ShapeInfo, container: IGroup) {
39
39
  const attrs = getStyle(cfg, true, false);
40
40
  const path = this.parsePath(getSmoothViolinPath(cfg.points));
@@ -5,7 +5,7 @@ import { registerShape, registerShapeFactory } from '../base';
5
5
  import { getViolinPath } from '../util/get-path-points';
6
6
  import { getStyle } from '../util/get-style';
7
7
 
8
- function normalizeSize(arr: number[]){
8
+ function normalizeSize(arr: number[]) {
9
9
  if (!isArray(arr)) {
10
10
  return [];
11
11
  }
@@ -19,7 +19,7 @@ const ViolinShapeFactory = registerShapeFactory('violin', {
19
19
  const radius = pointInfo.size / 2;
20
20
  const points = [];
21
21
  const sizeArr = normalizeSize(pointInfo._size);
22
-
22
+
23
23
  each(pointInfo.y as number[], (y, index) => {
24
24
  const offset = sizeArr[index] * radius;
25
25
  const isMin = index === 0;
@@ -41,10 +41,7 @@ export function getDefaultSize(geometry): number {
41
41
  let count: number = xValues.length;
42
42
  const xDimensionLength = getXDimensionLength(geometry.coordinate);
43
43
  // 获取柱宽相关配置项
44
- const {
45
- intervalPadding,
46
- dodgePadding,
47
- } = geometry;
44
+ const { intervalPadding, dodgePadding } = geometry;
48
45
  // 兼容theme配置
49
46
  const maxColumnWidth = geometry.maxColumnWidth || theme.maxColumnWidth;
50
47
  const minColumnWidth = geometry.minColumnWidth || theme.minColumnWidth;
@@ -108,7 +105,7 @@ export function getDefaultSize(geometry): number {
108
105
  // 组间距和组内间距均未配置
109
106
  normalizedSize = normalizedSize / dodgeCount;
110
107
  }
111
- normalizedSize = (normalizedSize >= 0) ? normalizedSize : 0;
108
+ normalizedSize = normalizedSize >= 0 ? normalizedSize : 0;
112
109
  }
113
110
 
114
111
  // 最大和最小限制
@@ -53,7 +53,7 @@ class ListChecked extends ListState {
53
53
  // 不知道 🤷‍♀️ 只认 unchecked status
54
54
  const allChecked = !some(list.getItems(), (t) => list.hasState(t, STATUS_UNCHECKED));
55
55
 
56
- //
56
+ //
57
57
  if (allChecked || list.hasState(item, STATUS_UNCHECKED)) {
58
58
  this.setItemState(list, item, true);
59
59
  } else {
@@ -1,7 +1,7 @@
1
- import { clamp, size, valuesOfKey } from "@antv/util";
2
- import { COMPONENT_TYPE } from "../../../constant";
1
+ import { clamp, size, valuesOfKey } from '@antv/util';
2
+ import { COMPONENT_TYPE } from '../../../constant';
3
3
  import { Action } from '..';
4
- import { LooseObject } from "../../../interface";
4
+ import { LooseObject } from '../../../interface';
5
5
 
6
6
  function isWheelDown(event: LooseObject) {
7
7
  const wheelEvent = event.gEvent.originalEvent as WheelEvent;
@@ -10,7 +10,6 @@ function isWheelDown(event: LooseObject) {
10
10
 
11
11
  const DEFAULT_WHEELDELTA = 1;
12
12
  class MousewheelScroll extends Action {
13
-
14
13
  public scroll(arg?) {
15
14
  const { view, event } = this.context;
16
15
 
package/src/interface.ts CHANGED
@@ -73,9 +73,11 @@ export interface RangePoint {
73
73
  /**
74
74
  * WAI-ARIA 无障碍标签配置
75
75
  */
76
- export type AriaOption = false | {
77
- readonly label: string;
78
- }
76
+ export type AriaOption =
77
+ | false
78
+ | {
79
+ readonly label: string;
80
+ };
79
81
 
80
82
  /** 用户数据经过图形映射处理后的数据结构 */
81
83
  export interface MappingDatum {
package/src/util/axis.ts CHANGED
@@ -178,14 +178,19 @@ export function getAxisThemeCfg(theme: object, direction: string): object {
178
178
 
179
179
  /**
180
180
  * get the options of axis title,mix the cfg from theme, avoid common themeCfg not work
181
- * @param theme
182
- * @param direction
183
- * @param axisOptions
181
+ * @param theme
182
+ * @param direction
183
+ * @param axisOptions
184
184
  * @returns axis title options
185
185
  */
186
186
  export function getAxisTitleOptions(theme: object, direction: string, axisOptions?: object): object {
187
187
  const axisTheme = get(theme, ['components', 'axis'], {});
188
- return deepMix({}, get(axisTheme, ['common', 'title'], {}), deepMix({}, get(axisTheme, [direction, 'title'], {})), axisOptions);
188
+ return deepMix(
189
+ {},
190
+ get(axisTheme, ['common', 'title'], {}),
191
+ deepMix({}, get(axisTheme, [direction, 'title'], {})),
192
+ axisOptions
193
+ );
189
194
  }
190
195
 
191
196
  /**
package/src/util/bbox.ts CHANGED
@@ -221,8 +221,7 @@ export class BBox {
221
221
  * @param bbox
222
222
  */
223
223
  public collide(bbox: BBox): boolean {
224
- return this.minX < bbox.maxX && this.maxX > bbox.minX &&
225
- this.minY < bbox.maxY && this.maxY > bbox.minY;
224
+ return this.minX < bbox.maxX && this.maxX > bbox.minX && this.minY < bbox.maxY && this.maxY > bbox.minY;
226
225
  }
227
226
 
228
227
  /**
@@ -82,7 +82,7 @@ export function getLegendItems(
82
82
  geometry: Geometry,
83
83
  attr: Attribute,
84
84
  themeMarker: object,
85
- userMarker: LegendCfg['marker'],
85
+ userMarker: LegendCfg['marker']
86
86
  ): ComponentLegendItem[] {
87
87
  const scale = attr.getScale(attr.type);
88
88
  if (scale.isCategory) {
@@ -115,7 +115,7 @@ export function getLegendItems(
115
115
 
116
116
  let markerCfg = userMarker;
117
117
  if (isFunction(markerCfg)) {
118
- markerCfg = markerCfg(name, index, { name, value, ...deepMix({}, themeMarker, marker) })
118
+ markerCfg = markerCfg(name, index, { name, value, ...deepMix({}, themeMarker, marker) });
119
119
  }
120
120
 
121
121
  // the marker configure order should be ensure
@@ -146,10 +146,12 @@ export function getCustomLegendItems(themeMarker: object, userMarker: object, cu
146
146
  return customItems.map((item: LegendItem, index: number) => {
147
147
  let markerCfg = userMarker;
148
148
  if (isFunction(markerCfg)) {
149
- markerCfg = markerCfg(item.name, index, deepMix({}, themeMarker, item))
149
+ markerCfg = markerCfg(item.name, index, deepMix({}, themeMarker, item));
150
150
  }
151
151
 
152
- const itemMarker = isFunction(item.marker) ? item.marker(item.name, index, deepMix({}, themeMarker, item)) : item.marker;
152
+ const itemMarker = isFunction(item.marker)
153
+ ? item.marker(item.name, index, deepMix({}, themeMarker, item))
154
+ : item.marker;
153
155
 
154
156
  const marker = deepMix({}, themeMarker, markerCfg, itemMarker);
155
157
  setMarkerSymbol(marker);
package/src/util/scale.ts CHANGED
@@ -3,7 +3,8 @@ import { getScale, Scale, Coordinate } from '../dependents';
3
3
  import { LooseObject, ScaleOption, ViewCfg } from '../interface';
4
4
  import { isFullCircle } from './coordinate';
5
5
 
6
- const dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]+)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
6
+ const dateRegex =
7
+ /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]+)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
7
8
 
8
9
  /**
9
10
  * 获取字段对应数据的类型
@@ -86,9 +87,13 @@ export function getName(scale: Scale): string {
86
87
  * 根据 scale values 和 coordinate 获取分类默认 range
87
88
  * @param scale 需要获取的 scale 实例
88
89
  * @param coordinate coordinate 实例
89
- * @param theme theme
90
+ * @param theme theme
90
91
  */
91
- export function getDefaultCategoryScaleRange(scale: Scale, coordinate: Coordinate, theme: ViewCfg['theme']): Scale['range'] {
92
+ export function getDefaultCategoryScaleRange(
93
+ scale: Scale,
94
+ coordinate: Coordinate,
95
+ theme: ViewCfg['theme']
96
+ ): Scale['range'] {
92
97
  const { values } = scale;
93
98
  const count = values.length;
94
99
  let range;
@@ -121,7 +126,7 @@ export function getDefaultCategoryScaleRange(scale: Scale, coordinate: Coordinat
121
126
  */
122
127
  export function getMaxScale(scale: Scale) {
123
128
  // 过滤values[]中 NaN/undefined/null 等
124
- const values = scale.values.filter(item => !isNil(item) && !isNaN(item))
129
+ const values = scale.values.filter((item) => !isNil(item) && !isNaN(item));
125
130
 
126
131
  return Math.max(...values, isNil(scale.max) ? -Infinity : scale.max);
127
132
  }
package/src/util/stat.ts CHANGED
@@ -16,7 +16,7 @@ export function getMedian(array: number[]) {
16
16
  // median
17
17
  // 0
18
18
  if (len === 0) {
19
- return 0
19
+ return 0;
20
20
  }
21
21
 
22
22
  // 奇数
@@ -33,9 +33,13 @@ export function getMedian(array: number[]) {
33
33
  * @param array
34
34
  */
35
35
  export function getMean(array: number[]) {
36
- const sum = reduce(array, (r: number, num: number) => {
37
- return r += (isNaN(num) || !isNumber(num) ? 0 : num);
38
- }, 0);
36
+ const sum = reduce(
37
+ array,
38
+ (r: number, num: number) => {
39
+ return (r += isNaN(num) || !isNumber(num) ? 0 : num);
40
+ },
41
+ 0
42
+ );
39
43
 
40
44
  return array.length === 0 ? 0 : sum / array.length;
41
- }
45
+ }