@@ -2,7 +2,6 @@ import type {ReactNode} from 'react';
2
2
import { useState , useRef , Fragment } from 'react' ;
3
3
import {
4
4
uniqueId ,
5
- DataType ,
6
5
useYScale ,
7
6
LineSeries ,
8
7
COLOR_VISION_SINGLE_ITEM ,
@@ -17,7 +16,6 @@ import type {
17
16
XAxisOptions ,
18
17
YAxisOptions ,
19
18
LineChartDataSeriesWithDefaults ,
20
- BoundingRect ,
21
19
LabelFormatter ,
22
20
} from '@shopify/polaris-viz-core' ;
23
21
@@ -53,7 +51,10 @@ import {VisuallyHiddenRows} from '../VisuallyHiddenRows';
53
51
import { YAxis } from '../YAxis' ;
54
52
import { HorizontalGridLines } from '../HorizontalGridLines' ;
55
53
import { ChartElements } from '../ChartElements' ;
56
- import { TooltipWrapperNext } from '../../components/TooltipWrapper/TooltipWrapperNext' ;
54
+ import {
55
+ getTooltipDataAttr ,
56
+ TooltipWrapperNext ,
57
+ } from '../../components/TooltipWrapper' ;
57
58
58
59
import { useLineChartTooltipContent } from './hooks/useLineChartTooltipContent' ;
59
60
import { PointsAndCrosshair } from './components' ;
@@ -297,20 +298,23 @@ export function Chart({
297
298
} ) }
298
299
299
300
{ [ ...Array ( longestSeriesLength + 1 ) . keys ( ) ] . map ( ( _ , index ) => {
301
+ const x =
302
+ index * ( drawableWidth / longestSeriesLength ) -
303
+ drawableWidth / longestSeriesLength / 2 ;
304
+ const width = drawableWidth / longestSeriesLength ;
305
+
300
306
return (
301
307
< rect
302
308
key = { `${ index } -tooltip-area` }
309
+ { ...getTooltipDataAttr ( {
310
+ index,
311
+ x : containerBounds . x + chartXPosition + x + width ,
312
+ y : containerBounds . y + Number ( scrollY ) + chartYPosition ,
313
+ } ) }
303
314
height = { drawableHeight }
304
- width = { drawableWidth / longestSeriesLength }
305
- x = {
306
- index * ( drawableWidth / longestSeriesLength ) -
307
- drawableWidth / longestSeriesLength / 2
308
- }
315
+ width = { width }
316
+ x = { x }
309
317
fill = "rgba(255,0,0,0.2)"
310
- data-tooltip-type = "line"
311
- data-tooltip-index = { index }
312
- data-tooltip-x = { xScale ( index ) }
313
- data-tooltip-y = { yScale ( index ) }
314
318
/>
315
319
) ;
316
320
} ) }
@@ -384,7 +388,6 @@ export function Chart({
384
388
{ longestSeriesLength !== - 1 && (
385
389
< TooltipWrapperNext
386
390
chartType = { InternalChartType . Line }
387
- focusElementDataType = { DataType . Point }
388
391
getMarkup = { getTooltipMarkup }
389
392
id = { tooltipId . current }
390
393
onIndexChange = { ( index ) => {
0 commit comments