@antv/g2 5.0.21 → 5.0.23

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 (153) hide show
  1. package/CHANGELOG.md +308 -0
  2. package/dist/g2-lite.min.js +3 -3
  3. package/dist/g2.min.js +3 -3
  4. package/esm/api/chart.d.ts +4 -1
  5. package/esm/api/chart.js.map +1 -1
  6. package/esm/api/index.d.ts +1 -1
  7. package/esm/api/index.js.map +1 -1
  8. package/esm/api/library.d.ts +1 -0
  9. package/esm/component/axis.js +15 -10
  10. package/esm/component/axis.js.map +1 -1
  11. package/esm/component/legendCategory.js +2 -2
  12. package/esm/component/legendCategory.js.map +1 -1
  13. package/esm/component/legendContinuous.js +4 -5
  14. package/esm/component/legendContinuous.js.map +1 -1
  15. package/esm/component/scrollbar.js +2 -0
  16. package/esm/component/scrollbar.js.map +1 -1
  17. package/esm/component/slider.js +2 -0
  18. package/esm/component/slider.js.map +1 -1
  19. package/esm/component/title.js +4 -2
  20. package/esm/component/title.js.map +1 -1
  21. package/esm/component/utils.d.ts +1 -1
  22. package/esm/component/utils.js +2 -3
  23. package/esm/component/utils.js.map +1 -1
  24. package/esm/composition/facetRect.js +2 -2
  25. package/esm/composition/facetRect.js.map +1 -1
  26. package/esm/composition/repeatMatrix.js +3 -3
  27. package/esm/composition/repeatMatrix.js.map +1 -1
  28. package/esm/index.d.ts +2 -2
  29. package/esm/index.js +1 -1
  30. package/esm/index.js.map +1 -1
  31. package/esm/interaction/brushHighlight.js.map +1 -1
  32. package/esm/interaction/tooltip.js +4 -3
  33. package/esm/interaction/tooltip.js.map +1 -1
  34. package/esm/lib/core.d.ts +1 -0
  35. package/esm/lib/core.js +4 -3
  36. package/esm/lib/core.js.map +1 -1
  37. package/esm/lib/std.d.ts +1 -0
  38. package/esm/runtime/component.js +33 -30
  39. package/esm/runtime/component.js.map +1 -1
  40. package/esm/runtime/layout.js +78 -28
  41. package/esm/runtime/layout.js.map +1 -1
  42. package/esm/runtime/plot.js +42 -42
  43. package/esm/runtime/plot.js.map +1 -1
  44. package/esm/runtime/render.js +0 -3
  45. package/esm/runtime/render.js.map +1 -1
  46. package/esm/runtime/scale.js +2 -0
  47. package/esm/runtime/scale.js.map +1 -1
  48. package/esm/runtime/types/common.d.ts +3 -1
  49. package/esm/runtime/types/theme.d.ts +8 -2
  50. package/esm/shape/connector/connector.js +19 -30
  51. package/esm/shape/connector/connector.js.map +1 -1
  52. package/esm/theme/classic.js +52 -37
  53. package/esm/theme/classic.js.map +1 -1
  54. package/esm/theme/index.d.ts +1 -0
  55. package/esm/theme/index.js +1 -0
  56. package/esm/theme/index.js.map +1 -1
  57. package/esm/theme/light.d.ts +6 -0
  58. package/esm/theme/light.js +476 -0
  59. package/esm/theme/light.js.map +1 -0
  60. package/esm/utils/selection.d.ts +1 -1
  61. package/esm/utils/selection.js +10 -10
  62. package/esm/utils/selection.js.map +1 -1
  63. package/esm/utils/size.js +1 -1
  64. package/lib/api/chart.d.ts +4 -1
  65. package/lib/api/chart.js.map +1 -1
  66. package/lib/api/index.d.ts +1 -1
  67. package/lib/api/index.js.map +1 -1
  68. package/lib/api/library.d.ts +1 -0
  69. package/lib/component/axis.js +14 -9
  70. package/lib/component/axis.js.map +1 -1
  71. package/lib/component/legendCategory.js +2 -2
  72. package/lib/component/legendCategory.js.map +1 -1
  73. package/lib/component/legendContinuous.js +4 -5
  74. package/lib/component/legendContinuous.js.map +1 -1
  75. package/lib/component/scrollbar.js +2 -0
  76. package/lib/component/scrollbar.js.map +1 -1
  77. package/lib/component/slider.js +2 -0
  78. package/lib/component/slider.js.map +1 -1
  79. package/lib/component/title.js +4 -2
  80. package/lib/component/title.js.map +1 -1
  81. package/lib/component/utils.d.ts +1 -1
  82. package/lib/component/utils.js +2 -3
  83. package/lib/component/utils.js.map +1 -1
  84. package/lib/composition/facetRect.js +2 -2
  85. package/lib/composition/facetRect.js.map +1 -1
  86. package/lib/composition/repeatMatrix.js +3 -3
  87. package/lib/composition/repeatMatrix.js.map +1 -1
  88. package/lib/index.d.ts +2 -2
  89. package/lib/index.js +4 -1
  90. package/lib/index.js.map +1 -1
  91. package/lib/interaction/brushHighlight.js.map +1 -1
  92. package/lib/interaction/tooltip.js +4 -3
  93. package/lib/interaction/tooltip.js.map +1 -1
  94. package/lib/lib/core.d.ts +1 -0
  95. package/lib/lib/core.js +1 -0
  96. package/lib/lib/core.js.map +1 -1
  97. package/lib/lib/std.d.ts +1 -0
  98. package/lib/runtime/component.js +33 -30
  99. package/lib/runtime/component.js.map +1 -1
  100. package/lib/runtime/layout.js +76 -26
  101. package/lib/runtime/layout.js.map +1 -1
  102. package/lib/runtime/plot.js +42 -42
  103. package/lib/runtime/plot.js.map +1 -1
  104. package/lib/runtime/render.js +0 -3
  105. package/lib/runtime/render.js.map +1 -1
  106. package/lib/runtime/scale.js +2 -0
  107. package/lib/runtime/scale.js.map +1 -1
  108. package/lib/runtime/types/common.d.ts +3 -1
  109. package/lib/runtime/types/theme.d.ts +8 -2
  110. package/lib/shape/connector/connector.js +19 -30
  111. package/lib/shape/connector/connector.js.map +1 -1
  112. package/lib/theme/classic.js +52 -37
  113. package/lib/theme/classic.js.map +1 -1
  114. package/lib/theme/index.d.ts +1 -0
  115. package/lib/theme/index.js +3 -1
  116. package/lib/theme/index.js.map +1 -1
  117. package/lib/theme/light.d.ts +6 -0
  118. package/lib/theme/light.js +480 -0
  119. package/lib/theme/light.js.map +1 -0
  120. package/lib/utils/selection.d.ts +1 -1
  121. package/lib/utils/selection.js +10 -10
  122. package/lib/utils/selection.js.map +1 -1
  123. package/lib/utils/size.js +1 -1
  124. package/package.json +4 -3
  125. package/src/api/chart.ts +3 -0
  126. package/src/api/index.ts +1 -1
  127. package/src/component/axis.ts +17 -13
  128. package/src/component/legendCategory.ts +3 -5
  129. package/src/component/legendContinuous.ts +4 -5
  130. package/src/component/scrollbar.ts +4 -1
  131. package/src/component/slider.ts +4 -1
  132. package/src/component/title.ts +3 -3
  133. package/src/component/utils.ts +1 -3
  134. package/src/composition/facetRect.ts +4 -3
  135. package/src/composition/repeatMatrix.ts +4 -3
  136. package/src/index.ts +10 -1
  137. package/src/interaction/brushHighlight.ts +1 -1
  138. package/src/interaction/tooltip.ts +5 -3
  139. package/src/lib/core.ts +4 -3
  140. package/src/runtime/component.ts +57 -30
  141. package/src/runtime/layout.ts +90 -31
  142. package/src/runtime/plot.ts +62 -40
  143. package/src/runtime/render.ts +0 -5
  144. package/src/runtime/scale.ts +1 -0
  145. package/src/runtime/types/common.ts +2 -0
  146. package/src/runtime/types/theme.ts +8 -2
  147. package/src/shape/connector/connector.ts +41 -47
  148. package/src/shape/utils.ts +2 -2
  149. package/src/theme/classic.ts +52 -37
  150. package/src/theme/index.ts +1 -0
  151. package/src/theme/light.ts +483 -0
  152. package/src/utils/selection.ts +11 -11
  153. package/src/utils/size.ts +1 -1
