@@ -20,6 +20,7 @@ import type { CompilerListenerParameters } from '../compile/interface';
2020import type { Compiler } from '../compile/compiler' ;
2121import type { StringOrNumber } from '../typings' ;
2222import type { IElement } from '@visactor/vgrammar-core' ;
23+ import type { IComponent } from '../component/interface' ;
2324import { Factory as VGrammarFactory } from '@visactor/vgrammar-core' ;
2425
2526const componentTypeMap : Record < string , string > = {
@@ -301,11 +302,18 @@ export class EventDispatcher implements IEventDispatcher {
301302 targetMark = targetMark . group ;
302303 }
303304
305+ const node = get ( listenerParams . event , 'target' ) ;
306+
307+ let datum = listenerParams . datum ;
308+ if ( model && model . modelType === 'component' ) {
309+ datum = ( model as IComponent ) . getDatum ( node ) ?? datum ;
310+ }
311+
304312 const params : BaseEventParams = {
305313 event : listenerParams . event ,
306314 item : listenerParams . item ,
307- datum : listenerParams . datum ,
308315 source : listenerParams . source ,
316+ datum,
309317 itemMap,
310318 chart,
311319 model,
@@ -326,7 +334,6 @@ export class EventDispatcher implements IEventDispatcher {
326334 if ( ( event as any ) . elements ) {
327335 items = ( event as any ) . elements ;
328336 }
329-
330337 const params : InteractionEventParam = {
331338 event : listenerParams . event ,
332339 chart,
0 commit comments