Skip to content

Update chartjs to latest (v4)#1013

Merged
ericboucher merged 14 commits intoaqualinkorg:masterfrom
yaodingyd:chartjs-issue
Sep 2, 2024
Merged

Update chartjs to latest (v4)#1013
ericboucher merged 14 commits intoaqualinkorg:masterfrom
yaodingyd:chartjs-issue

Conversation

@yaodingyd
Copy link
Copy Markdown
Collaborator

@yaodingyd yaodingyd commented Aug 23, 2024

fix #994
/claim #994

This is to update chartjs to latest V4 and related dependencies to latest. There are a lot breaking changes from V2 -> V4, includes:

  • plugin interface change: (custom) tooltip
  • plugin interface change: annotation registration
  • x axis time adapter usage, replace moment with date-fns
Screenshot 2024-08-28 at 10 38 40 PM

there are some remaining type issues (all of them are related to using any to avoid typecheck error) but it is in a good state to review

Copy link
Copy Markdown

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network for review. Expert reviewers are now being matched to your request based on the code's requirements. Stay tuned!

What to expect from this code review:
  • Comments posted to any areas of potential concern or improvement.
  • Detailed feedback or actions needed to resolve issues that are found.
  • Turnaround times vary, but we aim to be swift.

@yaodingyd you can click here to see the review status or cancel the code review job.

Copy link
Copy Markdown

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest Breakdown

Reviewable lines of change

+ 207
- 178

90% TSX
8% TypeScript
2% JSON

Generated lines of change

+ 29
- 35

Type of change

Feature - These changes are adding a new feature or improvement to existing code.

Copy link
Copy Markdown

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Looks great to me overall. It's always nice to see cleaning up of tech debt and staying on top of dependency updates. The only things I caught were relatively minor.

Image of Ryan Lester <@buu700> Ryan Lester <@buu700>


Reviewed with ❤️ by PullRequest

} from 'react';
import { Line } from 'react-chartjs-2';
import type { ChartTooltipModel } from 'chart.js';
// import { Line } from 'react-chartjs-2';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is the plan for these to be uncommented and added back, or can they be removed? It may be worth adding a TODO comment to clarify when they can be uncommented, as well as a comment to clarify why the types below were changed to any.

If it's just a temporary workaround for a third-party issue, you could temporarily include something like this:

// Temporarily defining these as `any` for XYZ reason
type Line = any;
type TooltipModel = any;

(Or alternatively, you could define the types to be more specific than any.)

Also, when/if the imports are uncommented, if only the type is needed for Line, you could use import type as with TooltipModel.

The same general questions and comments also apply to the commented imports in the other files.

🔹 Dead Code (Nice to have)

Image of Ryan Lester <@buu700> Ryan Lester <@buu700>

@ericboucher ericboucher marked this pull request as draft August 27, 2024 15:25
Copy link
Copy Markdown

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

This pull request would normally not be reviewed by PullRequest because the pull request is a draft; however since a review was already requested, it is currently being reviewed by the PullRequest network. If you would like to cancel it, you can do so manually from the PullRequest dashboard.

Copy link
Copy Markdown

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✖️ This code review was cancelled. See Details

@yaodingyd yaodingyd changed the title Update chartjs (WIP) Update chartjs to latest Aug 29, 2024
@yaodingyd yaodingyd marked this pull request as ready for review August 29, 2024 02:41
import { Line } from 'react-chartjs-2';
import 'chart.js/auto';
import { Tick } from 'chart.js';
import 'chartjs-adapter-date-fns';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like importing this like that is causing issues when running the tests.
We could try to import it in another file like you did for the annotation plugin, or maybe mock it during tests.

@ericboucher
Copy link
Copy Markdown
Member

@yaodingyd great work, thanks!

I noticed that we still have a "ghost" point when hovering on a survey. Eg. on site 3197. See the blue point over June 1st when hovering on the survey points.

Screenshot 2024-08-29 at 6 07 23 PM

@ericboucher ericboucher changed the title Update chartjs to latest Update chartjs to latest (v4) Aug 29, 2024
@yaodingyd
Copy link
Copy Markdown
Collaborator Author

@ericboucher can you take another look? I think the ghost hover issue is fixed

Screen.Recording.2024-08-31.at.10.45.47.PM.mov

Copy link
Copy Markdown
Member

@ericboucher ericboucher left a comment

Choose a reason for hiding this comment

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

Thanks @yaodingyd, great work!!

@ericboucher ericboucher merged commit 6b28375 into aqualinkorg:master Sep 2, 2024
@yaodingyd yaodingyd deleted the chartjs-issue branch November 9, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix ghost hover points and upgrade Chartjs

2 participants