@antv/g2 5.1.15 → 5.1.16

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.
@@ -360,13 +360,13 @@ function inferScaleRange(
360
360
  case 'sqrt': {
361
361
  const colors = categoricalColors(values, options, domain, theme, library);
362
362
  const [r0, r1] = inferRangeQ(name, colors);
363
- return [rangeMin || r0, rangeMax || r1];
363
+ return [rangeMin ?? r0, rangeMax ?? r1];
364
364
  }
365
365
  case 'band':
366
366
  case 'point': {
367
367
  const min = name === 'size' ? 5 : 0;
368
368
  const max = name === 'size' ? 10 : 1;
369
- return [rangeMin || min, rangeMax || max];
369
+ return [rangeMin ?? min, rangeMax ?? max];
370
370
  }
371
371
  case 'ordinal': {
372
372
  return categoricalColors(values, options, domain, theme, library);
@@ -565,7 +565,7 @@ function inferDomainC(values: Primitive[][]) {
565
565
  }
566
566
 
567
567
  function inferDomainO(values: Primitive[][]) {
568
- return inferDomainC(values).sort();
568
+ return values.flat().sort();
569
569
  }
570
570
 
571
571
  function inferDomainS(values: Primitive[][]) {
@@ -0,0 +1,57 @@
1
+ import { omit } from '@antv/util';
2
+ import type { Vector2, ShapeComponent as SC } from '../../runtime';
3
+
4
+ export type RoundOptions = Record<string, any>;
5
+
6
+ // Get point1 point2 radius.
7
+ const getR = (point1, point2) => {
8
+ return (
9
+ Math.sqrt(
10
+ Math.pow(point1[0] - point2[0], 2) + Math.pow(point1[1] - point2[1], 2),
11
+ ) / 2
12
+ );
13
+ };
14
+
15
+ // Gauge round.
16
+ export const Round: SC<RoundOptions> = (options, context) => {
17
+ if (!context) return;
18
+ const { coordinate } = context;
19
+ if (!coordinate?.getCenter) return;
20
+ // Get coordinate center point.
21
+ const center = coordinate.getCenter() as Vector2;
22
+
23
+ return (points, cfg, defaultCfg) => {
24
+ const { document } = context.canvas;
25
+ const { color, index } = cfg;
26
+
27
+ const g = document.createElement('g', {});
28
+
29
+ const minR = getR(points[0], points[1]);
30
+ const maxR = getR(points[0], center) * 2;
31
+
32
+ /**
33
+ * MinR small circle radius, maxR big circle radius.
34
+ * Draw four arcs.
35
+ * Style lineWidth and stroke for the time being inset.
36
+ */
37
+ const roundPath = document.createElement('path', {
38
+ style: {
39
+ path: [
40
+ ['M', ...points[0]],
41
+ ['A', minR, minR, 0, 1, 0, ...points[1]],
42
+ ['A', maxR + minR * 2, maxR + minR * 2, 0, 0, 0, ...points[2]],
43
+ ['A', minR, minR, 0, 1, index === 0 ? 0 : 1, ...points[3]],
44
+ ['A', maxR, maxR, 0, 0, 1, ...points[0]],
45
+ ['Z'],
46
+ ],
47
+ ...defaultCfg,
48
+ ...omit(options, ['shape', 'last', 'first']),
49
+ fill: color || defaultCfg.color,
50
+ },
51
+ });
52
+
53
+ g.appendChild(roundPath);
54
+
55
+ return g;
56
+ };
57
+ };
@@ -58,6 +58,7 @@ export { Rect as RectShape } from './interval/rect';
58
58
  export { Hollow as RectHollow } from './interval/hollow';
59
59
  export { Shape as ShapeShape } from './shape/shape';
60
60
  export { Liquid as LiquidShape } from './liquid/liquid';
61
+ export { Round as GaugeRound } from './gauge/round';
61
62
 
62
63
  export type { RectOptions as IntervalShapeOptions } from './interval/rect';
63
64
  export type { HollowOptions as IntervalHollowOptions } from './interval/hollow';