@@ -47,7 +47,10 @@ import {
47
47
isDerivedSeries ,
48
48
} from '@superset-ui/chart-controls' ;
49
49
import type { EChartsCoreOption } from 'echarts/core' ;
50
- import type { LineStyleOption } from 'echarts/types/src/util/types' ;
50
+ import type {
51
+ LineStyleOption ,
52
+ CallbackDataParams ,
53
+ } from 'echarts/types/src/util/types' ;
51
54
import type { SeriesOption } from 'echarts' ;
52
55
import {
53
56
EchartsTimeseriesChartProps ,
@@ -575,16 +578,31 @@ export default function transformProps(
575
578
const xValue : number = richTooltip
576
579
? params [ 0 ] . value [ xIndex ]
577
580
: params . value [ xIndex ] ;
578
- const forecastValue : any [ ] = richTooltip ? params : [ params ] ;
581
+ const forecastValue : CallbackDataParams [ ] = richTooltip
582
+ ? params
583
+ : [ params ] ;
579
584
const sortedKeys = extractTooltipKeys (
580
585
forecastValue ,
581
586
yIndex ,
582
587
richTooltip ,
583
588
tooltipSortByMetric ,
584
589
) ;
590
+ const filteredForecastValue = forecastValue . filter (
591
+ ( item : CallbackDataParams ) =>
592
+ ! annotationLayers . some (
593
+ ( annotation : AnnotationLayer ) =>
594
+ item . seriesName === annotation . name ,
595
+ ) ,
596
+ ) ;
585
597
const forecastValues : Record < string , ForecastValue > =
586
598
extractForecastValuesFromTooltipParams ( forecastValue , isHorizontal ) ;
587
599
600
+ const filteredForecastValues : Record < string , ForecastValue > =
601
+ extractForecastValuesFromTooltipParams (
602
+ filteredForecastValue ,
603
+ isHorizontal ,
604
+ ) ;
605
+
588
606
const isForecast = Object . values ( forecastValues ) . some (
589
607
value =>
590
608
value . forecastTrend || value . forecastLower || value . forecastUpper ,
@@ -595,7 +613,7 @@ export default function transformProps(
595
613
: ( getCustomFormatter ( customFormatters , metrics ) ?? defaultFormatter ) ;
596
614
597
615
const rows : string [ ] [ ] = [ ] ;
598
- const total = Object . values ( forecastValues ) . reduce (
616
+ const total = Object . values ( filteredForecastValues ) . reduce (
599
617
( acc , value ) =>
600
618
value . observation !== undefined ? acc + value . observation : acc ,
601
619
0 ,
@@ -617,7 +635,16 @@ export default function transformProps(
617
635
seriesName : key ,
618
636
formatter,
619
637
} ) ;
620
- if ( showPercentage && value . observation !== undefined ) {
638
+
639
+ const annotationRow = annotationLayers . some (
640
+ item => item . name === key ,
641
+ ) ;
642
+
643
+ if (
644
+ showPercentage &&
645
+ value . observation !== undefined &&
646
+ ! annotationRow
647
+ ) {
621
648
row . push (
622
649
percentFormatter . format ( value . observation / ( total || 1 ) ) ,
623
650
) ;
0 commit comments