Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@mantine/charts]: Fix LineChart Legend and Tooltip to support nested names #6536

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

Sergio16T
Copy link
Contributor

@Sergio16T Sergio16T commented Jul 16, 2024

Fixes #6529
Relates to #5886

Update tooltip payload by unpacking item's not related to the nested name. Then unpack nested details into same object.

Updates getSeriesLabels to account for nested name.

Adds Unit Tests for displaying legend and tooltip label and data.

@@ -1,3 +1,4 @@
import _ from 'lodash';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mantine/charts package does not depend on lodash, this dependency cannot be used.

@@ -11,6 +24,82 @@ const defaultProps: LineChartProps = {
style: { width: 200, height: 200 },
};

const nestedData = [
{
date: 'Mar 22',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much data, it is not needed for tests, reduce it to 2 items per data array.

import { LineChart, LineChartProps, LineChartStylesNames } from './LineChart';

jest.mock('recharts', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required? Other tests work correctly without it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rtivital! Thank you for the PR review.

This mock enables LineChart to be rendered in the DOM. Without this mock we are not able to do assertions that elements are in the DOM and rendered correctly. Prior to this the unit tests did not assert that any elements were rendering correctly for LineChart.

Before tests.itSupportsSystemProps were asserting that system properties were supported and this particular test did not rely on LineChart mounting to be able to test elements rendering correctly.

@Sergio16T Sergio16T requested a review from rtivital August 7, 2024 05:01
@rtivital rtivital merged commit 8f5a15e into mantinedev:master Aug 7, 2024
1 check passed
@rtivital
Copy link
Member

rtivital commented Aug 7, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Graphs with nested values ignore "label" property
2 participants