Skip to content

Conversation

@ALOK9442
Copy link
Contributor

@ALOK9442 ALOK9442 commented Mar 19, 2025

Fixes #38974
Fixes the issue where Y-axis labels were getting truncated, as mentioned in the issue.

Also resolves the problem of X-axis labels not being truncated when displaying large values. The fix ensures that truncation occurs in two cases:
When the orientation is set to "auto," truncation happens for relatively larger values.
For other orientations, truncation follows the same width constraints as before.

Automation

/ok-to-test tags=""

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Enhanced X-axis label display for charts, offering improved control over label spacing, width, and overlap when using automatic orientation.
    • Adjusted Y-axis label rendering by removing explicit truncation, resulting in a modified display behavior when labels exceed allocated space.

@ALOK9442 ALOK9442 requested a review from a team as a code owner March 19, 2025 11:39
@ALOK9442 ALOK9442 requested review from vivek-appsmith and removed request for a team March 19, 2025 11:39
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2025

Walkthrough

This pull request updates the axis label configuration for chart widgets. In the X-axis builder, the method now returns additional properties—including width, overflow, hideOverlap, and interval—based on the label orientation. In the Y-axis builder, the overflow truncation property has been removed, which may affect label rendering when the label size exceeds the allocated width. No changes were made to public API declarations.

Changes

File(s) Change Summary
app/.../EChartsXAxisLayoutBuilder.ts Updated axisLabelConfig to return more detailed configurations: for LabelOrientation.AUTO, includes width, overflow, hideOverlap, and interval; otherwise adds hideOverlap (true) and interval (0) alongside existing properties.
app/.../EChartsYAxisLayoutBuilder.ts Removed overflow: "truncate" from the axis label configuration in the config method, altering how label overflow is handled.

Sequence Diagram(s)

sequenceDiagram
    participant Widget as ChartWidget
    participant XAxis as EChartsXAxisLayoutBuilder
    Widget->>XAxis: call axisLabelConfig(labelOrientation, allocatedXAxisHeight)
    alt labelOrientation == AUTO
        XAxis-->>Widget: returns { width: allocatedXAxisHeight, overflow, hideOverlap, interval }
    else
        XAxis-->>Widget: returns { hideOverlap: true, interval: 0, ...existingProps }
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
[Bug]: Y labels for chart are truncated (#38974)

Suggested labels

Bug, Chart Widget, ok-to-test, Widgets Product, Widgets & Accelerators Pod

Suggested reviewers

  • rajatagrawal
  • jsartisan
  • ApekshaBhosale

Poem

In the realm of charts so vast and bright,
Axis labels now dance with added might.
X-axis gains detail with properties anew,
While Y-axis sheds truncation, fresh views ensue.
Cheers to clean code and a rendering delight! 🎉

Happy coding and charting on!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59948e1 and 262c828.

📒 Files selected for processing (2)
  • app/client/src/widgets/ChartWidget/component/LayoutBuilders/EChartsXAxisLayoutBuilder.ts (1 hunks)
  • app/client/src/widgets/ChartWidget/component/LayoutBuilders/EChartsYAxisLayoutBuilder.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/widgets/ChartWidget/component/LayoutBuilders/EChartsYAxisLayoutBuilder.ts
🔇 Additional comments (2)
app/client/src/widgets/ChartWidget/component/LayoutBuilders/EChartsXAxisLayoutBuilder.ts (2)

35-40: Appropriate property additions for AUTO orientation.

These newly added properties provide better control over axis label rendering when orientation is AUTO. The width property ensures labels have a defined space constraint, overflow: "truncate" handles text that exceeds this width, while hideOverlap and interval properties prevent label crowding.


48-49: Good addition of anti-overlap properties.

Adding hideOverlap: true and interval: 0 for non-AUTO orientations ensures consistent label display across all orientation types. This prevents potential label crowding while maintaining the existing truncation behavior.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this 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.

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.

@ALOK9442
Copy link
Contributor Author

Hey @rahulbarwal I have raised the pr, can you please check it.
Thanks

@vivek-appsmith vivek-appsmith added the Widgets Product This label groups issues related to widgets label Mar 20, 2025
nameGap: this.nameGap,
axisLabel: {
width: this.labelsWidth,
overflow: "truncate",
Copy link
Contributor

Choose a reason for hiding this comment

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

@ALOK9442

We should debug why the label width is incorrect. Calculating the correct width for labels and the chart area should fix the bug. Removing truncate will make other use cases fail.

Same approach for x label truncation issue too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Once the fix is done, I would like to request you to test the client unit test cases pass as well since there are a lot of unit test cases for the chart widget which check various scenarios which should pass after the changes. Thank you!

Copy link
Contributor Author

@ALOK9442 ALOK9442 Mar 20, 2025

Choose a reason for hiding this comment

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

@rajatagrawal
thanks for pointing out the real issue and for x axis we are having that issue in auto orientation only so we need to add the truncate properties in it and else I am debugging what could be the problem as you are correct about not removing truncate as it will affect the other edge cases

@ALOK9442
Copy link
Contributor Author

Hey @rajatagrawal, since this is assigned to you, I wanted to share a few observations:

  1. The width calculation currently considers commas in numbers. For example, in a large number like 120,000,000, the measureText function includes the commas while measuring the width, which may lead to inaccuracies.

  2. The font being used appears as 14px undefined. While the font size is correctly set to 14px, the font family is not being applied properly. This happens because it is assigned as fontFamily: "fontfamily", which causes measureText to fall back to the default 10px sans-serif, leading to incorrect width calculations.

although I am still working on it

@ALOK9442
Copy link
Contributor Author

hey @rajatagrawal , I think using a formatter would be a better approach as the width is dynamic and we are calculating it on the basis of text width and that's why even if we truncate on the basis of this dynamic width we will still face inconsistency for bigger numbers, let me know what do you think about this aproach

@github-actions
Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Mar 30, 2025
@vivek-appsmith vivek-appsmith removed their request for review April 1, 2025 05:57
@github-actions
Copy link

github-actions bot commented Apr 8, 2025

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale Widgets Product This label groups issues related to widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Y labels for chart are truncated

3 participants