@@ -184,7 +184,7 @@ class RadarView extends ChartView {
184
184
const symbolGroup = itemGroup . childAt ( 2 ) as graphic . Group ;
185
185
// Radar uses the visual encoded from itemStyle.
186
186
const itemStyle = data . getItemVisual ( idx , 'style' ) ;
187
- const color = itemStyle . fill as ColorString ;
187
+ const color = itemStyle . fill ;
188
188
189
189
group . add ( itemGroup ) ;
190
190
@@ -211,83 +211,65 @@ class RadarView extends ChartView {
211
211
const stateIgnore = stateModel . isEmpty ( ) && stateModel . parentModel . isEmpty ( ) ;
212
212
// Won't be ignore if normal state is not ignore.
213
213
polygon . ensureState ( stateName ) . ignore = stateIgnore && polygonIgnore ;
214
+ const lineStyle = itemModel . getModel ( [ stateName , 'lineStyle' ] ) . getLineStyle ( ) ;
215
+ polyline . ensureState ( stateName ) . style = lineStyle ;
216
+ const areaStyle = stateModel . getAreaStyle ( ) ;
217
+ polygon . ensureState ( stateName ) . style = areaStyle ;
218
+ const itemStateStyle = itemModel . getModel ( [ stateName , 'itemStyle' ] ) . getItemStyle ( ) ;
219
+ symbolGroup . eachChild ( function ( symbolPath : RadarSymbol ) {
220
+ symbolPath . ensureState ( stateName ) . style = zrUtil . clone ( itemStateStyle ) ;
221
+ } ) ;
214
222
} ) ;
215
223
216
224
polygon . useStyle (
217
225
zrUtil . defaults (
218
226
itemModel . getModel ( 'areaStyle' ) . getAreaStyle ( ) ,
219
227
{
220
228
fill : color ,
229
+ opacity : 0.7 ,
221
230
decal : itemStyle . decal
222
231
}
223
232
)
224
233
) ;
225
- symbolGroup . eachChild ( function ( symbolPath : RadarSymbol ) {
234
+ const emphasisModel = itemModel . getModel ( 'emphasis' ) ;
235
+ const itemHoverStyle = emphasisModel . getModel ( 'itemStyle' ) . getItemStyle ( ) ;
236
+ symbolGroup . eachChild ( function ( symbolPath : RadarSymbol ) {
226
237
if ( symbolPath instanceof ZRImage ) {
227
- const ps = symbolPath . style
228
- symbolPath . useStyle (
229
- zrUtil . extend (
230
- {
231
- image : ps . image ,
232
- x : ps . x ,
233
- y : ps . y ,
234
- width : ps . width ,
235
- height : ps . height ,
236
- } ,
237
- itemStyle ,
238
- ) ,
239
- )
240
- } else {
241
- symbolPath . useStyle ( itemStyle )
242
- symbolPath . setColor ( color )
243
- symbolPath . style . strokeNoScale = true
238
+ const pathStyle = symbolPath . style ;
239
+ symbolPath . useStyle ( zrUtil . extend ( {
240
+ // TODO other properties like x, y ?
241
+ image : pathStyle . image ,
242
+ x : pathStyle . x , y : pathStyle . y ,
243
+ width : pathStyle . width , height : pathStyle . height
244
+ } , itemStyle ) ) ;
244
245
}
245
- const emphasisModel = itemModel . getModel ( 'emphasis' )
246
- const hoverStyle = emphasisModel . getModel ( 'itemStyle' ) . getItemStyle ( )
247
- symbolPath . ensureState ( 'emphasis' ) . style = zrUtil . clone ( hoverStyle )
248
- let txt = data . getStore ( ) . get ( data . getDimensionIndex ( symbolPath . __dimIdx ) , idx )
249
- if ( txt == null || isNaN ( txt as number ) ) {
250
- txt = ''
246
+ else {
247
+ symbolPath . useStyle ( itemStyle ) ;
248
+ symbolPath . setColor ( color ) ;
249
+ symbolPath . style . strokeNoScale = true ;
251
250
}
251
+
252
+ const pathEmphasisState = symbolPath . ensureState ( 'emphasis' ) ;
253
+ pathEmphasisState . style = zrUtil . clone ( itemHoverStyle ) ;
254
+ let defaultText = data . getStore ( ) . get ( data . getDimensionIndex ( symbolPath . __dimIdx ) , idx ) ;
255
+ ( defaultText == null || isNaN ( defaultText as number ) ) && ( defaultText = '' ) ;
256
+
252
257
setLabelStyle (
253
258
symbolPath , getLabelStatesModels ( itemModel ) ,
254
259
{
255
260
labelFetcher : data . hostModel ,
256
261
labelDataIndex : idx ,
257
262
labelDimIndex : symbolPath . __dimIdx ,
258
- defaultText : txt as string ,
259
- inheritColor : color ,
260
- defaultOpacity : itemStyle . opacity ,
263
+ defaultText : defaultText as string ,
264
+ inheritColor : color as ColorString ,
265
+ defaultOpacity : itemStyle . opacity
261
266
}
262
- )
263
- } )
264
-
265
- function bindStateStyles ( state : 'emphasis' | 'select' | 'blur' ) {
266
- const ls = itemModel . getModel ( [ state , 'lineStyle' ] ) . getLineStyle ( )
267
-
268
- const as_ = itemModel . getModel ( [ state , 'areaStyle' ] ) . getAreaStyle ( )
269
-
270
- const is_ = itemModel . getModel ( [ state , 'itemStyle' ] ) . getItemStyle ( )
271
-
272
- polyline . ensureState ( state ) . style = ls
273
- polygon . ensureState ( state ) . style = as_
274
- symbolGroup . eachChild ( function ( symbolPath : RadarSymbol ) {
275
- symbolPath . ensureState ( state ) . style = zrUtil . clone ( is_ )
276
- } )
277
- }
278
-
279
- bindStateStyles ( 'emphasis' )
280
- bindStateStyles ( 'select' )
281
- bindStateStyles ( 'blur' )
282
-
283
- const emphasisModel = itemModel . getModel ( 'emphasis' )
267
+ ) ;
268
+ } ) ;
284
269
285
270
toggleHoverEmphasis (
286
- itemGroup ,
287
- emphasisModel . get ( 'focus' ) ,
288
- emphasisModel . get ( 'blurScope' ) ,
289
- emphasisModel . get ( 'disabled' ) ,
290
- )
271
+ itemGroup , emphasisModel . get ( 'focus' ) , emphasisModel . get ( 'blurScope' ) , emphasisModel . get ( 'disabled' )
272
+ ) ;
291
273
} ) ;
292
274
293
275
this . _data = data ;
0 commit comments