@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
@@ -0,0 +1,483 @@
1
+ import { ThemeComponent as TC, Theme } from '../runtime';
2
+
3
+ export type LightOptions = Theme;
4
+
5
+ const COLORS = {
6
+ BLACK: '#1D2129',
7
+ WHITE: '#fff',
8
+ STROKE: '#416180',
9
+ DEFAULT: '#5B8FF9',
10
+ BACKGROUND: 'transparent',
11
+ };
12
+
13
+ const PADDING = {
14
+ 1: 8,
15
+ 2: 12,
16
+ 3: 20,
17
+ };
18
+
19
+ const ALPHA = {
20
+ 90: 0.9,
21
+ 65: 0.65,
22
+ 45: 0.45,
23
+ 25: 0.25,
24
+ 10: 0.1,
25
+ };
26
+
27
+ /**
28
+ * Default theme.
29
+ */
30
+ export const Light: TC<LightOptions> = (options) => {
31
+ const defaultOptions: Theme = {
32
+ padding: 'auto',
33
+ margin: 16,
34
+ color: COLORS.DEFAULT,
35
+ size: 1,
36
+ category10: [
37
+ '#1783FF',
38
+ '#00C9C9',
39
+ '#F0884D',
40
+ '#D580FF',
41
+ '#7863FF',
42
+ '#60C42D',
43
+ '#BD8F24',
44
+ '#FF80CA',
45
+ '#2491B3',
46
+ '#17C76F',
47
+ ],
48
+ category20: [
49
+ '#1783FF',
50
+ '#00C9C9',
51
+ '#F0884D',
52
+ '#D580FF',
53
+ '#7863FF',
54
+ '#60C42D',
55
+ '#BD8F24',
56
+ '#FF80CA',
57
+ '#2491B3',
58
+ '#17C76F',
59
+ '#8093FF',
60
+ '#66C1DF',
61
+ '#EFBF77',
62
+ '#FFAFFA',
63
+ '#D5A5FA',
64
+ '#78DF78',
65
+ '#ECD74D',
66
+ '#FFAFC8',
67
+ '#73A2D1',
68
+ '#74DDCB',
69
+ ],
70
+ enter: {
71
+ duration: 300,
72
+ fill: 'both',
73
+ delay: 0,
74
+ },
75
+ update: {
76
+ duration: 300,
77
+ fill: 'both',
78
+ delay: 0,
79
+ },
80
+ exit: {
81
+ duration: 300,
82
+ fill: 'both',
83
+ delay: 0,
84
+ },
85
+ view: {
86
+ viewFill: COLORS.BACKGROUND,
87
+ plotFill: 'transparent',
88
+ mainFill: 'transparent',
89
+ contentFill: 'transparent',
90
+ },
91
+ line: {
92
+ line: {
93
+ fill: '',
94
+ strokeOpacity: 1,
95
+ lineWidth: 1,
96
+ },
97
+ },
98
+ point: {
99
+ point: {
100
+ r: 3,
101
+ fillOpacity: 0.95,
102
+ lineWidth: 0,
103
+ },
104
+ hollow: {
105
+ r: 3,
106
+ strokeOpacity: 0.95,
107
+ lineWidth: 1,
108
+ },
109
+ plus: {
110
+ r: 3,
111
+ strokeOpacity: 0.95,
112
+ lineWidth: 3,
113
+ },
114
+ diamond: {
115
+ r: 3,
116
+ strokeOpacity: 0.95,
117
+ lineWidth: 1,
118
+ },
119
+ },
120
+ interval: {
121
+ rect: {
122
+ fillOpacity: 0.95,
123
+ },
124
+ hollow: {
125
+ fill: '',
126
+ strokeOpacity: 1,
127
+ lineWidth: 2,
128
+ },
129
+ },
130
+ area: {
131
+ area: {
132
+ fillOpacity: 0.85,
133
+ lineWidth: 0,
134
+ },
135
+ },
136
+ polygon: {
137
+ polygon: {
138
+ fillOpacity: 0.95,
139
+ },
140
+ },
141
+ cell: {
142
+ cell: {
143
+ fillOpacity: 0.95,
144
+ },
145
+ hollow: {
146
+ fill: '',
147
+ strokeOpacity: 1,
148
+ lineWidth: 2,
149
+ },
150
+ },
151
+ rect: {
152
+ rect: {
153
+ fillOpacity: 0.95,
154
+ },
155
+ hollow: {
156
+ fill: '',
157
+ strokeOpacity: 1,
158
+ lineWidth: 2,
159
+ },
160
+ },
161
+ link: {
162
+ link: {
163
+ fill: '',
164
+ strokeOpacity: 1,
165
+ },
166
+ },
167
+ vector: {
168
+ vector: {
169
+ fillOpacity: 1,
170
+ },
171
+ },
172
+ box: {
173
+ box: {
174
+ fillOpacity: 0.95,
175
+ stroke: COLORS.BLACK,
176
+ lineWidth: 1,
177
+ },
178
+ },
179
+ text: {
180
+ text: {
181
+ fill: '#1D2129',
182
+ fontSize: 12,
183
+ strokeWidth: 0,
184
+ connectorStroke: COLORS.STROKE,
185
+ connectorStrokeOpacity: 0.45,
186
+ connectorLineWidth: 1,
187
+ backgroundFill: COLORS.STROKE,
188
+ backgroundFillOpacity: 0.15,
189
+ backgroundPadding: [2, 4],
190
+ startMarkerSymbol: 'circle',
191
+ startMarkerSize: 4,
192
+ endMarkerSymbol: 'circle',
193
+ endMarkerSize: 4,
194
+ },
195
+ badge: {
196
+ fill: '#1D2129',
197
+ fillOpacity: 0.65,
198
+ strokeWidth: 0,
199
+ fontSize: 10,
200
+ textAlign: 'center',
201
+ textBaseline: 'middle',
202
+ markerFill: COLORS.STROKE,
203
+ markerFillOpacity: 0.25,
204
+ markerStrokeOpacity: 0,
205
+ },
206
+ },
207
+ lineX: {
208
+ line: {
209
+ stroke: COLORS.STROKE,
210
+ strokeOpacity: 0.45,
211
+ lineWidth: 1,
212
+ },
213
+ },
214
+ lineY: {
215
+ line: {
216
+ stroke: COLORS.STROKE,
217
+ strokeOpacity: 0.45,
218
+ lineWidth: 1,
219
+ },
220
+ },
221
+ rangeX: {
222
+ range: {
223
+ fill: COLORS.STROKE,
224
+ fillOpacity: 0.15,
225
+ lineWidth: 0,
226
+ },
227
+ },
228
+ rangeY: {
229
+ range: {
230
+ fill: COLORS.STROKE,
231
+ fillOpacity: 0.15,
232
+ lineWidth: 0,
233
+ },
234
+ },
235
+ connector: {
236
+ connector: {
237
+ stroke: COLORS.STROKE,
238
+ strokeOpacity: 0.45,
239
+ lineWidth: 1,
240
+ connectLength1: 12,
241
+ endMarker: true,
242
+ endMarkerSize: 6,
243
+ endMarkerFill: COLORS.STROKE,
244
+ endMarkerFillOpacity: 0.95,
245
+ },
246
+ },
247
+ axis: {
248
+ arrow: false,
249
+ gridLineDash: [3, 4],
250
+ gridLineWidth: 0.5,
251
+ gridStroke: COLORS.BLACK,
252
+ gridStrokeOpacity: ALPHA[10],
253
+ labelAlign: 'horizontal',
254
+ labelFill: COLORS.BLACK,
255
+ labelOpacity: ALPHA[45],
256
+ labelFontSize: 12,
257
+ labelFontWeight: 'normal',
258
+ labelSpacing: PADDING[1], // spacing between label and it's tick
259
+ line: false,
260
+ lineLineWidth: 0.5,
261
+ lineStroke: COLORS.BLACK,
262
+ lineStrokeOpacity: ALPHA[45],
263
+ tickLength: 4,
264
+ tickLineWidth: 1,
265
+ tickStroke: COLORS.BLACK,
266
+ tickOpacity: ALPHA[45],
267
+ titleFill: COLORS.BLACK,
268
+ titleOpacity: ALPHA[90],
269
+ titleFontSize: 12,
270
+ titleFontWeight: 'normal',
271
+ titleSpacing: 12,
272
+ titleTransformOrigin: 'center',
273
+ lineArrowOffset: 6,
274
+ lineArrowSize: 6,
275
+ },
276
+ axisTop: {
277
+ gridDirection: 'positive',
278
+ labelDirection: 'negative',
279
+ tickDirection: 'negative',
280
+ titlePosition: 'top',
281
+ titleSpacing: 12,
282
+ labelSpacing: 4,
283
+ titleTextBaseline: 'middle',
284
+ },
285
+ axisBottom: {
286
+ gridDirection: 'negative',
287
+ labelDirection: 'positive',
288
+ labelAutoRotate: true,
289
+ tickDirection: 'positive',
290
+ titlePosition: 'bottom',
291
+ titleSpacing: 12,
292
+ labelSpacing: 4,
293
+ titleTextBaseline: 'bottom',
294
+ },
295
+ axisLeft: {
296
+ gridDirection: 'positive',
297
+ labelAutoRotate: false,
298
+ labelDirection: 'negative',
299
+ labelSpacing: 4,
300
+ tickDirection: 'negative',
301
+ titlePosition: 'left',
302
+ titleSpacing: 12,
303
+ titleTextBaseline: 'middle',
304
+ titleDirection: 'vertical',
305
+ titleTransformOrigin: 'center',
306
+ },
307
+ axisRight: {
308
+ gridDirection: 'negative',
309
+ labelDirection: 'positive',
310
+ labelSpacing: 4,
311
+ tickDirection: 'positive',
312
+ titlePosition: 'right',
313
+ labelAutoRotate: false,
314
+ titleSpacing: 12,
315
+ titleTextBaseline: 'top',
316
+ titleDirection: 'vertical',
317
+ titleTransformOrigin: 'center',
318
+ },
319
+ axisLinear: {
320
+ girdClosed: true,
321
+ gridConnect: 'arc',
322
+ gridDirection: 'negative',
323
+ gridType: 'surround',
324
+ titlePosition: 'top',
325
+ titleSpacing: 0,
326
+ },
327
+ axisArc: {
328
+ title: false,
329
+ titlePosition: 'inner',
330
+ line: false,
331
+ tick: true,
332
+ labelSpacing: 4,
333
+ },
334
+ axisRadar: {
335
+ girdClosed: true,
336
+ gridStrokeOpacity: 0.3,
337
+ gridType: 'surround',
338
+ label: false,
339
+ tick: false,
340
+ titlePosition: 'start',
341
+ },
342
+ legendCategory: {
343
+ backgroundFill: 'transparent',
344
+ itemBackgroundFill: 'transparent',
345
+ itemLabelFill: COLORS.BLACK,
346
+ itemLabelFillOpacity: ALPHA[90],
347
+ itemLabelFontSize: 12,
348
+ itemLabelFontWeight: 'normal',
349
+ itemMarkerFillOpacity: 1,
350
+ itemMarkerSize: 8,
351
+ itemSpacing: [PADDING[1], PADDING[1]],
352
+ itemValueFill: COLORS.BLACK,
353
+ itemValueFillOpacity: 0.65,
354
+ itemValueFontSize: 12,
355
+ itemValueFontWeight: 'normal',
356
+ navButtonFill: COLORS.BLACK,
357
+ navButtonFillOpacity: 0.65,
358
+ navPageNumFill: COLORS.BLACK,
359
+ navPageNumFillOpacity: 0.45,
360
+ navPageNumFontSize: 12,
361
+ padding: 8,
362
+ title: false,
363
+ titleFill: COLORS.BLACK,
364
+ titleFillOpacity: 0.65,
365
+ titleFontSize: 12,
366
+ titleFontWeight: 'normal',
367
+ titleSpacing: 4,
368
+ tickStroke: COLORS.BLACK,
369
+ tickStrokeOpacity: 0.25,
370
+ rowPadding: PADDING[1],
371
+ colPadding: PADDING[2],
372
+ maxRows: 3,
373
+ maxCols: 3,
374
+ },
375
+ legendContinuous: {
376
+ handleHeight: 12,
377
+ handleLabelFill: COLORS.BLACK,
378
+ handleLabelFillOpacity: ALPHA[45],
379
+ handleLabelFontSize: 12,
380
+ handleLabelFontWeight: 'normal',
381
+ handleMarkerFill: COLORS.BLACK,
382
+ handleMarkerFillOpacity: 0.6,
383
+ handleMarkerLineWidth: 1,
384
+ handleMarkerStroke: COLORS.BLACK,
385
+ handleMarkerStrokeOpacity: 0.25,
386
+ handleWidth: 10,
387
+ labelFill: COLORS.BLACK,
388
+ labelFillOpacity: ALPHA[45],
389
+ labelFontSize: 12,
390
+ labelFontWeight: 'normal',
391
+ labelSpacing: 3,
392
+ tick: true,
393
+ tickLength: 12,
394
+ ribbonSize: 12,
395
+ ribbonFill: '#aaa',
396
+ handle: true,
397
+ handleLabel: false,
398
+ handleShape: 'slider',
399
+ handleIconSize: 12 / 1.8,
400
+ indicator: false,
401
+ titleFontSize: 12,
402
+ titleSpacing: 4,
403
+ titleFontWeight: 'normal',
404
+ titleFillOpacity: ALPHA[90],
405
+ tickStroke: COLORS.BLACK,
406
+ tickStrokeOpacity: ALPHA[45],
407
+ },
408
+ label: {
409
+ fill: COLORS.BLACK,
410
+ fillOpacity: 0.65,
411
+ fontSize: 12,
412
+ fontWeight: 'normal',
413
+ stroke: undefined,
414
+ offset: 12,
415
+ connectorStroke: COLORS.BLACK,
416
+ connectorStrokeOpacity: 0.45,
417
+ connectorLineWidth: 1,
418
+ connectorLength: 12,
419
+ connectorLength2: 8,
420
+ connectorDistance: 4,
421
+ },
422
+ innerLabel: {
423
+ fill: COLORS.WHITE,
424
+ fontSize: 12,
425
+ fillOpacity: 0.85,
426
+ fontWeight: 'normal',
427
+ stroke: undefined,
428
+ offset: 0,
429
+ },
430
+ htmlLabel: {
431
+ fontSize: 12,
432
+ opacity: 0.65,
433
+ color: COLORS.BLACK,
434
+ fontWeight: 'normal',
435
+ },
436
+ slider: {
437
+ trackSize: 16,
438
+ trackFill: COLORS.STROKE,
439
+ trackFillOpacity: 1,
440
+ selectionFill: COLORS.DEFAULT,
441
+ selectionFillOpacity: 0.15,
442
+ handleIconSize: 10,
443
+ handleIconFill: '#f7f7f7',
444
+ handleIconFillOpacity: 1,
445
+ handleIconStroke: COLORS.BLACK,
446
+ handleIconStrokeOpacity: 0.25,
447
+ handleIconLineWidth: 1,
448
+ handleIconRadius: 2,
449
+ handleLabelFill: COLORS.BLACK,
450
+ handleLabelFillOpacity: 0.45,
451
+ handleLabelFontSize: 12,
452
+ handleLabelFontWeight: 'normal',
453
+ },
454
+ scrollbar: {
455
+ padding: [0, 0, 0, 0],
456
+ trackSize: 6,
457
+ isRound: true,
458
+ slidable: true,
459
+ scrollable: true,
460
+ trackFill: '#e5e5e5',
461
+ trackFillOpacity: 0,
462
+ thumbFill: '#000',
463
+ thumbFillOpacity: 0.15,
464
+ thumbHighlightedFillOpacity: 0.2,
465
+ },
466
+ title: {
467
+ spacing: 8,
468
+ titleFill: COLORS.BLACK,
469
+ titleFillOpacity: ALPHA[90],
470
+ titleFontSize: 16,
471
+ titleFontWeight: 'bold',
472
+ titleTextBaseline: 'top',
473
+ subtitleFill: COLORS.BLACK,
474
+ subtitleFillOpacity: ALPHA[65],
475
+ subtitleFontSize: 12,
476
+ subtitleFontWeight: 'normal',
477
+ subtitleTextBaseline: 'top',
478
+ },
479
+ };
480
+ return Object.assign({}, defaultOptions, options);
481
+ };
482
+
483
+ Light.props = {};
@@ -365,40 +365,40 @@ export class Selection<T = any> {
365
365
  );
