@antv/g2 5.0.16 → 5.0.17

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 (109) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/g2-lite.min.js +3 -3
  3. package/dist/g2.min.js +3 -3
  4. package/esm/api/chart.js +5 -1
  5. package/esm/api/chart.js.map +1 -1
  6. package/esm/api/mark/types.d.ts +2 -2
  7. package/esm/component/legendCategory.js +23 -21
  8. package/esm/component/legendCategory.js.map +1 -1
  9. package/esm/component/legendContinuous.js +1 -1
  10. package/esm/component/legendContinuous.js.map +1 -1
  11. package/esm/component/title.js +2 -4
  12. package/esm/component/title.js.map +1 -1
  13. package/esm/mark/point.js +1 -1
  14. package/esm/mark/point.js.map +1 -1
  15. package/esm/runtime/component.d.ts +3 -2
  16. package/esm/runtime/component.js +62 -22
  17. package/esm/runtime/component.js.map +1 -1
  18. package/esm/runtime/layout.js +3 -3
  19. package/esm/runtime/layout.js.map +1 -1
  20. package/esm/runtime/mark.js +3 -2
  21. package/esm/runtime/mark.js.map +1 -1
  22. package/esm/runtime/plot.js +5 -5
  23. package/esm/runtime/plot.js.map +1 -1
  24. package/esm/runtime/scale.d.ts +3 -3
  25. package/esm/runtime/scale.js +21 -13
  26. package/esm/runtime/scale.js.map +1 -1
  27. package/esm/runtime/types/common.d.ts +12 -14
  28. package/esm/runtime/types/theme.d.ts +9 -13
  29. package/esm/shape/label/position/default.js +7 -2
  30. package/esm/shape/label/position/default.js.map +1 -1
  31. package/esm/shape/text/advance.js +5 -2
  32. package/esm/shape/text/advance.js.map +1 -1
  33. package/esm/spec/component.d.ts +11 -12
  34. package/esm/spec/composition.d.ts +1 -1
  35. package/esm/spec/index.d.ts +2 -1
  36. package/esm/spec/index.js.map +1 -1
  37. package/esm/spec/interaction.d.ts +1 -2
  38. package/esm/spec/mark.d.ts +1 -1
  39. package/esm/theme/academy.js +11 -32
  40. package/esm/theme/academy.js.map +1 -1
  41. package/esm/theme/classic.js +12 -33
  42. package/esm/theme/classic.js.map +1 -1
  43. package/esm/theme/classicDark.js +11 -32
  44. package/esm/theme/classicDark.js.map +1 -1
  45. package/lib/api/chart.js +5 -1
  46. package/lib/api/chart.js.map +1 -1
  47. package/lib/api/mark/types.d.ts +2 -2
  48. package/lib/component/legendCategory.js +23 -21
  49. package/lib/component/legendCategory.js.map +1 -1
  50. package/lib/component/legendContinuous.js +1 -1
  51. package/lib/component/legendContinuous.js.map +1 -1
  52. package/lib/component/title.js +2 -4
  53. package/lib/component/title.js.map +1 -1
  54. package/lib/mark/point.js +1 -1
  55. package/lib/mark/point.js.map +1 -1
  56. package/lib/runtime/component.d.ts +3 -2
  57. package/lib/runtime/component.js +64 -23
  58. package/lib/runtime/component.js.map +1 -1
  59. package/lib/runtime/layout.js +3 -3
  60. package/lib/runtime/layout.js.map +1 -1
  61. package/lib/runtime/mark.js +3 -2
  62. package/lib/runtime/mark.js.map +1 -1
  63. package/lib/runtime/plot.js +4 -4
  64. package/lib/runtime/plot.js.map +1 -1
  65. package/lib/runtime/scale.d.ts +3 -3
  66. package/lib/runtime/scale.js +21 -13
  67. package/lib/runtime/scale.js.map +1 -1
  68. package/lib/runtime/types/common.d.ts +12 -14
  69. package/lib/runtime/types/theme.d.ts +9 -13
  70. package/lib/shape/label/position/default.js +7 -2
  71. package/lib/shape/label/position/default.js.map +1 -1
  72. package/lib/shape/text/advance.js +5 -2
  73. package/lib/shape/text/advance.js.map +1 -1
  74. package/lib/spec/component.d.ts +11 -12
  75. package/lib/spec/composition.d.ts +1 -1
  76. package/lib/spec/index.d.ts +2 -1
  77. package/lib/spec/index.js.map +1 -1
  78. package/lib/spec/interaction.d.ts +1 -2
  79. package/lib/spec/mark.d.ts +1 -1
  80. package/lib/theme/academy.js +11 -32
  81. package/lib/theme/academy.js.map +1 -1
  82. package/lib/theme/classic.js +12 -33
  83. package/lib/theme/classic.js.map +1 -1
  84. package/lib/theme/classicDark.js +11 -32
  85. package/lib/theme/classicDark.js.map +1 -1
  86. package/package.json +9 -6
  87. package/src/api/chart.ts +10 -1
  88. package/src/api/mark/types.ts +5 -2
  89. package/src/component/legendCategory.ts +26 -32
  90. package/src/component/legendContinuous.ts +1 -1
  91. package/src/component/title.ts +11 -15
  92. package/src/mark/point.ts +1 -1
  93. package/src/runtime/component.ts +76 -29
  94. package/src/runtime/layout.ts +3 -3
  95. package/src/runtime/mark.ts +10 -1
  96. package/src/runtime/plot.ts +10 -8
  97. package/src/runtime/scale.ts +30 -15
  98. package/src/runtime/types/common.ts +16 -18
  99. package/src/runtime/types/theme.ts +13 -17
  100. package/src/shape/label/position/default.ts +8 -2
  101. package/src/shape/text/advance.ts +7 -2
  102. package/src/spec/component.ts +11 -12
  103. package/src/spec/composition.ts +1 -1
  104. package/src/spec/index.ts +2 -1
  105. package/src/spec/interaction.ts +1 -2
  106. package/src/spec/mark.ts +1 -1
  107. package/src/theme/academy.ts +12 -32
  108. package/src/theme/classic.ts +13 -33
  109. package/src/theme/classicDark.ts +12 -32