@@ -3,10 +3,10 @@ import { Linear } from '@antv/scale';
3
3
  import { lowerFirst } from '@antv/util';
4
4
  import { extent } from 'd3-array';
5
5
  import { Path as D3Path } from 'd3-path';
6
- import { G2Theme, Primitive, Vector2, Vector3 } from '../runtime';
6
+ import { Primitive, Vector2, Vector3 } from '../runtime';
7
7
  import { indexOf } from '../utils/array';
8
8
  import { isPolar, isTranspose } from '../utils/coordinate';
9
- import { Selection } from '../utils/selection';
9
+ import { G2Element, Selection } from '../utils/selection';
10
10
  import { angle, angleWithQuadrant, dist, sub } from '../utils/vector';
11
11
 
12
12
  export function applyStyle(
@@ -3,21 +3,35 @@ import { ThemeComponent as TC, Theme } from '../runtime';
3
3
  export type ClassicOptions = Theme;
4
4
 
5
5
  const COLORS = {
6
- BLACK: '#000',
6
+ BLACK: '#1D2129',
7
7
  WHITE: '#fff',
8
8
  STROKE: '#416180',
9
+ DEFAULT: '#5B8FF9',
10
+ BACKGROUND: 'transparent',
9
11
  };
10
12
 
11
- const BACKGROUND_COLOR = 'transparent';
13
+ const PADDING = {
14
+ 1: 8,
15
+ 2: 12,
16
+ 3: 20,
17
+ };
12
18
 
13
- const DEFAULT_COLOR = '#5B8FF9';
19
+ const ALPHA = {
20
+ 90: 0.9,
21
+ 65: 0.65,
22
+ 45: 0.45,
23
+ 25: 0.25,
24
+ 10: 0.1,
25
+ };
14
26
 
15
27
  /**
16
28
  * Default theme.
17
29
  */
18
30
  export const Classic: TC<ClassicOptions> = (options) => {
19
31
  const defaultOptions: Theme = {
20
- color: DEFAULT_COLOR,
32
+ padding: 'auto',
33
+ margin: 16,
34
+ color: COLORS.DEFAULT,
21
35
  size: 1,
22
36
  category10: 'category10',
23
37
  category20: 'category20',
@@ -37,7 +51,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
37
51
  delay: 0,
38
52
  },
39
53
  view: {
40
- viewFill: BACKGROUND_COLOR,
54
+ viewFill: COLORS.BACKGROUND,
41
55
  plotFill: 'transparent',
42
56
  mainFill: 'transparent',
43
57
  contentFill: 'transparent',
@@ -200,26 +214,26 @@ export const Classic: TC<ClassicOptions> = (options) => {
200
214
  },
201
215
  axis: {
202
216
  arrow: false,
203
- gridLineDash: [0, 0],
217
+ gridLineDash: [3, 4],
204
218
  gridLineWidth: 0.5,
205
219
  gridStroke: COLORS.BLACK,
206
- gridStrokeOpacity: 0.05,
220
+ gridStrokeOpacity: ALPHA[10],
207
221
  labelAlign: 'horizontal',
208
222
  labelFill: COLORS.BLACK,
209
- labelFillOpacity: 0.65,
223
+ labelOpacity: ALPHA[45],
210
224
  labelFontSize: 12,
211
- labelFontWeight: 'lighter',
212
- labelSpacing: 8, // spacing between label and it's tick
225
+ labelFontWeight: 'normal',
226
+ labelSpacing: PADDING[1], // spacing between label and it's tick
213
227
  line: false,
214
228
  lineLineWidth: 0.5,
215
229
  lineStroke: COLORS.BLACK,
216
- lineStrokeOpacity: 0.45,
230
+ lineStrokeOpacity: ALPHA[45],
217
231
  tickLength: 4,
218
232
  tickLineWidth: 1,
219
233
  tickStroke: COLORS.BLACK,
220
- tickStrokeOpacity: 0.25,
234
+ tickOpacity: ALPHA[45],
221
235
  titleFill: COLORS.BLACK,
222
- titleFillOpacity: 0.65,
236
+ titleOpacity: ALPHA[90],
223
237
  titleFontSize: 12,
224
238
  titleFontWeight: 'normal',
225
239
  titleSpacing: 12,
@@ -228,20 +242,18 @@ export const Classic: TC<ClassicOptions> = (options) => {
228
242
  axisTop: {
229
243
  gridDirection: 'positive',
230
244
  labelDirection: 'negative',
231
- labelSpacing: 4,
232
245
  tickDirection: 'negative',
233
246
  titlePosition: 'top',
234
- titleSpacing: 0,
247
+ titleSpacing: 12,
235
248
  titleTextBaseline: 'middle',
236
249
  },
237
250
  axisBottom: {
238
251
  gridDirection: 'negative',
239
252
  labelDirection: 'positive',
240
- labelSpacing: 4,
241
253
  labelAutoRotate: true,
242
254
  tickDirection: 'positive',
243
255
  titlePosition: 'bottom',
244
- titleSpacing: 10,
256
+ titleSpacing: 12,
245
257
  titleTextBaseline: 'bottom',
246
258
  },
247
259
  axisLeft: {
@@ -251,7 +263,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
251
263
  labelSpacing: 4,
252
264
  tickDirection: 'negative',
253
265
  titlePosition: 'left',
254
- titleSpacing: 10,
266
+ titleSpacing: 12,
255
267
  titleTextBaseline: 'middle',
256
268
  titleDirection: 'vertical',
257
269
  titleTransformOrigin: 'center',
@@ -262,7 +274,8 @@ export const Classic: TC<ClassicOptions> = (options) => {
262
274
  labelSpacing: 4,
263
275
  tickDirection: 'positive',
264
276
  titlePosition: 'right',
265
- titleSpacing: 0,
277
+ labelAutoRotate: false,
278
+ titleSpacing: 12,
266
279
  titleTextBaseline: 'top',
267
280
  titleDirection: 'vertical',
268
281
  titleTransformOrigin: 'center',
@@ -294,23 +307,23 @@ export const Classic: TC<ClassicOptions> = (options) => {
294
307
  backgroundFill: 'transparent',
295
308
  itemBackgroundFill: 'transparent',
296
309
  itemLabelFill: COLORS.BLACK,
297
- itemLabelFillOpacity: 0.65,
310
+ itemLabelFillOpacity: ALPHA[90],
298
311
  itemLabelFontSize: 12,
299
- itemLabelFontWeight: 'lighter',
312
+ itemLabelFontWeight: 'normal',
300
313
  itemMarkerFillOpacity: 1,
301
314
  itemMarkerSize: 8,
302
- itemSpacing: [5, 8],
315
+ itemSpacing: [PADDING[1], PADDING[1]],
303
316
  itemValueFill: COLORS.BLACK,
304
317
  itemValueFillOpacity: 0.65,
305
318
  itemValueFontSize: 12,
306
- itemValueFontWeight: 'lighter',
319
+ itemValueFontWeight: 'normal',
307
320
  navButtonFill: COLORS.BLACK,
308
321
  navButtonFillOpacity: 0.65,
309
322
  navPageNumFill: COLORS.BLACK,
310
323
  navPageNumFillOpacity: 0.45,
311
324
  navPageNumFontSize: 12,
312
325
  padding: 8,
313
- title: true,
326
+ title: false,
314
327
  titleFill: COLORS.BLACK,
315
328
  titleFillOpacity: 0.65,
316
329
  titleFontSize: 12,
@@ -318,13 +331,15 @@ export const Classic: TC<ClassicOptions> = (options) => {
318
331
  titleSpacing: 4,
319
332
  tickStroke: COLORS.BLACK,
320
333
  tickStrokeOpacity: 0.25,
321
- rowPadding: 0,
322
- colPadding: 8,
334
+ rowPadding: PADDING[1],
335
+ colPadding: PADDING[2],
336
+ maxRows: 3,
337
+ maxCols: 3,
323
338
  },
324
339
  legendContinuous: {
325
340
  handleHeight: 12,
326
341
  handleLabelFill: COLORS.BLACK,
327
- handleLabelFillOpacity: 0.45,
342
+ handleLabelFillOpacity: ALPHA[45],
328
343
  handleLabelFontSize: 12,
329
344
  handleLabelFontWeight: 'normal',
330
345
  handleMarkerFill: COLORS.BLACK,
@@ -334,9 +349,9 @@ export const Classic: TC<ClassicOptions> = (options) => {
334
349
  handleMarkerStrokeOpacity: 0.25,
335
350
  handleWidth: 10,
336
351
  labelFill: COLORS.BLACK,
337
- labelFillOpacity: 0.45,
352
+ labelFillOpacity: ALPHA[45],
338
353
  labelFontSize: 12,
339
- labelFontWeight: 'lighter',
354
+ labelFontWeight: 'normal',
340
355
  labelSpacing: 3,
341
356
  tick: true,
342
357
  tickLength: 12,
@@ -350,9 +365,9 @@ export const Classic: TC<ClassicOptions> = (options) => {
350
365
  titleFontSize: 12,
351
366
  titleSpacing: 4,
352
367
  titleFontWeight: 'normal',
353
- titleFillOpacity: 0.65,
368
+ titleFillOpacity: ALPHA[90],
354
369
  tickStroke: COLORS.BLACK,
355
- tickStrokeOpacity: 0.25,
370
+ tickStrokeOpacity: ALPHA[45],
356
371
  },
357
372
  label: {
358
373
  fill: COLORS.BLACK,
@@ -386,7 +401,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
386
401
  trackSize: 16,
387
402
  trackFill: COLORS.STROKE,
388
403
  trackFillOpacity: 1,
389
- selectionFill: DEFAULT_COLOR,
404
+ selectionFill: COLORS.DEFAULT,
390
405
  selectionFillOpacity: 0.15,
391
406
  handleIconSize: 10,
392
407
  handleIconFill: '#f7f7f7',
@@ -401,8 +416,8 @@ export const Classic: TC<ClassicOptions> = (options) => {
401
416
  handleLabelFontWeight: 'normal',
402
417
  },
403
418
  scrollbar: {
404
- padding: [2, 2, 2, 2],
405
- trackSize: 10,
419
+ padding: [0, 0, 0, 0],
420
+ trackSize: 6,
406
421
  isRound: true,
407
422
  slidable: true,
408
423
  scrollable: true,
@@ -415,12 +430,12 @@ export const Classic: TC<ClassicOptions> = (options) => {
415
430
  title: {
416
431
  spacing: 8,
417
432
  titleFill: COLORS.BLACK,
418
- titleFillOpacity: 0.85,
419
- titleFontSize: 14,
433
+ titleFillOpacity: ALPHA[90],
434
+ titleFontSize: 16,
420
435
  titleFontWeight: 'bold',
421
436
  titleTextBaseline: 'top',
422
437
  subtitleFill: COLORS.BLACK,
423
- subtitleFillOpacity: 0.65,
438
+ subtitleFillOpacity: ALPHA[65],
424
439
  subtitleFontSize: 12,
425
440
  subtitleFontWeight: 'normal',
426
441
  subtitleTextBaseline: 'top',
@@ -1,3 +1,4 @@
1
1
  export { Classic } from './classic';
2
2
  export { ClassicDark } from './classicDark';
3
3
  export { Academy } from './academy';
4
+ export { Light } from './light';