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

Bar chart to skip x-axis labels like Linear charts #1777

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

markmssd
Copy link

@markmssd markmssd commented Dec 9, 2024

What does this implement/fix?

With Linear charts, the X-Axis displays labels nicely even if the width does not fit them all. It smartly displays less and less labels as it can, until it can no more show any of them.

However for Bar charts, it behaves differently. If all the labels can't fit within the width, it simply displays none of them. With this PR, it changes this behaviour to be similar to the Linear charts.

I have created a new story for Bar Charts, Monthly Reports, to show an example with a typical use case, showing a 30-days monthly report.

Does this close any currently open issues?

No

What do the changes look like?

Before After
before after

Storybook link

Before merging

  • Check your changes on a variety of browsers and devices.

  • Update the Changelog's Unreleased section with your changes.

  • Update relevant documentation, tests, and Storybook.

  • Make sure you're exporting any new shared Components, Types and Utilities from the top level index file of the package

@markmssd markmssd marked this pull request as ready for review December 9, 2024 19:42
@markmssd markmssd closed this Dec 10, 2024
@markmssd markmssd reopened this Dec 10, 2024
@markmssd markmssd changed the title Bar chart labels to partially display like Linear charts Bar chart to skip x-axis labels like Linear charts Dec 10, 2024
@envex
Copy link
Collaborator

envex commented Jan 30, 2025

We likely won't merge this because we don't want to remove labels in BarChart. Unlike LineChart, where the assumption of linearity allows us to drop labels without a 1:1 relationship to data points,BarChart require each bar to have its own label. If you are working with linear data, consider using a LineChart instead.

@markmssd
Copy link
Author

Thanks @envex , that's understandable. What if it's configurable instead? What you say makes sense, but there's still use cases similar to Google Cloud's billing charts, which we can render both as Linear and Bar charts, but it would also skip dates if the screen is narrow (I'm hiding the Y-Axis on purpose on those screenshots, but they're also here):

Screenshot 2025-01-30 at 11 03 55 AM Screenshot 2025-01-30 at 11 04 14 AM

I think it's a common use case to use Bar rendering even for Linear data like dates, WDYT?

@envex
Copy link
Collaborator

envex commented Jan 30, 2025

@carysmills Any thoughts on making this a prop?

@carysmills
Copy link
Contributor

I think we should talk to UX and see if this is behaviour we want for linear bar charts. If so, I'm not opposed, but I would like to add as little complexity/options to the charts as possible

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.

3 participants