package/src/spec/index.ts CHANGED
@@ -1,7 +1,8 @@
1
+ import { AxisComponent, LegendComponent } from './component';
1
2
  import { Composition } from './composition';
2
3
  import { Mark } from './mark';
3
4
 
4
- export type G2Spec = (Mark | Composition) & {
5
+ export type G2Spec = (Mark | Composition | AxisComponent | LegendComponent) & {
5
6
  width?: number;
6
7
  height?: number;
7
8
  };
@@ -184,8 +184,7 @@ export type TooltipInteraction = {
184
184
  event, // @todo
185
185
  options: { title: 'string'; items: TooltipItemValue[] },
186
186
  ) => HTMLElement | string;
187
- style?: Record<`crosshairs${any}`, any>;
188
- };
187
+ } & Record<`crosshairs${any}`, any>;
189
188
 
190
189
  export type FisheyeInteraction = {
191
190
  type?: 'fisheye';
package/src/spec/mark.ts CHANGED
@@ -280,7 +280,7 @@ export type SankeyMark = BaseMark<
280
280
  linkLabels: Record<string, any>[];
281
281
  };
282
282
 
283
- export type PathMark = BaseMark<'path', ChannelTypes>;
283
+ export type PathMark = BaseMark<'path', ChannelTypes | 'd'>;
284
284
 
