Skip to content

Commit 14e264d

Browse files
committed
refactor: hover on label position
1 parent f43c7a6 commit 14e264d

3 files changed

Lines changed: 182 additions & 149 deletions

File tree

packages/vrender-components/__tests__/browser/examples/axis-hoverOn-label-bottom.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const axis = new LineAxis({
5656
},
5757
labelHoverOnAxis: {
5858
autoRotate: true,
59-
position: 130,
59+
position: 185,
6060
// space: 10,
6161
padding: 6,
6262
textStyle: {
@@ -74,7 +74,7 @@ const axis = new LineAxis({
7474
// fill: 'red'
7575
// }
7676
// },
77-
text: '细分细分细分细分细分细分'
77+
text: ''
7878
},
7979
// tick: {
8080
// visible: true,
@@ -174,4 +174,7 @@ const axis = new LineAxis({
174174
horizontalMinSize: 150
175175
});
176176
window.axis = axis;
177+
setTimeout(() => {
178+
axis.showLabelHoverOnAxis(490, '细分细分细分细分细分打撒规细分');
179+
}, 100);
177180
render([axis], 'main');

packages/vrender-components/__tests__/browser/examples/axis-hoverOn-label-left.ts

Lines changed: 99 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -5,111 +5,109 @@ import { LineAxis, GroupTransition } from '../../../src';
55
import render from '../../util/render';
66

77
const axis = new LineAxis({
8-
title: {
9-
space: -30,
10-
padding: 0,
11-
textStyle: {
12-
fontSize: 12,
13-
fill: '#363839',
14-
fontWeight: 'normal',
15-
fillOpacity: 1,
16-
textAlign: 'center',
17-
textBaseline: 'bottom'
18-
},
19-
visible: true,
20-
autoRotate: false,
21-
// angle: 1.7,
22-
shape: {},
23-
background: {
24-
visible: true,
25-
style: {
26-
fill: 'red'
27-
}
28-
},
29-
state: {
30-
text: null,
31-
shape: null,
32-
background: null
33-
},
34-
text: '细分',
35-
maxWidth: null
8+
orient: 'left',
9+
hover: true,
10+
line: {
11+
visible: false,
12+
style: {
13+
lineWidth: 1,
14+
stroke: '#D9DDE4',
15+
strokeOpacity: 1
16+
}
3617
},
3718
label: {
38-
visible: true,
39-
inside: false,
40-
space: 0,
41-
padding: 0,
4219
style: {
4320
fontSize: 12,
44-
fill: '#6F6F6F',
45-
fontWeight: 'normal',
21+
fill: '#BCC1CB',
22+
fontWeight: 400,
4623
fillOpacity: 1,
47-
angle: 0,
48-
textAlign: 'center'
24+
maxLineWidth: 80,
25+
angle: 0
4926
},
5027
formatMethod: null,
5128
state: null,
52-
autoRotate: false,
53-
autoHide: false,
54-
autoLimit: false,
55-
containerAlign: 'center'
56-
},
57-
labelHoverOnAxis: {
5829
visible: true,
59-
// position: 50,
60-
// autoRotate: false,
61-
// space: 10,
62-
// padding: 2,
63-
// textStyle: {
64-
// fontSize: 12,
65-
// fill: '#363839',
66-
// fontWeight: 'normal',
67-
// fillOpacity: 1,
68-
// textAlign: 'right',
69-
// textBaseline: 'middle'
70-
// },
71-
// background: {
72-
// visible: true,
73-
// style: {
74-
// fill: 'red'
75-
// }
76-
// },
77-
text: '细分'
78-
// maxWidth: 100
30+
space: 0,
31+
autoLimit: false,
32+
flush: true,
33+
containerAlign: 'right',
34+
minGap: 1,
35+
autoHide: false,
36+
autoHideMethod: 'greedy',
37+
autoHideSeparation: 1,
38+
autoRotate: false,
39+
autoRotateAngle: [0, -45, -90],
40+
lastVisible: true
7941
},
8042
tick: {
81-
visible: true,
43+
visible: false,
44+
length: 4,
8245
inside: false,
83-
alignWithLabel: true,
84-
length: 2,
8546
style: {
8647
lineWidth: 1,
87-
stroke: '#D9DDE4',
48+
stroke: '#21252C',
8849
strokeOpacity: 1
8950
},
9051
state: null
9152
},
9253
subTick: {
93-
visible: true,
94-
inside: false,
95-
count: 4,
54+
visible: false,
9655
length: 2,
9756
style: {
98-
lineWidth: 10,
57+
lineWidth: 1,
9958
stroke: '#D9DDE4',
10059
strokeOpacity: 1
10160
},
10261
state: null
10362
},
104-
line: {
105-
visible: true,
63+
grid: {
64+
type: 'line',
65+
visible: false,
10666
style: {
10767
lineWidth: 1,
108-
stroke: '#989999',
109-
strokeOpacity: 1
68+
stroke: '#E3E5EB',
69+
strokeOpacity: 1,
70+
lineDash: [4, 2]
71+
}
72+
},
73+
subGrid: {
74+
type: 'line',
75+
visible: false,
76+
style: {
77+
lineWidth: 1,
78+
stroke: '#EBEDF2',
79+
strokeOpacity: 1,
80+
lineDash: [4, 4]
81+
}
82+
},
83+
title: {
84+
visible: false,
85+
space: 10,
86+
autoRotate: false,
87+
angle: -1.5707963267948966,
88+
textStyle: {
89+
textAlign: 'center',
90+
textBaseline: 'bottom',
91+
fontSize: 12,
92+
fill: '#606773',
93+
fontWeight: 400,
94+
fillOpacity: 1
95+
},
96+
shape: {},
97+
background: {},
98+
state: {
99+
text: null,
100+
shape: null,
101+
background: null
110102
},
111-
startSymbol: {},
112-
endSymbol: {}
103+
text: 'order_date',
104+
maxWidth: null
105+
},
106+
panel: {
107+
state: null
108+
},
109+
labelHoverOnAxis: {
110+
visible: true
113111
},
114112
x: 140,
115113
y: 0,
@@ -124,55 +122,38 @@ const axis = new LineAxis({
124122
items: [
125123
[
126124
{
127-
id: '消费者',
128-
label: '消费者',
129-
value: 0.8333333333333334,
130-
rawValue: '消费者'
125+
id: '2016-01-01',
126+
label: '2016-01-01',
127+
value: 0.1308139534883721,
128+
rawValue: '2016-01-01'
129+
},
130+
{
131+
id: '2017-01-01',
132+
label: '2017-01-01',
133+
value: 0.37693798449612403,
134+
rawValue: '2017-01-01'
131135
},
132136
{
133-
id: '公司',
134-
label: '公司',
135-
value: 0.4999999999999999,
136-
rawValue: '公司'
137+
id: '2018-01-01',
138+
label: '2018-01-01',
139+
value: 0.623062015503876,
140+
rawValue: '2018-01-01'
137141
},
138142
{
139-
id: '小型企业',
140-
label: '小型企业',
141-
value: 0.1666666666666666,
142-
rawValue: '小型企业'
143+
id: '2019-01-01',
144+
label: '2019-',
145+
value: 0.8691860465116279,
146+
rawValue: '2019-01-01'
143147
}
144148
]
145149
],
146-
visible: true,
147-
pickable: true,
148-
orient: 'left',
149-
hover: true,
150-
select: true,
151-
panel: {
152-
visible: true,
153-
state: {
154-
// hover: {
155-
// fillOpacity: 0.08,
156-
// fill: 'red'
157-
// },
158-
selected: {
159-
fillOpacity: 0.08,
160-
fill: 'blue'
161-
},
162-
selected_reverse: {
163-
fillOpacity: 0.08,
164-
fill: 'red'
165-
}
166-
// hover_reverse: {
167-
// fillOpacity: 0.08,
168-
// fill: '#141414'
169-
// }
170-
}
171-
},
172-
verticalFactor: 1,
173-
verticalLimitSize: 150,
174-
verticalMinSize: 150
150+
verticalLimitSize: 66,
151+
verticalMinSize: 66,
152+
verticalFactor: 1
175153
});
176154
window.axis = axis;
177-
// axis.showLabelHoverOnAxis(130);
155+
debugger;
156+
setTimeout(() => {
157+
axis.showLabelHoverOnAxis(390, '2016-01-01');
158+
}, 100);
178159
render([axis], 'main');

0 commit comments

Comments
 (0)