Skip to content

Commit

Permalink
Fix percentile index for line chart relational
Browse files Browse the repository at this point in the history
  • Loading branch information
mollerjorge committed Jan 16, 2025
1 parent 1f18106 commit f5d61c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@ describe('<RelatedAreas />', () => {

expect(chart).toContainReactComponentTimes(Area, 2);
});

it('sets the Area index to the index of the first related percentile series', () => {
const chart = mount(
<svg>
<RelatedAreas {...MOCK_PROPS} />
</svg>,
);

expect(chart).toContainReactComponent(Area, {
index: 1,
});
});
});

0 comments on commit f5d61c1

Please sign in to comment.