File tree 2 files changed +42
-1
lines changed
2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { Pie } from '../../src' ;
2
+ import { createDiv } from '../utils/dom' ;
3
+
4
+ describe ( '#2096' , ( ) => {
5
+ const pie = new Pie ( createDiv ( ) , {
6
+ data : [
7
+ { type : '1' , value : 10 } ,
8
+ { type : '13' , value : 10 } ,
9
+ { type : '55' , value : 10 } ,
10
+ ] ,
11
+ angleField : 'value' ,
12
+ colorField : 'type' ,
13
+ radius : 0.8 ,
14
+ } ) ;
15
+
16
+ it ( 'normal' , ( ) => {
17
+ pie . render ( ) ;
18
+ expect ( pie . chart . interactions . tooltip ) . toBeDefined ( ) ;
19
+ } ) ;
20
+
21
+ it ( '开启中心文本交互时,默认关闭 tooltip' , ( ) => {
22
+ pie . update ( {
23
+ innerRadius : 0.64 ,
24
+ statistic : { } ,
25
+ interactions : [ { type : 'pie-statistic-active' } ] ,
26
+ } ) ;
27
+
28
+ expect ( pie . chart . interactions . tooltip ) . not . toBeDefined ( ) ;
29
+ } ) ;
30
+
31
+ it ( '开启中心文本交互时,需要显式注册 tooltip 交互来开启 tooltip' , ( ) => {
32
+ pie . update ( {
33
+ interactions : [ { type : 'pie-statistic-active' } , { type : 'tooltip' } ] ,
34
+ } ) ;
35
+ expect ( pie . chart . interactions . tooltip ) . toBeDefined ( ) ;
36
+ } ) ;
37
+ } ) ;
Original file line number Diff line number Diff line change @@ -64,7 +64,11 @@ describe('chord', () => {
64
64
) ;
65
65
66
66
// tooltip
67
- chord . chart . showTooltip ( { x : 500 , y : 100 } ) ;
67
+ const edgeView = chord . chart . views [ 0 ] ;
68
+ const edgeElementIdx = edgeView . getData ( ) . findIndex ( ( d ) => d . source === '北京' && d . target === '天津' ) ;
69
+ const element = edgeView . geometries [ 0 ] . elements [ edgeElementIdx ] ;
70
+ const path = element . shape . attr ( 'path' ) ;
71
+ chord . chart . showTooltip ( { x : path [ 0 ] [ 1 ] , y : path [ 0 ] [ 2 ] } ) ;
68
72
expect ( document . querySelector ( '.g2-tooltip-name' ) . textContent ) . toBe ( '北京 -> 天津' ) ;
69
73
expect ( document . querySelector ( '.g2-tooltip-value' ) . textContent ) . toBe ( '30' ) ;
70
74
You can’t perform that action at this time.
0 commit comments