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: create options for tick rotation #770

Merged

Conversation

hlyang397
Copy link
Contributor

@hlyang397 hlyang397 commented Aug 27, 2020

User may like to control if ticks need to be rotated while zoom domain is changing .
For example, if the tick number is small and the chart is wide enough, maybe tick rotation is not necessary.

Updates

  • new enums and configuration
  • control x-axis tick rotation depending on configuration

Demo screenshot or recording

Always rotate ticks while zooming:
always

Never rotate ticks while zooming:
never

Rotate ticks when space is not enough: (default)
depending

Review checklist (for reviewers only)

  • Demos all features
  • Documented/annotated
  • Matches UI/UX specs
  • Meets the code style guide
  • Accessible
  • Mobile first (responsive)
  • RTL support (bidirectional text)
  • Performant (limited bloat)

- new enums and configuration
- control x-axis tick rotation depending on configuration
@hlyang397 hlyang397 requested review from natashadecoste, theiliad and a team as code owners August 27, 2020 07:57
@hlyang397 hlyang397 requested review from Donisius and removed request for a team August 27, 2020 07:57
packages/core/src/components/axes/axis.ts Outdated Show resolved Hide resolved
@@ -472,8 +511,7 @@ export class Axis extends Component {
: estimatedTickSize < minTickSize;
}

