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

upcoming: [DI-21200] - Migration from ChartJS to Recharts in CloudPulse #11204

Merged
merged 45 commits into from
Nov 20, 2024

Conversation

nikhagra-akamai
Copy link
Contributor

@nikhagra-akamai nikhagra-akamai commented Nov 4, 2024

Description 📝

Migrated ChartJS to Recharts in CloudPulse.

Note: This PR is raised so that code changes can be reviewed & parallelly we are working on automation test cases which will eventually be added in this PR.

Changes 🔄

List any change relevant to the reviewer.

  1. Replaced LineGraph with AreaChart in CloudPulseLineGraph component.
  2. Updated x-axis ticks & chart variant in CloudPulseWidget
  3. Modified structure the of data passed to AreaChart component in CloudPulseWidgetUtils
  4. Removed CloudPulseColorPalette
  5. Modified legendColor property in metrics display to accept any color
  6. Added a connectNulls property in AreaChart component
  7. Added DataSet type in cloudpulse types

Target release date 🗓️

18th November

Preview 📷

Include a screenshot or screen recording of the change.

🔒 Use the Mask Sensitive Data setting for security.

💡 Use <video src="" /> tag when including recordings in table.

No Data Display
Screenshot 2024-11-04 at 1 41 57 PM
Screenshot 2024-11-04 at 1 42 10 PM

X-Axis with timestamp ticks for less than 24hrs
Screenshot 2024-11-04 at 1 42 22 PM
Screenshot 2024-11-04 at 1 42 30 PM

X-Axis with date & timestamp ticks for more than 24hrs
Screenshot 2024-11-04 at 1 42 57 PM
Screenshot 2024-11-04 at 1 43 16 PM

Legends rows
https://github.com/user-attachments/assets/bc8886ba-db7a-44ba-aa09-fea7d715bd22

Error State
Screenshot 2024-11-04 at 2 16 32 PM
Screenshot 2024-11-04 at 2 16 40 PM

How to test 🧪

  1. Switch to mock user
  2. Select mandatory filters to generate the graphs
  3. Change time duration filter to see difference in x-axis tick
  4. Modify data in serverHandlers.ts for monitor/services/:serviceType/metrics endpoint to playaround with graph & legends.
  5. You can see a scroll bar in legend rows table if more than 2 legends are present

As an Author I have considered 🤔

Check all that apply

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@nikhagra-akamai nikhagra-akamai self-assigned this Nov 4, 2024
@nikhagra-akamai nikhagra-akamai marked this pull request as ready for review November 4, 2024 14:22
@nikhagra-akamai nikhagra-akamai requested a review from a team as a code owner November 4, 2024 14:22
@nikhagra-akamai nikhagra-akamai requested review from hkhalil-akamai and abailly-akamai and removed request for a team November 4, 2024 14:22
@abailly-akamai
Copy link
Contributor

@nikhagra-akamai please address the e2e failures before we get to the review - thx!

