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

✨ (dashboards) piecharts - sorting and label spacing #3855

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

MatissJanis
Copy link
Member

Two changes:

  1. the piechart data will now be sorted (from biggest balance to smallest);
  2. slightly increased the spacing between the labels in the piechart (for mobile & dashboard page) - to give it a bit more breathing room and so it wouldn't intersect with the piechart itself

@actual-github-bot actual-github-bot bot changed the title ✨ (dashboards) piecharts - sorting and label spacing [WIP] ✨ (dashboards) piecharts - sorting and label spacing Nov 19, 2024
Copy link

netlify bot commented Nov 19, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 8202aa5
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/673cf52b76843e00082ef012
😎 Deploy Preview https://deploy-preview-3855.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Nov 19, 2024

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
9 5.43 MB → 5.43 MB (+170 B) +0.00%
Changeset
File Δ Size
src/components/reports/graphs/DonutGraph.tsx 📈 +170 B (+2.27%) 7.33 kB → 7.49 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/ReportRouter.js 1.49 MB → 1.49 MB (+170 B) +0.01%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/AppliedFilters.js 21.3 kB 0%
static/js/narrow.js 82.68 kB 0%
static/js/wide.js 242.81 kB 0%
static/js/index.js 3.44 MB 0%

Copy link
Contributor

github-actions bot commented Nov 19, 2024

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.32 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.32 MB 0%

@MatissJanis
Copy link
Member Author

/update-vrt

@MatissJanis MatissJanis changed the title [WIP] ✨ (dashboards) piecharts - sorting and label spacing ✨ (dashboards) piecharts - sorting and label spacing Nov 19, 2024
Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

Walkthrough

The pull request introduces modifications to the DonutGraph component in DonutGraph.tsx. The getVal function's parameter type has been explicitly defined as DataEntity, enhancing type safety. A new variable, sortedData, has been introduced to sort the unsortedData based on the getVal function, replacing the previous direct reference to data[splitData] in the rendering logic. The pie chart now utilizes sortedData as its data source. Additionally, the Pie component has been updated to include startAngle and endAngle properties, which adjust the orientation of the pie chart. Minor adjustments have also been made to the positioning of text elements within the ActiveShapeMobile and ActiveShape components, specifically changing the x attributes of certain <text> elements to improve layout consistency.

Suggested labels

sparkles: Merged

Suggested reviewers

  • youngcw

Warning

Rate limit exceeded

@MatissJanis has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 36 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 193ee8a and 8202aa5.

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-eslint-plugin".

(The package "eslint-plugin-eslint-plugin" was not found when loaded as a Node module from the directory "/packages/eslint-plugin-actual".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-eslint-plugin@latest --save-dev

The plugin "eslint-plugin-eslint-plugin" was referenced from the config file in "packages/eslint-plugin-actual/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 193ee8a and 8202aa5.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx (5 hunks)
🔇 Additional comments (4)
packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx (4)

43-43: LGTM: Label spacing improvements

The adjustments to text element positioning in ActiveShapeMobile component improve label spacing and prevent overlap, particularly beneficial for mobile view.

Also applies to: 47-47, 50-50


Line range hint 214-219: LGTM: Enhanced type safety

Adding the DataEntity type annotation to the getVal function parameter improves type safety and code maintainability.


224-226: LGTM: Correct sorting implementation

The sorting implementation:

  • Uses browser-compatible slice().sort() method
  • Correctly sorts in descending order (largest to smallest)
  • Properly handles debt values through the getVal function

251-251: LGTM: Improved chart orientation

The addition of startAngle and endAngle properties ensures consistent clockwise orientation of the pie chart, enhancing readability. The chart now correctly uses the sorted data for rendering.

Also applies to: 258-259


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx (1)

1-2: Consider enabling TypeScript strict mode

The file has strict TypeScript checking disabled with // @ts-strict-ignore. Consider gradually enabling strict mode to improve type safety and catch potential issues at compile time.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b4d2d6a and 3b46602.

⛔ Files ignored due to path filters (4)
  • packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-3-chromium-linux.png is excluded by !**/*.png
  • upcoming-release-notes/3855.md is excluded by !**/*.md
📒 Files selected for processing (1)
  • packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx (6 hunks)
🔇 Additional comments (4)
packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx (4)

43-52: Improved label spacing in mobile view

The adjustments to text element positioning improve the layout by:

  • Centering the main label
  • Separating the amount and percentage with consistent spacing
  • Using proper text anchoring for alignment

This change aligns well with the PR objective to improve label spacing.


Line range hint 214-220: LGTM: Improved type safety

Adding type annotation to getVal function improves type safety and code maintainability.


226-228: Good use of useMemo for performance optimization

The implementation correctly uses useMemo to cache the sorted data, preventing unnecessary re-sorting on every render. The dependency array properly includes both unsortedData and balanceTypeOp.


260-261: Verify the impact of angle adjustments

The addition of startAngle and endAngle properties changes the chart's orientation. While this might help with label positioning, we should ensure it doesn't affect the user experience negatively.

Let's check for any related visual regression tests:

✅ Verification successful

Angle adjustments are safe and intentional

The angle adjustments (startAngle: 90, endAngle: -270) are safe and appropriate for the following reasons:

  • These values create a standard donut chart orientation starting from the top (90°) and going clockwise for a full 360° rotation (-270° = 90° - 360°)
  • The component is already using these angle properties throughout its implementation for both the main sectors and decorative elements
  • The graph is properly integrated into the reporting system with appropriate type definitions and usage controls
  • The changes are consistent with common donut chart implementations where the first slice starts at the top position
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for visual regression tests related to DonutGraph
rg -l "DonutGraph" -g "*.test.*"

Length of output: 32


Script:

#!/bin/bash
# Let's search for any test files or snapshots related to DonutGraph with a broader search
rg -l "DonutGraph" --type-add 'test:*.{test.*,spec.*,stories.*,snap*}' --type test

# Also search for any existing usage of these angle properties to understand the current implementation
rg "startAngle|endAngle" packages/desktop-client/src/components/reports/graphs/

Length of output: 1498


Script:

#!/bin/bash
# Let's check the git history of this file to see if these angle values were different before
git log -p packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx | grep -A 5 -B 5 "startAngle\|endAngle"

# Also let's check if there are any existing usages of DonutGraph to understand the current implementation
rg "DonutGraph" -A 3 -B 3 packages/desktop-client/src/components/

Length of output: 8399

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e287049 and 193ee8a.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx (5 hunks)
🔇 Additional comments (4)
packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx (4)

43-52: LGTM: Label spacing improvements

The adjustments to text element positioning provide better spacing between labels, which aligns with the PR objectives to prevent overlap, especially on mobile devices.


Line range hint 214-220: LGTM: Enhanced type safety

Adding the DataEntity type annotation improves type safety while maintaining the correct logic for handling debt values.


251-251: LGTM: Consistent data source update

The pie chart correctly uses the sorted data array.


258-259: LGTM: Improved pie chart orientation

Setting the start angle to 90° and end angle to -270° ensures the pie chart starts from the top and rotates clockwise, which is more intuitive for users.

@youngcw
Copy link
Member

youngcw commented Nov 19, 2024

The category text is getting cut off just a bit in the card
image

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.

2 participants