// always rotate ticks if zoomDomain is changing to avoid rotation flips during zoomDomain changing
if (rotateTicks || this.zoomDomainChanging) {
if (this.isTickRotationRequired(rotateTicks)) {
Copy link
Member

Choose a reason for hiding this comment

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

why would we go through labels and calculate whether any need rotation before knowing whether we are rotating or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, if we already know that we need to rotate or not, we could avoid some calculation

Updated in f2489e7.

@hlyang397 hlyang397 requested a review from theiliad August 28, 2020 04:53
Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

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

Couple of points here:

  • the code here strictly works for bottom & top axis. It should just really factor in which zoom bars are active and act accordingly
  • we should probably fix the issue of unnecessary tick rotations before fixing this. Seems like ticks rotate at times when they don't need to

@hlyang397
Copy link
Contributor Author

@theiliad,

Couple of points here:

* the code here strictly works for bottom & top axis. It should just really factor in which zoom bars are active and act accordingly

Updated in bc124bb.

* we should probably fix the issue of unnecessary tick rotations before fixing this. Seems like ticks rotate at times when they don't need to

I don't think so.
Even the tick rotation function works perfectly without unnecessary tick rotations, we still need this option to avoid the tick rotation flips during zoom domain changing.
So I think unnecessary tick rotations is another issue, but not necessary a dependency of this issue.

Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

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

again, this seems like it's completely dependant on zooming. Why wouldn't this just work without the zoom bar?

@theiliad
Copy link
Member

theiliad commented Sep 2, 2020

we should just move this flag out of the zoom bar options & into each individual axis:

{
  axes: {
    bottom: {
       ticks: {
           rotation: .....
       }
    }
  }
}

@hlyang397 hlyang397 changed the title feat: create options for tick rotation feat: create options for tick rotation while zooming Sep 3, 2020
@hlyang397
Copy link
Contributor Author

again, this seems like it's completely dependant on zooming. Why wouldn't this just work without the zoom bar?

@theiliad ,
Yes, it's completely dependent on zooming.
I guess you misunderstand this option, so I just update the PR title.
This PR is about the tick rotation while zooming, not the tick rotation without zoom bar enabled.
When zoom bar is disabled, tick rotation behavior keeps as it is. It rotates whenever necessary. This option is meaningless.
When zoom bar is enabled, and user is changing zoom domain, this option allows user to decide if

  1. ALWAYS keep tick rotation when zoom domain is changing
  2. NEVER let tick rotated (keep flat) when zoom domain is changing
  3. AUTO let tick rotate whenever needed when zoom domain is changing

That's why I set the flag name rotateWhileZooming, and it has to be related to zoom bar.

If you are thinking about the tick rotation option when zoom domain is NOT changing or zoom bar is disabled, that would be another story.

Hope I make it clear after these explanation.

@hlyang397
Copy link
Contributor Author

we should just move this flag out of the zoom bar options & into each individual axis:

{
  axes: {
    bottom: {
       ticks: {
           rotation: .....
       }
    }
  }
}

The flag is already under ticks of individual axis, but the name is rotateWhileZooming for now.
As I mentioned in another comment, this option is about tick rotation while zooming, so the name rotation may confuse user.
It's up to you, let me know the flag name you like to use.

@hlyang397 hlyang397 requested a review from theiliad September 3, 2020 04:05
Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

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

This really should work without being dependant on zooming.

If you've set the config to auto then it'll result in the library deciding when to rotate and when not to.

If you've set it to never then obviously ticks will never rotate.

If you've set it to always, then they'll always be rotated...

Therefore it should just be a axisOptions.ticks.rotation flag rather than axisOptions.ticks. rotateWhileZooming

@hlyang397 hlyang397 changed the title feat: create options for tick rotation while zooming feat: create options for tick rotation Sep 11, 2020
@hlyang397
Copy link
Contributor Author

This really should work without being dependant on zooming.

If you've set the config to auto then it'll result in the library deciding when to rotate and when not to.

If you've set it to never then obviously ticks will never rotate.

If you've set it to always, then they'll always be rotated...

Therefore it should just be a axisOptions.ticks.rotation flag rather than axisOptions.ticks. rotateWhileZooming
@theiliad
The tick rotation option not related to zooming is actually another kind of option.
But this option also works to me for now. Updated in e83c395.

Since this PR is not related to zoom now, I also update PR title and description.

Let me know if you have any comment.

@hlyang397 hlyang397 requested a review from theiliad September 11, 2020 08:32
@theiliad theiliad merged commit 4063c8a into carbon-design-system:master Sep 11, 2020
@theiliad theiliad deleted the label-rotation-options branch September 11, 2020 16:48
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 14, 2020
…to linearGradient

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.37.0
  Merge pull request carbon-design-system#780 from natashadecoste/fix-meter-max-val
  feat: enable or disable scatter dot on charts except scatter chart (carbon-design-system#769)
  feat: create options for tick rotation (carbon-design-system#770)
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 14, 2020
…to axis-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.37.0
  Merge pull request carbon-design-system#780 from natashadecoste/fix-meter-max-val
  feat: enable or disable scatter dot on charts except scatter chart (carbon-design-system#769)
  feat: create options for tick rotation (carbon-design-system#770)

fix: enable zoom in functionality while axis is disabled
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 15, 2020
…to ruler-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.37.1
  Merge pull request carbon-design-system#800 from metonym/fix-svelte-base-chart
  v0.37.0
  Merge pull request carbon-design-system#780 from natashadecoste/fix-meter-max-val
  feat: enable or disable scatter dot on charts except scatter chart (carbon-design-system#769)
  feat: create options for tick rotation (carbon-design-system#770)
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 15, 2020
…to tooltip-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.37.1
  Merge pull request carbon-design-system#800 from metonym/fix-svelte-base-chart
  v0.37.0
  Merge pull request carbon-design-system#780 from natashadecoste/fix-meter-max-val
  feat: enable or disable scatter dot on charts except scatter chart (carbon-design-system#769)
  feat: create options for tick rotation (carbon-design-system#770)
  v0.36.4
  Merge pull request carbon-design-system#761 from JennChao/sparkline
  Merge pull request carbon-design-system#793 from hlyang397/update-initial-zoom-domain
  fix the defect of label tooltip not showing when using custom tooltip (carbon-design-system#787)
  v0.36.3
  Merge pull request carbon-design-system#785 from sophiiae/skeleton-with-data
theiliad pushed a commit to theiliad/carbon-charts that referenced this pull request May 17, 2021
* feat: create options for tick rotation

- new enums and configuration
- control x-axis tick rotation depending on configuration

* refactor: change TickRotations DEPENDING to AUTO

* refactor: avoid extra calculation for shouldRotateTicks

* refactor: limit top/bottom axis tick rotation to top/bottom zoom bar only

* refactor: tick rotation don't depend on zoom
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.

4 participants