366
366
  }
367
367
 
368
- each(callback: (datum: T, index: number) => any): Selection<T> {
368
+ each(callback: (datum: T, index: number, element) => any): Selection<T> {
369
369
  for (let i = 0; i < this._elements.length; i++) {
370
370
  const element = this._elements[i];
371
371
  const datum = element.__data__;
372
- callback.call(element, datum, i);
372
+ callback(datum, i, element);
373
373
  }
374
374
  return this;
375
375
  }
376
376
 
377
377
  attr(key: string, value: any): Selection<T> {
378
378
  const callback = typeof value !== 'function' ? () => value : value;
379
- return this.each(function (d, i) {
380
- if (value !== undefined) this[key] = callback.call(this, d, i);
379
+ return this.each(function (d, i, element) {
380
+ if (value !== undefined) element[key] = callback(d, i, element);
381
381
  });
382
382
  }
383
383
 
384
384
  style(key: string, value: any): Selection<T> {
385
385
  const callback = typeof value !== 'function' ? () => value : value;
386
- return this.each(function (d, i) {
387
- if (value !== undefined) this.style[key] = callback.call(this, d, i);
386
+ return this.each(function (d, i, element) {
387
+ if (value !== undefined) element.style[key] = callback(d, i, element);
388
388
  });
389
389
  }
390
390
 
391
391
  transition(value: any): Selection<T> {
392
392
  const callback = typeof value !== 'function' ? () => value : value;
393
393
  const { _transitions: T } = this;
394
- return this.each(function (d, i) {
395
- T[i] = callback.call(this, d, i);
394
+ return this.each(function (d, i, element) {
395
+ T[i] = callback(d, i, element);
396
396
  });
397
397
  }
398
398
 
399
399
  on(event: string, handler: any) {
400
- this.each(function () {
401
- this.addEventListener(event, handler);
400
+ this.each(function (d, i, element) {
401
+ element.addEventListener(event, handler);
402
402
  });
403
403
  return this;
404
404
  }
@@ -407,7 +407,7 @@ export class Selection<T = any> {
407
407
  callback: (selection: Selection<T>, ...args: any[]) => any,
408
408
  ...args: any[]
409
409
  ): Selection<T> {
410
- callback.call(this._parent, this, ...args);
410
+ callback(this, ...args);
411
411
  return this;
412
412
  }
413
413
 
package/src/utils/size.ts CHANGED
@@ -59,7 +59,7 @@ export function getBBoxSize(options: G2View): Size {
59
59
 
60
60
  // @todo Add this padding to theme.
61
61
  // 30 is default size for padding, which defined in runtime.
62
- const maybeAuto = (padding) => (padding === 'auto' ? 30 : padding);
62
+ const maybeAuto = (padding) => (padding === 'auto' ? 20 : padding);
63
63
 
64
64
  const finalWidth =
65
65
  width -