@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.
- package/dist/g2.lite.min.js +1 -1
- package/dist/g2.min.js +1 -1
- package/esm/mark/gauge.js +4 -1
- package/esm/mark/gauge.js.map +1 -1
- package/esm/runtime/scale.js +3 -3
- package/esm/runtime/scale.js.map +1 -1
- package/esm/shape/gauge/round.d.ts +3 -0
- package/esm/shape/gauge/round.js +40 -0
- package/esm/shape/gauge/round.js.map +1 -0
- package/esm/shape/index.d.ts +1 -0
- package/esm/shape/index.js +1 -0
- package/esm/shape/index.js.map +1 -1
- package/lib/mark/gauge.js +4 -1
- package/lib/mark/gauge.js.map +1 -1
- package/lib/runtime/scale.js +3 -3
- package/lib/runtime/scale.js.map +1 -1
- package/lib/shape/gauge/round.d.ts +3 -0
- package/lib/shape/gauge/round.js +44 -0
- package/lib/shape/gauge/round.js.map +1 -0
- package/lib/shape/index.d.ts +1 -0
- package/lib/shape/index.js +3 -1
- package/lib/shape/index.js.map +1 -1
- package/package.json +2 -2
- package/src/mark/gauge.ts +5 -1
- package/src/runtime/scale.ts +3 -3
- package/src/shape/gauge/round.ts +57 -0
- package/src/shape/index.ts +1 -0
package/src/runtime/scale.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
+
};
|
package/src/shape/index.ts
CHANGED
|
@@ -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';
|