File tree 2 files changed +21
-0
lines changed
__tests__/unit/plots/histogram
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,25 @@ describe('histogram', () => {
148
148
histogram . destroy ( ) ;
149
149
} ) ;
150
150
151
+ it ( '直方图 关闭 legend' , ( ) => {
152
+ const histogram = new Histogram ( createDiv ( 'legend * true' ) , {
153
+ width : 400 ,
154
+ height : 300 ,
155
+ appendPadding : 10 ,
156
+ data : histogramStackData ,
157
+ binField : 'value' ,
158
+ binWidth : 4 ,
159
+ legend : false ,
160
+ } ) ;
161
+
162
+ histogram . render ( ) ;
163
+
164
+ //@ts -ignore
165
+ expect ( histogram . chart . getController ( 'legend' ) . components . length ) . toEqual ( 0 ) ;
166
+
167
+ histogram . destroy ( ) ;
168
+ } ) ;
169
+
151
170
it ( 'stackField with color' , ( ) => {
152
171
const colors = [ 'red' , 'blue' ] ;
153
172
const histogram = new Histogram ( createDiv ( ) , {
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ function geometry(params: Params<HistogramOptions>): Params<HistogramOptions> {
39
39
// 图例
40
40
if ( legend && stackField ) {
41
41
chart . legend ( stackField , legend ) ;
42
+ } else {
43
+ chart . legend ( false ) ;
42
44
}
43
45
44
46
return params ;
You can’t perform that action at this time.
0 commit comments