@antv/g2plot 2.4.2 → 2.4.7
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/CHANGELOG.md +20 -7
- package/dist/g2plot.min.js +4 -4
- package/dist/g2plot.min.js.map +1 -1
- package/esm/index.d.ts +1 -9
- package/esm/index.js +1 -9
- package/esm/index.js.map +1 -1
- package/esm/plots/area/adaptor.js +22 -22
- package/esm/plots/area/adaptor.js.map +1 -1
- package/esm/plots/area/constants.d.ts +0 -2
- package/esm/plots/area/constants.js +1 -2
- package/esm/plots/area/constants.js.map +1 -1
- package/esm/plots/area/index.js +4 -11
- package/esm/plots/area/index.js.map +1 -1
- package/esm/plots/area/types.d.ts +1 -1
- package/esm/plots/area/types.js.map +1 -1
- package/esm/plots/bar/constants.js +3 -0
- package/esm/plots/bar/constants.js.map +1 -1
- package/esm/plots/column/constants.js +3 -0
- package/esm/plots/column/constants.js.map +1 -1
- package/esm/plots/gauge/adaptor.js +1 -0
- package/esm/plots/gauge/adaptor.js.map +1 -1
- package/esm/plots/line/adaptor.js +19 -33
- package/esm/plots/line/adaptor.js.map +1 -1
- package/esm/plots/line/constants.d.ts +0 -2
- package/esm/plots/line/constants.js +1 -3
- package/esm/plots/line/constants.js.map +1 -1
- package/esm/plots/line/index.js +1 -8
- package/esm/plots/line/index.js.map +1 -1
- package/esm/plots/line/interactions/marker-active.js +11 -8
- package/esm/plots/line/interactions/marker-active.js.map +1 -1
- package/esm/plots/line/types.d.ts +1 -1
- package/esm/plots/line/types.js.map +1 -1
- package/esm/plots/liquid/adaptor.js +2 -1
- package/esm/plots/liquid/adaptor.js.map +1 -1
- package/esm/plots/liquid/shapes/liquid.js +5 -3
- package/esm/plots/liquid/shapes/liquid.js.map +1 -1
- package/esm/plots/liquid/types.d.ts +1 -0
- package/esm/plots/liquid/types.js.map +1 -1
- package/esm/plots/pie/adaptor.js +2 -0
- package/esm/plots/pie/adaptor.js.map +1 -1
- package/esm/plots/pie/contants.js +1 -0
- package/esm/plots/pie/contants.js.map +1 -1
- package/esm/plots/progress/adaptor.js +1 -0
- package/esm/plots/progress/adaptor.js.map +1 -1
- package/esm/plots/rose/constant.js +1 -0
- package/esm/plots/rose/constant.js.map +1 -1
- package/esm/plots/scatter/adaptor.d.ts +1 -1
- package/esm/plots/scatter/adaptor.js +2 -2
- package/esm/plots/scatter/adaptor.js.map +1 -1
- package/esm/utils/geometry.js +1 -2
- package/esm/utils/geometry.js.map +1 -1
- package/lib/index.d.ts +1 -9
- package/lib/index.js +5 -13
- package/lib/index.js.map +1 -1
- package/lib/plots/area/adaptor.js +20 -20
- package/lib/plots/area/adaptor.js.map +1 -1
- package/lib/plots/area/constants.d.ts +0 -2
- package/lib/plots/area/constants.js +2 -3
- package/lib/plots/area/constants.js.map +1 -1
- package/lib/plots/area/index.js +3 -10
- package/lib/plots/area/index.js.map +1 -1
- package/lib/plots/area/types.d.ts +1 -1
- package/lib/plots/area/types.js.map +1 -1
- package/lib/plots/bar/constants.js +3 -0
- package/lib/plots/bar/constants.js.map +1 -1
- package/lib/plots/column/constants.js +3 -0
- package/lib/plots/column/constants.js.map +1 -1
- package/lib/plots/gauge/adaptor.js +1 -0
- package/lib/plots/gauge/adaptor.js.map +1 -1
- package/lib/plots/line/adaptor.js +16 -30
- package/lib/plots/line/adaptor.js.map +1 -1
- package/lib/plots/line/constants.d.ts +0 -2
- package/lib/plots/line/constants.js +2 -4
- package/lib/plots/line/constants.js.map +1 -1
- package/lib/plots/line/index.js +0 -7
- package/lib/plots/line/index.js.map +1 -1
- package/lib/plots/line/interactions/marker-active.js +11 -8
- package/lib/plots/line/interactions/marker-active.js.map +1 -1
- package/lib/plots/line/types.d.ts +1 -1
- package/lib/plots/line/types.js.map +1 -1
- package/lib/plots/liquid/adaptor.js +2 -1
- package/lib/plots/liquid/adaptor.js.map +1 -1
- package/lib/plots/liquid/shapes/liquid.js +5 -3
- package/lib/plots/liquid/shapes/liquid.js.map +1 -1
- package/lib/plots/liquid/types.d.ts +1 -0
- package/lib/plots/liquid/types.js.map +1 -1
- package/lib/plots/pie/adaptor.js +2 -0
- package/lib/plots/pie/adaptor.js.map +1 -1
- package/lib/plots/pie/contants.js +1 -0
- package/lib/plots/pie/contants.js.map +1 -1
- package/lib/plots/progress/adaptor.js +1 -0
- package/lib/plots/progress/adaptor.js.map +1 -1
- package/lib/plots/rose/constant.js +1 -0
- package/lib/plots/rose/constant.js.map +1 -1
- package/lib/plots/scatter/adaptor.d.ts +1 -1
- package/lib/plots/scatter/adaptor.js +1 -1
- package/lib/plots/scatter/adaptor.js.map +1 -1
- package/lib/utils/geometry.js +1 -2
- package/lib/utils/geometry.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -9
- package/src/plots/area/adaptor.ts +25 -26
- package/src/plots/area/constants.ts +1 -3
- package/src/plots/area/index.ts +3 -10
- package/src/plots/area/types.ts +1 -1
- package/src/plots/bar/constants.ts +3 -0
- package/src/plots/column/constants.ts +3 -0
- package/src/plots/gauge/adaptor.ts +1 -0
- package/src/plots/line/adaptor.ts +28 -37
- package/src/plots/line/constants.ts +1 -4
- package/src/plots/line/index.ts +1 -8
- package/src/plots/line/interactions/marker-active.ts +12 -9
- package/src/plots/line/types.ts +1 -1
- package/src/plots/liquid/adaptor.ts +2 -1
- package/src/plots/liquid/shapes/liquid.ts +6 -3
- package/src/plots/liquid/types.ts +1 -0
- package/src/plots/pie/adaptor.ts +2 -0
- package/src/plots/pie/contants.ts +1 -0
- package/src/plots/progress/adaptor.ts +1 -0
- package/src/plots/rose/constant.ts +1 -0
- package/src/plots/scatter/adaptor.ts +3 -1
- package/src/utils/geometry.ts +1 -2
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { Plot } from '../../core/plot';
|
|
2
2
|
import { deepAssign } from '../../utils';
|
|
3
3
|
|
|
4
|
-
/** point 标注点视图 */
|
|
5
|
-
export const POINT_VIEW_ID = 'point-view';
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* 折线图默认配置项
|
|
9
6
|
*/
|
|
10
7
|
export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
|
|
11
|
-
syncViewPadding: true,
|
|
12
8
|
tooltip: {
|
|
13
9
|
shared: true,
|
|
14
10
|
showMarkers: true,
|
|
@@ -19,6 +15,7 @@ export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
|
|
|
19
15
|
},
|
|
20
16
|
legend: {
|
|
21
17
|
position: 'top-left',
|
|
18
|
+
radio: {},
|
|
22
19
|
},
|
|
23
20
|
isStack: false,
|
|
24
21
|
});
|
package/src/plots/line/index.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { isNil } from '@antv/util';
|
|
2
1
|
import { Plot } from '../../core/plot';
|
|
3
2
|
import { Adaptor } from '../../core/adaptor';
|
|
4
|
-
import { findViewById } from '../../utils';
|
|
5
3
|
import { LineOptions } from './types';
|
|
6
4
|
import { adaptor, meta } from './adaptor';
|
|
7
|
-
import { DEFAULT_OPTIONS
|
|
5
|
+
import { DEFAULT_OPTIONS } from './constants';
|
|
8
6
|
import './interactions';
|
|
9
7
|
|
|
10
8
|
export type { LineOptions };
|
|
@@ -28,13 +26,8 @@ export class Line extends Plot<LineOptions> {
|
|
|
28
26
|
public changeData(data: LineOptions['data']) {
|
|
29
27
|
this.updateOption({ data });
|
|
30
28
|
const { chart, options } = this;
|
|
31
|
-
const { yField } = options;
|
|
32
29
|
meta({ chart, options });
|
|
33
30
|
this.chart.changeData(data);
|
|
34
|
-
const pointView = findViewById(this.chart, POINT_VIEW_ID);
|
|
35
|
-
if (pointView) {
|
|
36
|
-
pointView.changeData(data.filter((d) => !isNil(d[yField])));
|
|
37
|
-
}
|
|
38
31
|
}
|
|
39
32
|
|
|
40
33
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { each, findIndex } from '@antv/util';
|
|
2
|
-
import { InteractionAction, View } from '@antv/g2';
|
|
3
|
-
import { findGeometry } from '../../../utils';
|
|
2
|
+
import { InteractionAction, View, Geometry } from '@antv/g2';
|
|
4
3
|
|
|
5
4
|
export class MarkerActiveAction extends InteractionAction {
|
|
6
5
|
public active() {
|
|
@@ -9,19 +8,23 @@ export class MarkerActiveAction extends InteractionAction {
|
|
|
9
8
|
if (evt.data) {
|
|
10
9
|
// items: 数组对象,当前 tooltip 显示的每条内容
|
|
11
10
|
const { items } = evt.data;
|
|
12
|
-
const
|
|
13
|
-
each(
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const points = view.geometries.filter((geom) => geom.type === 'point');
|
|
12
|
+
each(points, (point: Geometry) => {
|
|
13
|
+
each(point.elements, (element) => {
|
|
14
|
+
const active = findIndex(items, (item) => (item as any).data === element.data) !== -1;
|
|
15
|
+
element.setState('active', active);
|
|
16
|
+
});
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
public reset() {
|
|
21
22
|
const view = this.getView();
|
|
22
|
-
const
|
|
23
|
-
each(
|
|
24
|
-
|
|
23
|
+
const points = view.geometries.filter((geom) => geom.type === 'point');
|
|
24
|
+
each(points, (point: Geometry) => {
|
|
25
|
+
each(point.elements, (element) => {
|
|
26
|
+
element.setState('active', false);
|
|
27
|
+
});
|
|
25
28
|
});
|
|
26
29
|
}
|
|
27
30
|
|
package/src/plots/line/types.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'
|
|
|
28
28
|
/** 折线数据点:1、图形映射属性 2、状态样式 */
|
|
29
29
|
readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;
|
|
30
30
|
/** 折线趋势填充色:1、图形映射属性 */
|
|
31
|
-
readonly area?: AreaGeometryOptions['area']
|
|
31
|
+
readonly area?: AreaGeometryOptions['area'] & Pick<PointGeometryOptions, 'state'>;
|
|
32
32
|
|
|
33
33
|
// 其他
|
|
34
34
|
/** 坐标轴反转配置 */
|
|
@@ -13,7 +13,7 @@ import { getLiquidData } from './utils';
|
|
|
13
13
|
*/
|
|
14
14
|
function geometry(params: Params<LiquidOptions>): Params<LiquidOptions> {
|
|
15
15
|
const { chart, options } = params;
|
|
16
|
-
const { percent, liquidStyle, radius, outline, wave, shape } = options;
|
|
16
|
+
const { percent, liquidStyle, radius, outline, wave, shape, animation } = options;
|
|
17
17
|
|
|
18
18
|
chart.scale({
|
|
19
19
|
percent: {
|
|
@@ -49,6 +49,7 @@ function geometry(params: Params<LiquidOptions>): Params<LiquidOptions> {
|
|
|
49
49
|
wave,
|
|
50
50
|
shape,
|
|
51
51
|
background,
|
|
52
|
+
animation,
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
// 将 radius 传入到自定义 shape 中
|
|
@@ -212,7 +212,8 @@ function addWaterWave(
|
|
|
212
212
|
group: IGroup,
|
|
213
213
|
clip: IShape,
|
|
214
214
|
radius: number,
|
|
215
|
-
waveLength: number
|
|
215
|
+
waveLength: number,
|
|
216
|
+
animation: LiquidOptions['animation']
|
|
216
217
|
) {
|
|
217
218
|
const { fill, opacity } = waveAttrs;
|
|
218
219
|
const bbox = clip.getBBox();
|
|
@@ -239,6 +240,7 @@ function addWaterWave(
|
|
|
239
240
|
});
|
|
240
241
|
|
|
241
242
|
try {
|
|
243
|
+
if (animation === false) return;
|
|
242
244
|
const matrix = transform([['t', waveLength, 0]]);
|
|
243
245
|
|
|
244
246
|
wave.stopAnimate();
|
|
@@ -373,7 +375,7 @@ registerShape('interval', 'liquid-fill-gauge', {
|
|
|
373
375
|
const cy = 0.5;
|
|
374
376
|
|
|
375
377
|
const { customInfo } = cfg;
|
|
376
|
-
const { radius: radio, shape, background } = customInfo as CustomInfo;
|
|
378
|
+
const { radius: radio, shape, background, animation } = customInfo as CustomInfo;
|
|
377
379
|
const outline: LiquidOptions['outline'] = customInfo.outline;
|
|
378
380
|
const wave: LiquidOptions['wave'] = customInfo.wave;
|
|
379
381
|
const { border, distance } = outline;
|
|
@@ -430,7 +432,8 @@ registerShape('interval', 'liquid-fill-gauge', {
|
|
|
430
432
|
waves,
|
|
431
433
|
clipPath,
|
|
432
434
|
radius * 2,
|
|
433
|
-
waveLength
|
|
435
|
+
waveLength,
|
|
436
|
+
animation
|
|
434
437
|
);
|
|
435
438
|
|
|
436
439
|
// 2. 绘制一个 distance 宽的 border
|
package/src/plots/pie/adaptor.ts
CHANGED
|
@@ -42,6 +42,7 @@ function geometry(params: Params<PieOptions>): Params<PieOptions> {
|
|
|
42
42
|
},
|
|
43
43
|
args: {
|
|
44
44
|
zIndexReversed: true,
|
|
45
|
+
sortZIndex: true,
|
|
45
46
|
},
|
|
46
47
|
},
|
|
47
48
|
});
|
|
@@ -62,6 +63,7 @@ function geometry(params: Params<PieOptions>): Params<PieOptions> {
|
|
|
62
63
|
},
|
|
63
64
|
args: {
|
|
64
65
|
zIndexReversed: true,
|
|
66
|
+
sortZIndex: true,
|
|
65
67
|
},
|
|
66
68
|
},
|
|
67
69
|
});
|
|
@@ -3,7 +3,7 @@ import { Params } from '../../core/adaptor';
|
|
|
3
3
|
import { flow, deepAssign, pick } from '../../utils';
|
|
4
4
|
import { point } from '../../adaptor/geometries';
|
|
5
5
|
import { brushInteraction } from '../../adaptor/brush';
|
|
6
|
-
import { interaction, animation, theme, scale, annotation } from '../../adaptor/common';
|
|
6
|
+
import { interaction, animation, theme, scale, annotation, slider, scrollbar } from '../../adaptor/common';
|
|
7
7
|
import { findGeometry, transformLabel } from '../../utils';
|
|
8
8
|
import { getQuadrantDefaultConfig, getPath, getMeta } from './util';
|
|
9
9
|
import { ScatterOptions } from './types';
|
|
@@ -327,6 +327,8 @@ export function adaptor(params: Params<ScatterOptions>) {
|
|
|
327
327
|
label,
|
|
328
328
|
// 需要在 interaction 前面
|
|
329
329
|
brushInteraction,
|
|
330
|
+
slider,
|
|
331
|
+
scrollbar,
|
|
330
332
|
interaction,
|
|
331
333
|
scatterAnnotation,
|
|
332
334
|
animation,
|
package/src/utils/geometry.ts
CHANGED
|
@@ -7,8 +7,7 @@ import { reduce, get } from '@antv/util';
|
|
|
7
7
|
* @param type
|
|
8
8
|
*/
|
|
9
9
|
export function findGeometry(view: View, type: string): Geometry {
|
|
10
|
-
|
|
11
|
-
return geometries.find((g: Geometry) => g.type === type);
|
|
10
|
+
return view.geometries.find((g: Geometry) => g.type === type);
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
/**
|