@@ -11,7 +11,7 @@ import type { IComponentMark, ILabelMark } from '../../mark/interface';
1111import { MarkTypeEnum } from '../../mark/interface/type' ;
1212import { mergeSpec } from '@visactor/vutils-extension' ;
1313import { eachSeries } from '../../util/model' ;
14- import type { ISeries } from '../../series/interface' ;
14+ import type { ISeries , SeriesMarkNameEnum } from '../../series/interface' ;
1515import type { IGroupMark , ILabel , IMark as IVGrammarMark } from '@visactor/vgrammar-core' ;
1616// eslint-disable-next-line no-duplicate-imports
1717import { registerLabel as registerVGrammarLabel } from '@visactor/vgrammar-core' ;
@@ -29,6 +29,7 @@ import { registerLabelMark } from '../../mark/label';
2929import type { IChartSpecInfo } from '../../chart/interface' ;
3030import type { IChartSpec } from '../../typings' ;
3131import { LabelSpecTransformer } from './label-transformer' ;
32+ import type { IGraphic } from '@visactor/vrender-core' ;
3233
3334export class Label < T extends IChartSpec = any > extends BaseLabelComponent < T > {
3435 static type = ComponentTypeEnum . label ;
@@ -141,7 +142,7 @@ export class Label<T extends IChartSpec = any> extends BaseLabelComponent<T> {
141142 if ( ! mark ) {
142143 continue ;
143144 }
144- markLabelSpec [ markName ] . forEach ( ( spec : TransformedLabelSpec , index : number ) => {
145+ markLabelSpec [ markName as SeriesMarkNameEnum ] . forEach ( ( spec : TransformedLabelSpec , index : number ) => {
145146 if ( spec . visible ) {
146147 const info = this . _labelInfoMap . get ( region ) ;
147148 const labelMark = this . _createMark (
@@ -151,6 +152,9 @@ export class Label<T extends IChartSpec = any> extends BaseLabelComponent<T> {
151152 } ,
152153 { noSeparateStyle : true , attributeContext : series . getMarkAttributeContext ( ) }
153154 ) as ILabelMark ;
155+ if ( spec . showRelatedMarkTooltip ) {
156+ series . tooltipHelper ?. activeTriggerSet . mark ?. add ( labelMark ) ;
157+ }
154158 labelMark . setTarget ( mark ) ;
155159 info . push ( {
156160 labelMark,
@@ -353,14 +357,30 @@ export class Label<T extends IChartSpec = any> extends BaseLabelComponent<T> {
353357
354358 getVRenderComponents ( ) {
355359 const labels : any [ ] = [ ] ;
356- this . _labelComponentMap . forEach ( ( info , component ) => {
360+ this . _labelComponentMap . forEach ( ( infoFunc , component ) => {
357361 const graphicItem = component . getProduct ( ) . getGroupGraphicItem ( ) ;
358362 if ( graphicItem ) {
359363 labels . push ( graphicItem ) ;
360364 }
361365 } ) ;
362366 return labels ;
363367 }
368+
369+ getLabelInfoByTextGraphic ( text : IGraphic ) : ILabelInfo {
370+ let labelInfo : ILabelInfo ;
371+ const vrenderLabel = text ?. parent ;
372+ const vrenderDataLabel = vrenderLabel ?. parent ;
373+ if ( vrenderDataLabel ) {
374+ const labelIndex = vrenderDataLabel . getChildren ( ) . indexOf ( vrenderLabel as any ) ;
375+ this . _labelComponentMap . forEach ( ( infoFunc , component ) => {
376+ const graphicItem = component . getProduct ( ) . getGroupGraphicItem ( ) ;
377+ if ( graphicItem === vrenderDataLabel ) {
378+ labelInfo = array ( infoFunc ( ) ) [ labelIndex ] ;
379+ }
380+ } ) ;
381+ }
382+ return labelInfo ;
383+ }
364384}
365385
366386export const registerLabel = ( ) => {
0 commit comments