@antv/component 0.8.32 → 0.9.2
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/esm/abstract/html-component.js +1 -9
- package/esm/abstract/html-component.js.map +1 -1
- package/esm/legend/category.js +12 -3
- package/esm/legend/category.js.map +1 -1
- package/esm/slider/constant.d.ts +46 -1
- package/esm/slider/constant.js +50 -4
- package/esm/slider/constant.js.map +1 -1
- package/esm/slider/foreground.d.ts +78 -0
- package/esm/slider/foreground.js +102 -0
- package/esm/slider/foreground.js.map +1 -0
- package/esm/slider/handler.d.ts +3 -8
- package/esm/slider/handler.js +8 -15
- package/esm/slider/handler.js.map +1 -1
- package/esm/slider/slider.d.ts +29 -4
- package/esm/slider/slider.js +243 -46
- package/esm/slider/slider.js.map +1 -1
- package/esm/tooltip/css-const.d.ts +0 -1
- package/esm/tooltip/css-const.js +0 -1
- package/esm/tooltip/css-const.js.map +1 -1
- package/esm/tooltip/html-theme.d.ts +0 -22
- package/esm/tooltip/html-theme.js +0 -7
- package/esm/tooltip/html-theme.js.map +1 -1
- package/esm/tooltip/html.d.ts +0 -23
- package/esm/tooltip/html.js +11 -27
- package/esm/tooltip/html.js.map +1 -1
- package/esm/util/event.d.ts +8 -0
- package/esm/util/event.js +11 -0
- package/esm/util/event.js.map +1 -1
- package/esm/util/mask.d.ts +9 -0
- package/esm/util/mask.js +26 -0
- package/esm/util/mask.js.map +1 -0
- package/esm/util/util.d.ts +10 -0
- package/esm/util/util.js +62 -1
- package/esm/util/util.js.map +1 -1
- package/lib/abstract/html-component.js +1 -9
- package/lib/abstract/html-component.js.map +1 -1
- package/lib/legend/category.js +12 -3
- package/lib/legend/category.js.map +1 -1
- package/lib/slider/constant.d.ts +46 -1
- package/lib/slider/constant.js +51 -5
- package/lib/slider/constant.js.map +1 -1
- package/lib/slider/foreground.d.ts +78 -0
- package/lib/slider/foreground.js +105 -0
- package/lib/slider/foreground.js.map +1 -0
- package/lib/slider/handler.d.ts +3 -8
- package/lib/slider/handler.js +9 -16
- package/lib/slider/handler.js.map +1 -1
- package/lib/slider/slider.d.ts +29 -4
- package/lib/slider/slider.js +240 -43
- package/lib/slider/slider.js.map +1 -1
- package/lib/tooltip/css-const.d.ts +0 -1
- package/lib/tooltip/css-const.js +1 -2
- package/lib/tooltip/css-const.js.map +1 -1
- package/lib/tooltip/html-theme.d.ts +0 -22
- package/lib/tooltip/html-theme.js +0 -7
- package/lib/tooltip/html-theme.js.map +1 -1
- package/lib/tooltip/html.d.ts +0 -23
- package/lib/tooltip/html.js +11 -27
- package/lib/tooltip/html.js.map +1 -1
- package/lib/util/event.d.ts +8 -0
- package/lib/util/event.js +13 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/mask.d.ts +9 -0
- package/lib/util/mask.js +32 -0
- package/lib/util/mask.js.map +1 -0
- package/lib/util/util.d.ts +10 -0
- package/lib/util/util.js +64 -1
- package/lib/util/util.js.map +1 -1
- package/package.json +6 -18
- package/src/abstract/html-component.ts +1 -12
- package/src/legend/category.ts +21 -12
- package/src/slider/constant.ts +54 -4
- package/src/slider/foreground.ts +158 -0
- package/src/slider/handler.ts +10 -20
- package/src/slider/slider.ts +275 -60
- package/src/tooltip/css-const.ts +0 -1
- package/src/tooltip/html-theme.ts +0 -8
- package/src/tooltip/html.ts +11 -29
- package/src/util/event.ts +12 -0
- package/src/util/mask.ts +32 -0
- package/src/util/util.ts +67 -2
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { IGroup, LooseObject } from '@antv/g-base';
|
|
2
|
+
import { omit } from '@antv/util';
|
|
3
|
+
import GroupComponent from '../abstract/group-component';
|
|
4
|
+
import { GroupComponentCfg } from '../types';
|
|
5
|
+
import { BAR_STYLE, FOREGROUND_STYLE, SLIDER_BAR_LINE_GAP } from './constant';
|
|
6
|
+
|
|
7
|
+
interface IStyle {
|
|
8
|
+
fill?: string;
|
|
9
|
+
stroke?: string;
|
|
10
|
+
radius?: number;
|
|
11
|
+
opacity?: number;
|
|
12
|
+
cursor?: string;
|
|
13
|
+
highLightFill?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ForegroundCfg extends GroupComponentCfg {
|
|
17
|
+
// position size
|
|
18
|
+
readonly x: number;
|
|
19
|
+
readonly y: number;
|
|
20
|
+
readonly width: number;
|
|
21
|
+
readonly height: number;
|
|
22
|
+
// style
|
|
23
|
+
readonly foregroundStyle?: IStyle;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class Foreground extends GroupComponent<ForegroundCfg> {
|
|
27
|
+
public getDefaultCfg() {
|
|
28
|
+
const cfg = super.getDefaultCfg();
|
|
29
|
+
return {
|
|
30
|
+
...cfg,
|
|
31
|
+
name: 'foreground',
|
|
32
|
+
width: 100,
|
|
33
|
+
height: 16,
|
|
34
|
+
foregroundStyle: FOREGROUND_STYLE,
|
|
35
|
+
barStyle: BAR_STYLE,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected renderInner(group: IGroup) {
|
|
40
|
+
const { x, height, width, foregroundStyle, barStyle } = this.cfg;
|
|
41
|
+
|
|
42
|
+
// 上方brush区域
|
|
43
|
+
this.addShape(group, {
|
|
44
|
+
id: this.getElementId('foreground-brush'),
|
|
45
|
+
name: 'foreground-brush',
|
|
46
|
+
type: 'rect',
|
|
47
|
+
attrs: {
|
|
48
|
+
x,
|
|
49
|
+
y: 0,
|
|
50
|
+
width,
|
|
51
|
+
height: (height * 3) / 5,
|
|
52
|
+
cursor: 'crosshair',
|
|
53
|
+
...omit(foregroundStyle, ['stroke']),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// 下方移动区域
|
|
58
|
+
this.addShape(group, {
|
|
59
|
+
id: this.getElementId('foreground-scroll'),
|
|
60
|
+
name: 'foreground-scroll',
|
|
61
|
+
type: 'rect',
|
|
62
|
+
attrs: {
|
|
63
|
+
x,
|
|
64
|
+
y: (height * 3) / 5,
|
|
65
|
+
width,
|
|
66
|
+
height: (height * 2) / 5,
|
|
67
|
+
cursor: 'move',
|
|
68
|
+
...omit(foregroundStyle, ['stroke']),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// 下方Bar区域
|
|
73
|
+
const barGroup = this.addGroup(group, {
|
|
74
|
+
id: this.getElementId('foreground-bar'),
|
|
75
|
+
name: 'foreground-bar',
|
|
76
|
+
});
|
|
77
|
+
// 外层矩形
|
|
78
|
+
this.addShape(barGroup, {
|
|
79
|
+
id: this.getElementId('foreground-bar-rect'),
|
|
80
|
+
name: 'foreground-bar-rect',
|
|
81
|
+
type: 'rect',
|
|
82
|
+
attrs: {
|
|
83
|
+
x,
|
|
84
|
+
y: height,
|
|
85
|
+
width,
|
|
86
|
+
height: barStyle.height,
|
|
87
|
+
cursor: 'move',
|
|
88
|
+
...barStyle,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
// 三条小竖线
|
|
92
|
+
const centerX = width / 2 + x;
|
|
93
|
+
const leftX = centerX - SLIDER_BAR_LINE_GAP;
|
|
94
|
+
const rightX = centerX + SLIDER_BAR_LINE_GAP;
|
|
95
|
+
const y1 = height + (1 / 4) * barStyle.height;
|
|
96
|
+
const y2 = height + (3 / 4) * barStyle.height;
|
|
97
|
+
const publicAttrs = {
|
|
98
|
+
y1,
|
|
99
|
+
y2,
|
|
100
|
+
...barStyle,
|
|
101
|
+
};
|
|
102
|
+
[leftX, centerX, rightX].forEach((x) => {
|
|
103
|
+
this.drawBarLine(group, x, publicAttrs);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
this.addShape(group, {
|
|
107
|
+
id: this.getElementId('foreground-border'),
|
|
108
|
+
name: 'foreground-border',
|
|
109
|
+
type: 'rect',
|
|
110
|
+
attrs: {
|
|
111
|
+
x,
|
|
112
|
+
y: 0,
|
|
113
|
+
width,
|
|
114
|
+
height,
|
|
115
|
+
stroke: foregroundStyle?.stroke,
|
|
116
|
+
opacity: foregroundStyle?.strokeOpacity,
|
|
117
|
+
lineWidth: foregroundStyle?.lineWidth,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private drawBarLine(group: IGroup, x: number, attrs: LooseObject) {
|
|
123
|
+
this.addShape(group, {
|
|
124
|
+
id: this.getElementId(`line-${x}`),
|
|
125
|
+
name: `line-${x}`,
|
|
126
|
+
type: 'line',
|
|
127
|
+
attrs: {
|
|
128
|
+
x1: x,
|
|
129
|
+
x2: x,
|
|
130
|
+
...attrs,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
protected initEvent() {
|
|
136
|
+
this.bindEvents();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private bindEvents() {
|
|
140
|
+
const { highLightFill, fill } = this.get('barStyle');
|
|
141
|
+
const barRectShape = this.get('group').findById(this.getElementId('foreground-bar-rect'));
|
|
142
|
+
this.get('group').on('foreground-bar:mouseenter', () => {
|
|
143
|
+
barRectShape.attr('fill', highLightFill);
|
|
144
|
+
this.draw();
|
|
145
|
+
});
|
|
146
|
+
this.get('group').on('foreground-bar:mouseleave', () => {
|
|
147
|
+
barRectShape.attr('fill', fill);
|
|
148
|
+
this.draw();
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private draw() {
|
|
153
|
+
const canvas = this.get('container').get('canvas');
|
|
154
|
+
if (canvas) {
|
|
155
|
+
canvas.draw();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
package/src/slider/handler.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IGroup } from '@antv/g-base';
|
|
2
2
|
import GroupComponent from '../abstract/group-component';
|
|
3
3
|
import { GroupComponentCfg } from '../types';
|
|
4
|
+
import { DEFAULT_HANDLER_HEIGHT, DEFAULT_HANDLER_WIDTH, HANDLER_STYLE } from './constant';
|
|
4
5
|
|
|
5
6
|
interface IStyle {
|
|
6
7
|
fill?: string;
|
|
@@ -21,16 +22,6 @@ export interface HandlerCfg extends GroupComponentCfg {
|
|
|
21
22
|
readonly style?: IStyle;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export const DEFAULT_HANDLER_STYLE = {
|
|
25
|
-
fill: '#F7F7F7',
|
|
26
|
-
stroke: '#BFBFBF',
|
|
27
|
-
radius: 2,
|
|
28
|
-
opacity: 1,
|
|
29
|
-
cursor: 'ew-resize',
|
|
30
|
-
// 高亮的颜色
|
|
31
|
-
highLightFill: '#FFF',
|
|
32
|
-
};
|
|
33
|
-
|
|
34
25
|
export class Handler extends GroupComponent<HandlerCfg> {
|
|
35
26
|
public getDefaultCfg() {
|
|
36
27
|
const cfg = super.getDefaultCfg();
|
|
@@ -39,9 +30,9 @@ export class Handler extends GroupComponent<HandlerCfg> {
|
|
|
39
30
|
name: 'handler',
|
|
40
31
|
x: 0,
|
|
41
32
|
y: 0,
|
|
42
|
-
width:
|
|
43
|
-
height:
|
|
44
|
-
style:
|
|
33
|
+
width: DEFAULT_HANDLER_WIDTH,
|
|
34
|
+
height: DEFAULT_HANDLER_HEIGHT,
|
|
35
|
+
style: HANDLER_STYLE,
|
|
45
36
|
};
|
|
46
37
|
}
|
|
47
38
|
protected renderInner(group: IGroup) {
|
|
@@ -58,7 +49,6 @@ export class Handler extends GroupComponent<HandlerCfg> {
|
|
|
58
49
|
width,
|
|
59
50
|
height,
|
|
60
51
|
fill,
|
|
61
|
-
stroke,
|
|
62
52
|
radius,
|
|
63
53
|
opacity,
|
|
64
54
|
cursor,
|
|
@@ -112,16 +102,16 @@ export class Handler extends GroupComponent<HandlerCfg> {
|
|
|
112
102
|
|
|
113
103
|
private bindEvents() {
|
|
114
104
|
this.get('group').on('mouseenter', () => {
|
|
115
|
-
const {
|
|
116
|
-
this.getElementByLocalId('
|
|
117
|
-
|
|
105
|
+
const { highLightStroke } = this.get('style');
|
|
106
|
+
this.getElementByLocalId('line-left').attr('stroke', highLightStroke);
|
|
107
|
+
this.getElementByLocalId('line-right').attr('stroke', highLightStroke);
|
|
118
108
|
this.draw();
|
|
119
109
|
});
|
|
120
110
|
|
|
121
111
|
this.get('group').on('mouseleave', () => {
|
|
122
|
-
const {
|
|
123
|
-
this.getElementByLocalId('
|
|
124
|
-
|
|
112
|
+
const { stroke } = this.get('style');
|
|
113
|
+
this.getElementByLocalId('line-left').attr('stroke', stroke);
|
|
114
|
+
this.getElementByLocalId('line-right').attr('stroke', stroke);
|
|
125
115
|
this.draw();
|
|
126
116
|
});
|
|
127
117
|
}
|