@@ -107,45 +107,47 @@ describe('pie label', () => {
107
107
} ) ;
108
108
109
109
describe ( 'support template string formatter' , ( ) => {
110
- const pie = new Pie ( createDiv ( ) , {
111
- width : 400 ,
112
- height : 400 ,
113
- data : [
114
- { type : 'item1' , value : 1 } ,
115
- { type : 'item2' , value : 2 } ,
116
- { type : 'item3' , value : 2 } ,
117
- ] ,
118
- angleField : 'value' ,
119
- colorField : 'type' ,
120
- label : {
121
- content : '{name}: {value}' ,
122
- } ,
123
- } ) ;
110
+ it ( '' , ( ) => {
111
+ const pie = new Pie ( createDiv ( ) , {
112
+ width : 400 ,
113
+ height : 400 ,
114
+ data : [
115
+ { type : 'item1' , value : 1 } ,
116
+ { type : 'item2' , value : 2 } ,
117
+ { type : 'item3' , value : 2 } ,
118
+ ] ,
119
+ angleField : 'value' ,
120
+ colorField : 'type' ,
121
+ label : {
122
+ content : '{name}: {value}' ,
123
+ } ,
124
+ } ) ;
124
125
125
- pie . render ( ) ;
126
- let labels = pie . chart . geometries [ 0 ] . labelsContainer . getChildren ( ) ;
127
- expect ( ( labels [ 0 ] as IGroup ) . getChildren ( ) [ 0 ] . attr ( 'text' ) ) . toBe ( 'item1: 1' ) ;
128
-
129
- pie . update ( {
130
- ...pie . options ,
131
- label : {
132
- content : '{name}: {value}({percentage})' ,
133
- } ,
134
- } ) ;
135
- labels = pie . chart . geometries [ 0 ] . labelsContainer . getChildren ( ) ;
136
- // todo 暂时没有提供精度配置,直接粗暴返回
137
- expect ( ( labels [ 0 ] as IGroup ) . getChildren ( ) [ 0 ] . attr ( 'text' ) ) . toBe ( 'item1: 1(2...' ) ;
138
-
139
- // 移除 limit-in-plot ellipsis
140
- pie . update ( {
141
- ...pie . options ,
142
- label : {
143
- content : '{name}: {value}({percentage})' ,
144
- layout : [ ] ,
145
- } ,
146
- } ) ;
147
- labels = pie . chart . geometries [ 0 ] . labelsContainer . getChildren ( ) ;
148
- expect ( ( labels [ 0 ] as IGroup ) . getChildren ( ) [ 0 ] . attr ( 'text' ) ) . toBe ( 'item1: 1(20.00%)' ) ;
126
+ pie . render ( ) ;
127
+ let labels = pie . chart . geometries [ 0 ] . labelsContainer . getChildren ( ) ;
128
+ expect ( ( labels [ 0 ] as IGroup ) . getChildren ( ) [ 0 ] . attr ( 'text' ) ) . toBe ( 'item1: 1' ) ;
149
129
150
- pie . destroy ( ) ;
130
+ pie . update ( {
131
+ ...pie . options ,
132
+ label : {
133
+ content : '{name}: {value}({percentage})' ,
134
+ } ,
135
+ } ) ;
136
+ labels = pie . chart . geometries [ 0 ] . labelsContainer . getChildren ( ) ;
137
+ // todo 暂时没有提供精度配置,直接粗暴返回
138
+ expect ( ( labels [ 0 ] as IGroup ) . getChildren ( ) [ 0 ] . attr ( 'text' ) ) . toBe ( 'item1: 1(2...' ) ;
139
+
140
+ // 移除 limit-in-plot ellipsis
141
+ pie . update ( {
142
+ ...pie . options ,
143
+ label : {
144
+ content : '{name}: {value}({percentage})' ,
145
+ layout : [ ] ,
146
+ } ,
147
+ } ) ;
148
+ labels = pie . chart . geometries [ 0 ] . labelsContainer . getChildren ( ) ;
149
+ expect ( ( labels [ 0 ] as IGroup ) . getChildren ( ) [ 0 ] . attr ( 'text' ) ) . toBe ( 'item1: 1(20.00%)' ) ;
150
+
151
+ pie . destroy ( ) ;
152
+ } ) ;
151
153
} ) ;
0 commit comments