-
Notifications
You must be signed in to change notification settings - Fork 185
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
feat: create options for tick rotation #770
Conversation
- new enums and configuration - control x-axis tick rotation depending on configuration
@@ -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)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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
Updated in bc124bb.
I don't think so. |
There was a problem hiding this 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?
we should just move this flag out of the zoom bar options & into each individual axis:
|
@theiliad ,
That's why I set the flag name 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. |
The flag is already under ticks of individual axis, but the name is |
There was a problem hiding this 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
Since this PR is not related to zoom now, I also update PR title and description. Let me know if you have any comment. |
…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)
…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
…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)
…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
* 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
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
Demo screenshot or recording
Always rotate ticks
while zooming:Never rotate ticks
while zooming:Rotate ticks when space is not enough: (default)
Review checklist (for reviewers only)