Skip to content

fix(charts): show all x-axis date labels #33191

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

Open
wants to merge 1 commit into
base: 4.1
Choose a base branch
from

Conversation

magickspell
Copy link

SUMMARY

Fix to display all x-axis date labels that are selected in the time grain.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
Screenshot from 2025-04-20 22-11-03


After:
Screenshot from 2025-04-20 23-17-00

TESTING INSTRUCTIONS

  1. Create a BAR CHART
  2. Add a timestamp field in QUERY -> X-AXIS
  3. Select Month in TIME GRAIN
    Expect: All months should be displayed on the X-AXIS.

ADDITIONAL INFORMATION

@dosubot dosubot bot added the viz:charts:timeseries Related to Timeseries label Apr 20, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Performance Unbounded splitNumber causing potential performance and readability issues ▹ view 🧠 Not in standard
Files scanned
File Path Reviewed
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

@@ -488,6 +488,7 @@ export default function transformProps(
formatter: xAxisFormatter,
rotate: xAxisLabelRotation,
},
splitNumber: data.length,

This comment was marked as resolved.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @magickspell, this looks great! What happens when you choose day or minute as the time grain? Does it still try to render every x-axis label, or will it then aggregate them?

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should have a checkbox control to enable this. I'm a little worried that even with larger timegrains, the labels might overlap when they're in the default (horizontal) layout.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on the checkbox (preferably disabled by default to preserve existing functionality)

Copy link
Member

Choose a reason for hiding this comment

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

splitNumber does not guarantee that all labels will be displayed.

Note that this number serves only as a recommendation, and the true segments may be adjusted based on readability.

You need to set interval, min, and max to achieve this functionality.

As splitNumber is a recommendation value, the calculated tick may not be the same as expected. In this case, interval should be used along with min and max to compulsively set tickings.

I also agree with the checkbox (disabled by default) approach.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

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.

5 participants