Skip to content

Commit cdbfbd9

Browse files
committed
Broken
1 parent a648037 commit cdbfbd9

File tree

11 files changed

+374
-105
lines changed

11 files changed

+374
-105
lines changed

Diff for: packages/polaris-viz-core/src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ export enum InternalChartType {
316316
HorizontalBar = 'HorizontalBar',
317317
Combo = 'Combo',
318318
Line = 'Line',
319+
Donut = 'Donut',
319320
}
320321

321322
export enum Hue {

Diff for: packages/polaris-viz-core/src/utilities/getColorVisionEventAttrs.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ export function getColorVisionEventAttrs({type, index, watch = true}: Props) {
1111
[`${COLOR_VISION_EVENT.dataAttribute}-watch`]: watch,
1212
[`${COLOR_VISION_EVENT.dataAttribute}-type`]: type,
1313
[`${COLOR_VISION_EVENT.dataAttribute}-index`]: index,
14+
['data-tooltip-type']: 'blah',
1415
};
1516
}

Diff for: packages/polaris-viz/src/components/Arc/Arc.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export function Arc({
140140
height={radius * 4}
141141
width={radius * 4}
142142
gradient={gradient}
143+
index={index}
143144
/>
144145
</g>
145146
</Fragment>

Diff for: packages/polaris-viz/src/components/ConicGradientWithStops/ConicGradientWithStops.tsx

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {GradientStop} from '@shopify/polaris-viz-core';
2+
import {Fragment} from 'react';
23

34
import {createCSSConicGradient} from '../../utilities';
45

@@ -16,18 +17,30 @@ export function ConicGradientWithStops({
1617
width,
1718
x = 0,
1819
y = 0,
20+
index,
1921
}: ConicGradientWithStopsProps) {
2022
const conicGradientValue = createCSSConicGradient(gradient);
2123

2224
return (
23-
<foreignObject x={x} y={y} width={width} height={height}>
24-
<div
25-
style={{
26-
width: `${width}px`,
27-
height: `${height}px`,
28-
backgroundImage: conicGradientValue,
29-
}}
25+
<Fragment>
26+
<foreignObject x={x} y={y} width={width} height={height}>
27+
<div
28+
style={{
29+
width: `${width}px`,
30+
height: `${height}px`,
31+
backgroundImage: conicGradientValue,
32+
}}
33+
/>
34+
</foreignObject>
35+
<rect
36+
data-tooltip-type="donut"
37+
data-tooltip-index={index}
38+
width={width}
39+
height={height}
40+
x={x}
41+
y={y}
42+
fill="transparent"
3043
/>
31-
</foreignObject>
44+
</Fragment>
3245
);
3346
}

Diff for: packages/polaris-viz/src/components/DonutChart/Chart.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
useChartContext,
1010
THIN_ARC_CORNER_THICKNESS,
1111
isInfinity,
12+
InternalChartType,
13+
DataType,
1214
} from '@shopify/polaris-viz-core';
1315
import type {
1416
DataPoint,
@@ -17,6 +19,7 @@ import type {
1719
Direction,
1820
} from '@shopify/polaris-viz-core';
1921

22+
import {TooltipWrapperNext} from '../../components/TooltipWrapper/TooltipWrapperNext';
2023
import {getAnimationDelayForItems} from '../../utilities/getAnimationDelayForItems';
2124
import {getContainerAlignmentForLegend} from '../../utilities';
2225
import type {ComparisonMetricProps} from '../ComparisonMetric';
@@ -84,6 +87,7 @@ export function Chart({
8487
const chartId = useUniqueId('Donut');
8588
const [activeIndex, setActiveIndex] = useState<number>(-1);
8689
const selectedTheme = useTheme();
90+
const [svgRef, setSvgRef] = useState<SVGSVGElement | null>(null);
8791

8892
const seriesCount = clamp({
8993
amount: data.length,
@@ -208,6 +212,7 @@ export function Chart({
208212
viewBox={`${minX} ${minY} ${viewBoxDimensions.width} ${viewBoxDimensions.height}`}
209213
height={diameter}
210214
width={diameter}
215+
ref={setSvgRef}
211216
>
212217
{isLegendMounted && (
213218
<g className={styles.DonutChart}>
@@ -300,6 +305,14 @@ export function Chart({
300305
}
301306
/>
302307
)}
308+
<TooltipWrapperNext
309+
chartType={InternalChartType.Donut}
310+
focusElementDataType={DataType.Point}
311+
getMarkup={(index) => {
312+
return <div>Tooltip {index}</div>;
313+
}}
314+
parentElement={svgRef}
315+
/>
303316
</div>
304317
);
305318
}

Diff for: packages/polaris-viz/src/components/LineChart/Chart.tsx

+22-8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import {VisuallyHiddenRows} from '../VisuallyHiddenRows';
5555
import {YAxis} from '../YAxis';
5656
import {HorizontalGridLines} from '../HorizontalGridLines';
5757
import {ChartElements} from '../ChartElements';
58+
import {TooltipWrapperNext} from '../../components/TooltipWrapper/TooltipWrapperNext';
5859

5960
import {useLineChartTooltipContent} from './hooks/useLineChartTooltipContent';
6061
import {PointsAndCrosshair} from './components';
@@ -242,6 +243,8 @@ export function Chart({
242243

243244
const halfXAxisLabelWidth = xAxisDetails.labelWidth / 2;
244245

246+
console.log({longestSeriesLength});
247+
245248
return (
246249
<Fragment>
247250
<ChartElements.Svg
@@ -304,6 +307,24 @@ export function Chart({
304307
theme,
305308
})}
306309

310+
{[...Array(longestSeriesLength).keys()].map((series, index) => {
311+
return (
312+
<rect
313+
height={drawableHeight}
314+
width={drawableWidth / longestSeriesLength}
315+
x={
316+
index * (drawableWidth / longestSeriesLength) -
317+
drawableWidth / longestSeriesLength / 2
318+
}
319+
fill="rgba(255,0,0,0.2)"
320+
data-tooltip-type="line"
321+
data-tooltip-index={index}
322+
data-tooltip-x={xScale(index)}
323+
data-tooltip-y={yScale(index)}
324+
/>
325+
);
326+
})}
327+
307328
{data.map((singleSeries, index) => {
308329
if (singleSeries.metadata?.isVisuallyHidden === true) {
309330
return null;
@@ -371,15 +392,11 @@ export function Chart({
371392
</ChartElements.Svg>
372393

373394
{longestSeriesLength !== -1 && (
374-
<TooltipWrapper
375-
chartBounds={chartBounds}
395+
<TooltipWrapperNext
376396
chartType={InternalChartType.Line}
377397
focusElementDataType={DataType.Point}
378398
getMarkup={getTooltipMarkup}
379-
data={data}
380-
longestSeriesIndex={longestSeriesIndex}
381399
id={tooltipId.current}
382-
margin={ChartMargin}
383400
onIndexChange={(index) => {
384401
if (index != null && isPerformanceImpacted) {
385402
moveCrosshair(index);
@@ -388,9 +405,6 @@ export function Chart({
388405
}
389406
}}
390407
parentElement={svgRef}
391-
usePortal
392-
xScale={xScale}
393-
yScale={yScale}
394408
/>
395409
)}
396410

0 commit comments

Comments
 (0)