@@ -47,7 +38,7 @@ export interface MetricsDisplayRow {
data: Metrics;
format: (n: number) => string;
handleLegendClick?: () => void;
legendColor: LegendColor;
legendColor: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks worse from a type safety perspective. Is this change necessary?

Copy link
Contributor Author

@nikhagra-akamai nikhagra-akamai Nov 5, 2024

Choose a reason for hiding this comment

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

yes it is already been discussed with @jaalah-akamai that instead of restricting to the 7 predefined colors, it should accept any color, so that legend rows greater than 7 won't collide with same color. Also, I don't think color has anything related to typesafety.

Comment on lines 136 to 139
export interface DataSet {
[label: string]: number;
timestamp: number;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Interfaces in the API SDK should correspond to responses from a particular endpoint. This definition may be more appropriately located in CloudPulseWidgetUtils.ts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, thanks

/**
* connect nulls value between two data points
*/
connectNulls? :boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
connectNulls? :boolean;
connectNulls?: boolean;

Copy link
Contributor Author

@nikhagra-akamai nikhagra-akamai Nov 5, 2024

Choose a reason for hiding this comment

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

updated, it was there in local changes but forgot to push. Thanks

legendRows={legendRows}
connectNulls
fillOpacity={0.5}
legendHeight={theme.spacing(18.75)}
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, the overflow in the legend is worse from a usability perspective -- I would prefer to be able to see all rows without a scroll bar.

Screenshot 2024-11-04 at 6 06 02 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also already been discussed. I understand your concern, but think for dynamically growing legend rows where number can cross 5. Bigger legend row table won't be look so good for UI and if two side by side graphs have different number of legend row count, then that mismatch in graph & legend height will make it look more worse. As in our case legends rows are dynamic & they can grow to 20.

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood, thanks for the context.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the latest revision, only two rows fit into the viewport at a time. Do we have any estimates on how many rows were expecting on average? If there are 5+ rows, why are we restricting the window to only show 2 instead of 4 or more?

Copy link

github-actions bot commented Nov 5, 2024

Coverage Report:
Base Coverage: 86.88%
Current Coverage: 86.9%

@nikhagra-akamai
Copy link
Contributor Author

nikhagra-akamai commented Nov 5, 2024

@nikhagra-akamai please address the e2e failures before we get to the review - thx!

@abailly-akamai This PR is raised so that code changes can be reviewed & parallelly we are working on automation test cases, which will eventually be added in this PR. Please let me know if automation is necessary for the review, I'll make it draft & open once automations are done. - Thx

@abailly-akamai
Copy link
Contributor

@nikhagra-akamai I am unsure what you meant, but this just can't be merged with failing tests no matter what cause everyone would inherit these failures

@nikhagra-akamai
Copy link
Contributor Author

@nikhagra-akamai I am unsure what you meant, but this just can't be merged with failing tests no matter what cause everyone would inherit these failures

I only meant that failure tests should not be blocking the PR review. By the time tests are being fixed ( that will be done within a day or 2 ), we can have review for our rest of the PR code.

@abailly-akamai
Copy link
Contributor

@nikhagra-akamai fixing the tests may affect the current code and we are trying to minimize the back and forth.

@nikhagra-akamai
Copy link
Contributor Author

nikhagra-akamai commented Nov 19, 2024

we now display the time in the legend, which makes it unreadable on mobile

thank you for highlighting. I've updated

Screen.Recording.2024-11-19.at.4.27.15.PM.mov

Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for strengthening the types )it will go a long way!) and addressing the mobile defects. This migration is important, appreciate the tedious work pushing this forward, charts are never easy 👍

Approving pending some extra cleanup on the data types.

@@ -39,7 +39,7 @@ export interface Widgets {
namespace_id: number;
color: string;
size: number;
chart_type: string;
chart_type: 'line' | 'area';
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you

@nikhagra-akamai
Copy link
Contributor Author

Thanks @abailly-akamai for the approval

Copy link
Contributor

@hkhalil-akamai hkhalil-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for responding to feedback!

@hkhalil-akamai hkhalil-akamai added Approved Multiple approvals and ready to merge! and removed Requires Changes labels Nov 19, 2024
@nikhagra-akamai
Copy link
Contributor Author

nikhagra-akamai commented Nov 20, 2024

thanks @abailly-akamai @hkhalil-akamai for the approvals

couple of updates from the last few comments

  1. Renamed the filename MetricDisplay.styles.ts to MetricsDisplay.styles.ts
  2. Added a DataSet interface in AreaChart component & used the same for type safety in generate12HoursTick function
  3. Added more detailed documentation for xAxisTickCount property

if all good, lets merge the PR

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 453 passing tests on test run #23 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing453 Passing2 Skipped94m 24s

@jaalah-akamai jaalah-akamai merged commit 6c15fbd into linode:develop Nov 20, 2024
23 checks passed
Copy link

cypress bot commented Nov 20, 2024

Cloud Manager E2E    Run #6855

Run Properties:  status check passed Passed #6855  •  git commit 6c15fbd1c7: upcoming: [DI-21200] - Migration from ChartJS to Recharts in CloudPulse (#11204)
Project Cloud Manager E2E
Branch Review develop
Run status status check passed Passed #6855
Run duration 26m 58s
Commit git commit 6c15fbd1c7: upcoming: [DI-21200] - Migration from ChartJS to Recharts in CloudPulse (#11204)
Committer Nikhil Agrawal
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 453
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! CloudPulse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants