diff --git a/packages/polaris-viz/CHANGELOG.md b/packages/polaris-viz/CHANGELOG.md
index 0f886691d..9ba430475 100644
--- a/packages/polaris-viz/CHANGELOG.md
+++ b/packages/polaris-viz/CHANGELOG.md
@@ -7,6 +7,10 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased
+### Fixed
+
+- Fixed issue in `` where the `percentileIndex` was not being set correctly.
+
### Added
- Added Tooltips to ``
diff --git a/packages/polaris-viz/src/components/LineChartRelational/components/RelatedAreas/RelatedAreas.tsx b/packages/polaris-viz/src/components/LineChartRelational/components/RelatedAreas/RelatedAreas.tsx
index c4c35ee15..3e5c933c9 100644
--- a/packages/polaris-viz/src/components/LineChartRelational/components/RelatedAreas/RelatedAreas.tsx
+++ b/packages/polaris-viz/src/components/LineChartRelational/components/RelatedAreas/RelatedAreas.tsx
@@ -15,12 +15,10 @@ export interface RelatedAreaProps extends LineChartSlotProps {
export function RelatedAreas({yScale, xScale, data}: RelatedAreaProps) {
const [activeIndex, setActiveIndex] = useState(-1);
- const lineSeries = data.filter(
- (series) => series?.metadata?.relatedIndex == null,
+ const percentileIndex = data.findIndex(
+ (series) => series.metadata?.relatedIndex != null,
);
- const percentileIndex = lineSeries.length + 1;
-
const {hiddenIndexes} = useExternalHideEvents();
const {id} = useChartContext();
diff --git a/packages/polaris-viz/src/components/LineChartRelational/components/RelatedAreas/tests/RelatedAreas.test.tsx b/packages/polaris-viz/src/components/LineChartRelational/components/RelatedAreas/tests/RelatedAreas.test.tsx
index b7b31193d..77c0b752b 100644
--- a/packages/polaris-viz/src/components/LineChartRelational/components/RelatedAreas/tests/RelatedAreas.test.tsx
+++ b/packages/polaris-viz/src/components/LineChartRelational/components/RelatedAreas/tests/RelatedAreas.test.tsx
@@ -60,4 +60,16 @@ describe('', () => {
expect(chart).toContainReactComponentTimes(Area, 2);
});
+
+ it('sets the Area index to the index of the first related percentile series', () => {
+ const chart = mount(
+ ,
+ );
+
+ expect(chart).toContainReactComponent(Area, {
+ index: 1,
+ });
+ });
});