@@ -41,6 +41,14 @@ function facetAdaptor(params: Params<FacetOptions>): Params<FacetOptions> {
4141 } else {
4242 const plot = viewOptions as IPlot ;
4343 const plotOptions = plot . options ;
44+
45+ // 如果 view 内部没有指定映射字段,则使用 options 内指定的映射字段
46+ [ 'seriesField' , 'colorField' , 'shapeField' , 'sizeField' , 'groupField' ] . forEach ( ( key ) => {
47+ if ( options [ key ] && typeof plotOptions [ key ] === 'undefined' ) {
48+ plotOptions [ key ] = options [ key ] ;
49+ }
50+ } ) ;
51+
4452 // @ts -ignore 仪表盘没 tooltip
4553 if ( plotOptions . tooltip ) {
4654 // 配置 tooltip 交互
@@ -56,7 +64,20 @@ function facetAdaptor(params: Params<FacetOptions>): Params<FacetOptions> {
5664
5765function component ( params : Params < FacetOptions > ) : Params < FacetOptions > {
5866 const { chart, options } = params ;
59- const { axes, meta, tooltip, coordinate, theme, legend, interactions, annotations } = options ;
67+ const {
68+ axes,
69+ meta,
70+ tooltip,
71+ coordinate,
72+ theme,
73+ legend,
74+ interactions,
75+ annotations,
76+ shapeField,
77+ sizeField,
78+ shapeLegend,
79+ sizeLegend,
80+ } = options ;
6081
6182 // 3. meta 配置
6283 let scales : Record < string , any > = { } ;
@@ -91,6 +112,17 @@ function component(params: Params<FacetOptions>): Params<FacetOptions> {
91112
92113 // 7. legend 配置(默认展示)
93114 chart . legend ( legend ) ;
115+ if ( shapeField ) {
116+ chart . legend ( shapeField , shapeLegend ? shapeLegend : false ) ;
117+ }
118+
119+ if ( sizeField ) {
120+ chart . legend ( sizeField , sizeLegend ? sizeLegend : false ) ;
121+ }
122+ // /** 默认不展示 shape 图例,当 shapeLegend 为 undefined 也不展示图例 */
123+ if ( ! legend && ! shapeLegend && ! sizeLegend ) {
124+ chart . legend ( false ) ;
125+ }
94126
95127 // theme 配置
96128 if ( theme ) {
0 commit comments