285
285
  export type TreemapMark = BaseMark<'treemap', 'value' | ChannelTypes> & {
286
286
  layout?: Record<string, any>;
@@ -10,14 +10,14 @@ const COLORS = {
10
10
 
11
11
  const BACKGROUND_COLOR = 'transparent';
12
12
 
13
+ const DEFAULT_COLOR = '#4e79a7';
14
+
13
15
  export const Academy: TC<AcademyOptions> = (options) => {
14
- const DEFAULT_COLOR = '#4e79a7';
15
16
  const defaultOptions: Theme = {
16
- defaultColor: DEFAULT_COLOR,
17
- defaultCategory10: 'tableau10',
18
- defaultCategory20: 'tableau10',
19
- defaultSize: 1,
20
- elementActiveStroke: COLORS.BLACK,
17
+ color: DEFAULT_COLOR,
18
+ size: 1,
19
+ category10: 'tableau10',
20
+ category20: 'tableau10',
21
21
  enter: {
22
22
  duration: 300,
23
23
  fill: 'both',
@@ -33,12 +33,12 @@ export const Academy: TC<AcademyOptions> = (options) => {
33
33
  fill: 'both',
34
34
  delay: 0,
35
35
  },
36
- // --- Theme of area style
37
- viewFill: BACKGROUND_COLOR,
38
- plotFill: 'transparent',
39
- mainFill: 'transparent',
40
- contentFill: 'transparent',
41
- // --- Theme of mark shape
36
+ view: {
37
+ viewFill: BACKGROUND_COLOR,
38
+ plotFill: 'transparent',
39
+ mainFill: 'transparent',
40
+ contentFill: 'transparent',
41
+ },
42
42
  line: {
43
43
  line: {
44
44
  fill: '',
@@ -198,26 +198,6 @@ export const Academy: TC<AcademyOptions> = (options) => {
198
198
  endMarkerFillOpacity: 0.95,
199
199
  },
200
200
  },
201
- interaction: {
202
- active: {
203
- line: {
204
- line: { lineWidth: 3 },
205
- },
206
- interval: {
207
- rect: { stroke: COLORS.BLACK },
208
- },
209
- area: {
210
- area: { fillOpacity: 0.5 },
211
- },
212
- },
213
- inactive: {
214
- area: {
215
- area: { fillOpacity: 0.3 },
216
- },
217
- },
218
- selected: {},
219
- disabled: {},
220
- },
221
201
  axis: {
222
202
  arrow: false,
223
203
  gridLineDash: [0, 0],
@@ -10,17 +10,17 @@ const COLORS = {
10
10
 
11
11
  const BACKGROUND_COLOR = 'transparent';
12
12
 
13
+ const DEFAULT_COLOR = '#5B8FF9';
14
+
13
15
  /**
14
16
  * Default theme.
15
17
  */
16
18
  export const Classic: TC<ClassicOptions> = (options) => {
17
- const DEFAULT_COLOR = '#5B8FF9';
18
19
  const defaultOptions: Theme = {
19
- defaultColor: DEFAULT_COLOR,
20
- defaultCategory10: 'category10',
21
- defaultCategory20: 'category20',
22
- defaultSize: 1,
23
- elementActiveStroke: COLORS.BLACK,
20
+ color: DEFAULT_COLOR,
21
+ size: 1,
22
+ category10: 'category10',
23
+ category20: 'category20',
24
24
  enter: {
25
25
  duration: 300,
26
26
  fill: 'both',
@@ -36,12 +36,12 @@ export const Classic: TC<ClassicOptions> = (options) => {
36
36
  fill: 'both',
37
37
  delay: 0,
38
38
  },
39
- // --- Theme of area style
40
- viewFill: BACKGROUND_COLOR,
41
- plotFill: 'transparent',
42
- mainFill: 'transparent',
43
- contentFill: 'transparent',
44
- // --- Theme of mark shape
39
+ view: {
40
+ viewFill: BACKGROUND_COLOR,
41
+ plotFill: 'transparent',
42
+ mainFill: 'transparent',
43
+ contentFill: 'transparent',
44
+ },
45
45
  line: {
46
46
  line: {
47
47
  fill: '',
@@ -132,7 +132,6 @@ export const Classic: TC<ClassicOptions> = (options) => {
132
132
  },
133
133
  text: {
134
134
  text: {
135
- // fill: COLORS.BLACK,fillOpacity: 0.65,
136
135
  fill: '#1D2129',
137
136
  fontSize: 12,
138
137
  strokeWidth: 0,
@@ -199,26 +198,6 @@ export const Classic: TC<ClassicOptions> = (options) => {
199
198
  endMarkerFillOpacity: 0.95,
200
199
  },
201
200
  },
202
- interaction: {
203
- active: {
204
- line: {
205
- line: { lineWidth: 3 },
206
- },
207
- interval: {
208
- rect: { stroke: COLORS.BLACK },
209
- },
210
- area: {
211
- area: { fillOpacity: 0.5 },
212
- },
213
- },
214
- inactive: {
215
- area: {
216
- area: { fillOpacity: 0.3 },
217
- },
218
- },
219
- selected: {},
220
- disabled: {},
221
- },
222
201
  axis: {
223
202
  arrow: false,
224
203
  gridLineDash: [0, 0],
@@ -429,6 +408,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
429
408
  thumbHighlightedFillOpacity: 0.2,
430
409
  },
431
410
  title: {
411
+ spacing: 8,
432
412
  titleFill: COLORS.BLACK,
433
413
  titleFillOpacity: 0.85,
434
414
  titleFontSize: 14,
@@ -10,17 +10,17 @@ const COLORS = {
10
10
 
11
11
  const BACKGROUND_COLOR = '#141414';
12
12
 
13
+ const DEFAULT_COLOR = '#5B8FF9';
14
+
13
15
  /**
14
16
  * Dark theme.
15
17
  */
16
18
  export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
17
- const DEFAULT_COLOR = '#5B8FF9';
18
19
  const defaultOptions: Theme = {
19
- defaultColor: DEFAULT_COLOR,
20
- defaultCategory10: 'category10',
21
- defaultCategory20: 'category20',
22
- defaultSize: 1,
23
- elementActiveStroke: COLORS.BLACK,
20
+ color: DEFAULT_COLOR,
21
+ category10: 'category10',
22
+ category20: 'category20',
23
+ size: 1,
24
24
  enter: {
25
25
  duration: 300,
26
26
  fill: 'both',
@@ -36,12 +36,12 @@ export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
36
36
  fill: 'both',
37
37
  delay: 0,
38
38
  },
39
- // --- Theme of area style
40
- viewFill: BACKGROUND_COLOR,
41
- plotFill: 'transparent',
42
- mainFill: 'transparent',
43
- contentFill: 'transparent',
44
- // --- Theme of mark shape
39
+ view: {
40
+ viewFill: BACKGROUND_COLOR,
41
+ plotFill: 'transparent',
42
+ mainFill: 'transparent',
43
+ contentFill: 'transparent',
44
+ },
45
45
  line: {
46
46
  line: {
47
47
  fill: '',
@@ -199,26 +199,6 @@ export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
199
199
  endMarkerFillOpacity: 0.95,
200
200
  },
201
201
  },
202
- interaction: {
203
- active: {
204
- line: {
205
- line: { lineWidth: 3 },
206
- },
207
- interval: {
208
- rect: { stroke: COLORS.BLACK },
209
- },
210
- area: {
211
- area: { fillOpacity: 0.5 },
212
- },
213
- },
214
- inactive: {
215
- area: {
216
- area: { fillOpacity: 0.3 },
217
- },
218
- },
219
- selected: {},
220
- disabled: {},
221
- },
222
202
  axis: {
223
203
  arrow: false,
224
204
  gridLineDash: [0, 0],