@@ -13,7 +13,7 @@ import { Params } from '../../core/adaptor';
13
13
import { Datum } from '../../types' ;
14
14
import { flow , deepAssign } from '../../utils' ;
15
15
import { findViewById } from '../../utils/view' ;
16
- import { isColumn , getYAxisWithDefault , getGeometryOption , transArrayToObject } from './util/option' ;
16
+ import { isColumn , getYAxisWithDefault , getGeometryOption , transformObjectToArray } from './util/option' ;
17
17
import { getViewLegendItems } from './util/legend' ;
18
18
import { drawSingleGeometry } from './util/geometry' ;
19
19
import { DualAxesOptions , AxisType , DualAxesGeometry } from './types' ;
@@ -72,14 +72,14 @@ export function transformOptions(params: Params<DualAxesOptions>): Params<DualAx
72
72
{
73
73
options : {
74
74
// yAxis
75
- yAxis : transArrayToObject ( yField , options . yAxis , 'yAxis should be object.' ) ,
75
+ yAxis : transformObjectToArray ( yField , options . yAxis ) ,
76
76
// geometryOptions
77
77
geometryOptions : [
78
78
getGeometryOption ( xField , yField [ 0 ] , geometryOptions [ 0 ] ) ,
79
79
getGeometryOption ( xField , yField [ 1 ] , geometryOptions [ 1 ] ) ,
80
80
] ,
81
81
// annotations
82
- annotations : transArrayToObject ( yField , options . annotations , 'annotations should be object.' ) ,
82
+ annotations : transformObjectToArray ( yField , options . annotations ) ,
83
83
} ,
84
84
}
85
85
) ;
@@ -180,12 +180,12 @@ export function meta(params: Params<DualAxesOptions>): Params<DualAxesOptions> {
180
180
181
181
scale ( {
182
182
[ xField ] : xAxis ,
183
- [ yField [ 0 ] ] : yAxis [ yField [ 0 ] ] ,
183
+ [ yField [ 0 ] ] : yAxis [ 0 ] ,
184
184
} ) ( deepAssign ( { } , params , { chart : findViewById ( chart , LEFT_AXES_VIEW ) } ) ) ;
185
185
186
186
scale ( {
187
187
[ xField ] : xAxis ,
188
- [ yField [ 1 ] ] : yAxis [ yField [ 1 ] ] ,
188
+ [ yField [ 1 ] ] : yAxis [ 1 ] ,
189
189
} ) ( deepAssign ( { } , params , { chart : findViewById ( chart , RIGHT_AXES_VIEW ) } ) ) ;
190
190
191
191
return params ;
@@ -207,11 +207,11 @@ export function axis(params: Params<DualAxesOptions>): Params<DualAxesOptions> {
207
207
208
208
// 左 View
209
209
leftView . axis ( xField , xAxis ) ;
210
- leftView . axis ( yField [ 0 ] , getYAxisWithDefault ( yAxis [ yField [ 0 ] ] , AxisType . Left ) ) ;
210
+ leftView . axis ( yField [ 0 ] , getYAxisWithDefault ( yAxis [ 0 ] , AxisType . Left ) ) ;
211
211
212
212
// 右 Y 轴
213
213
rightView . axis ( xField , false ) ;
214
- rightView . axis ( yField [ 1 ] , getYAxisWithDefault ( yAxis [ yField [ 1 ] ] , AxisType . Right ) ) ;
214
+ rightView . axis ( yField [ 1 ] , getYAxisWithDefault ( yAxis [ 1 ] , AxisType . Right ) ) ;
215
215
216
216
return params ;
217
217
}
@@ -257,21 +257,24 @@ export function interaction(params: Params<DualAxesOptions>): Params<DualAxesOpt
257
257
*/
258
258
export function annotation ( params : Params < DualAxesOptions > ) : Params < DualAxesOptions > {
259
259
const { chart, options } = params ;
260
- const { yField , annotations } = options ;
260
+ const { annotations } = options ;
261
261
262
- commonAnnotation ( get ( annotations , [ yField [ 0 ] ] ) ) (
262
+ const a1 = get ( annotations , [ 0 ] ) ;
263
+ const a2 = get ( annotations , [ 1 ] ) ;
264
+
265
+ commonAnnotation ( a1 ) (
263
266
deepAssign ( { } , params , {
264
267
chart : findViewById ( chart , LEFT_AXES_VIEW ) ,
265
268
options : {
266
- annotations : get ( annotations , [ yField [ 0 ] ] ) ,
269
+ annotations : a1 ,
267
270
} ,
268
271
} )
269
272
) ;
270
- commonAnnotation ( get ( annotations , [ yField [ 1 ] ] ) ) (
273
+ commonAnnotation ( a2 ) (
271
274
deepAssign ( { } , params , {
272
275
chart : findViewById ( chart , RIGHT_AXES_VIEW ) ,
273
276
options : {
274
- annotations : get ( annotations , [ yField [ 1 ] ] ) ,
277
+ annotations : a2 ,
275
278
} ,
276
279
} )
277
280
) ;
@@ -299,7 +302,7 @@ export function limitInPlot(params: Params<DualAxesOptions>): Params<DualAxesOpt
299
302
deepAssign ( { } , params , {
300
303
chart : findViewById ( chart , LEFT_AXES_VIEW ) ,
301
304
options : {
302
- yAxis : yAxis [ yField [ 0 ] ] ,
305
+ yAxis : yAxis [ 0 ] ,
303
306
} ,
304
307
} )
305
308
) ;
@@ -308,7 +311,7 @@ export function limitInPlot(params: Params<DualAxesOptions>): Params<DualAxesOpt
308
311
deepAssign ( { } , params , {
309
312
chart : findViewById ( chart , RIGHT_AXES_VIEW ) ,
310
313
options : {
311
- yAxis : yAxis [ yField [ 1 ] ] ,
314
+ yAxis : yAxis [ 1 ] ,
312
315
} ,
313
316
} )
314
317
) ;
0 commit comments