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

feat(MCDA): 19032 Append units to custom axis labels in MCDA dropdown #805

Merged

Conversation

albaranau
Copy link
Contributor

@albaranau albaranau commented Jul 23, 2024

https://kontur.fibery.io/Tasks/Task/FE-MCDA-dropdown-add-units-to-custom-axis-labels-19032

Summary by CodeRabbit

  • New Features

    • Introduced a custom label formatting function for bivariate axes, allowing more descriptive and flexible labeling.
    • Updated logic for axis label generation to better handle custom labels and associated quotients.
  • Bug Fixes

    • Improved the label generation process to ensure accurate formatting when custom labels are used.
  • Tests

    • Added comprehensive unit tests for the new custom label formatting function, validating various scenarios for accurate label representation.

Copy link
Contributor

coderabbitai bot commented Jul 23, 2024

Walkthrough

The recent changes enhance the axisDTOtoAxis function and introduce the formatCustomBivariateAxisLabel function, allowing for more flexible and descriptive axis labeling in bivariate visualizations. The new functionality supports custom labels and incorporates units derived from specified quotients, improving clarity and interpretability for graphical representations.

Changes

Files Change Summary
src/utils/bivariate/helpers/converters/axisDTOtoAxis.ts, src/utils/bivariate/labelFormatters.ts Introduced formatCustomBivariateAxisLabel for custom label formatting, enhancing label clarity. Modified axisDTOtoAxis to utilize this function under specific conditions.
src/utils/bivariate/labelFormatters.test.ts Added tests for the new formatCustomBivariateAxisLabel, validating its behavior with various input scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant axisDTOtoAxis
    participant formatCustomBivariateAxisLabel

    User->>axisDTOtoAxis: Call with AxisDTO
    axisDTOtoAxis->>formatCustomBivariateAxisLabel: Check if dto.label exists
    alt If dto.label exists
        formatCustomBivariateAxisLabel->>axisDTOtoAxis: Return formatted label with quotients
    else
        axisDTOtoAxis->>formatBivariateAxisLabel: Call for default formatting
    end
    axisDTOtoAxis->>User: Return final axis object with label
Loading

Poem

In the fields where data grows,
A rabbit hops where the axis flows.
With labels bright, and units clear,
Custom tales bring graphs to cheer!
Hopping high, I celebrate,
Changes made, oh, how great! 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@albaranau albaranau requested a review from a team July 23, 2024 18:40
Copy link

Language To Recheck Fuzzy Untranslated Total
ar 3 24 101 128
de 2 24 101 127
es 3 24 101 128
id 2 24 101 127
ko 3 24 101 128
uk 0 7 8 15

Copy link

Bundle size diff

Old size New size Diff
4.95 MB 4.95 MB 70 B (0.00%)

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between e262896 and a44f616.

Files selected for processing (3)
  • src/utils/bivariate/helpers/converters/axisDTOtoAxis.ts (1 hunks)
  • src/utils/bivariate/labelFormatters.test.ts (2 hunks)
  • src/utils/bivariate/labelFormatters.ts (1 hunks)
Additional comments not posted (5)
src/utils/bivariate/helpers/converters/axisDTOtoAxis.ts (2)

1-4: Import statements are correctly updated.

The new formatCustomLabelForBivariateAxis function is correctly imported.


12-14: Function logic is correctly updated.

The axisDTOtoAxis function now uses formatCustomLabelForBivariateAxis for custom label formatting if dto.label is provided. The fallback to formatBivariateAxisLabel ensures backward compatibility.

src/utils/bivariate/labelFormatters.ts (1)

13-22: Function logic is correctly implemented.

The formatCustomLabelForBivariateAxis function correctly formats custom labels with units derived from quotients. The fallback to return the custom label without units ensures robustness.

src/utils/bivariate/labelFormatters.test.ts (2)

2-6: Import statements are correctly updated.

The new formatCustomLabelForBivariateAxis function is correctly imported.


126-183: Tests are correctly implemented.

The tests for the formatCustomLabelForBivariateAxis function correctly cover the scenarios where units are present and absent. The test cases are well-defined and ensure the function behaves as expected.

@albaranau albaranau self-assigned this Jul 24, 2024
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between a44f616 and bca74bb.

Files selected for processing (3)
  • src/utils/bivariate/helpers/converters/axisDTOtoAxis.ts (1 hunks)
  • src/utils/bivariate/labelFormatters.test.ts (2 hunks)
  • src/utils/bivariate/labelFormatters.ts (1 hunks)
Additional comments not posted (5)
src/utils/bivariate/helpers/converters/axisDTOtoAxis.ts (2)

1-4: Import statement looks good.

The import statement correctly includes formatCustomBivariateAxisLabel.


12-14: Function logic looks good.

The function correctly uses formatCustomBivariateAxisLabel when dto.label is present and falls back to formatBivariateAxisLabel otherwise.

src/utils/bivariate/labelFormatters.ts (1)

13-19: Function logic looks good.

The function correctly formats the custom label with units derived from quotients.

src/utils/bivariate/labelFormatters.test.ts (2)

2-6: Import statement looks good.

The import statement correctly includes formatCustomBivariateAxisLabel.


126-183: Test cases look good.

The test cases correctly verify the behavior of formatCustomBivariateAxisLabel under different conditions.

…-mcda-dropdown-add-units-to-custom-axis-labels
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between bca74bb and 49ec29b.

Files selected for processing (1)
  • src/utils/bivariate/helpers/converters/axisDTOtoAxis.ts (1 hunks)
Additional comments not posted (2)
src/utils/bivariate/helpers/converters/axisDTOtoAxis.ts (2)

1-4: Imports look good!

The import statement correctly includes formatCustomBivariateAxisLabel from ~utils/bivariate/labelFormatters.


12-14: Conditional structure for label property looks good!

The conditional structure for setting the label property is correctly implemented. It checks for the existence of dto.label and uses formatCustomBivariateAxisLabel if present, otherwise falls back to formatBivariateAxisLabel.

@albaranau albaranau merged commit c27787c into main Jul 24, 2024
7 checks passed
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.

2 participants