-
Notifications
You must be signed in to change notification settings - Fork 58
feat: allow customization of axis tick mark and grid line alignment in band scale #291
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
eff9e3e
feat: support band positions in axis lines
hcopp a8b37e8
Improve web
hcopp 3a0c5c4
Bring changes to mobile
hcopp 4e8beb6
Update mobile example
hcopp 3d992c7
Cleanup band scale calculation
hcopp f1f8016
Merge function for serializable band scale into point
hcopp 9c6c443
Revert TickMarkComponent name change
hcopp 2d4976a
Simplify transition
hcopp c2bdf96
Fix scale bug
hcopp 7049b82
Drop comments from jsx
hcopp e1094a2
Simplify toPointAnchor
hcopp 029875d
Rename position to placement with new props
hcopp 7b6a7a2
Update docs
hcopp 2c8c83e
Rename bandGridPlacement to bandGridLinePlacement
hcopp 3448aaf
Bump versions
hcopp 71a0bb3
Merge branch 'master' into hunter/chart-axis-band-line-alignment
hcopp 783a557
Update web example
hcopp 44350f0
Improve axis tick location naming
hcopp ddc4f6b
Remove extra line
hcopp e8d3f10
Update example
hcopp 5e60ddd
Update example
hcopp c98e6a4
Update width of example
hcopp 37e00ed
Merge branch 'master' into hunter/chart-axis-band-line-alignment
hcopp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,51 +2,14 @@ import type React from 'react'; | |
|
|
||
| import { type LineComponent } from '../line'; | ||
| import type { ChartTextChildren, ChartTextProps } from '../text/ChartText'; | ||
| import { accessoryFadeTransitionDuration, type AxisBandPlacement } from '../utils'; | ||
|
|
||
| /** | ||
| * Animation variants for grouped axis tick labels - initial mount | ||
| * Note: Mobile currently doesn't use these variants. Axes render immediately without animation. | ||
| * Web uses similar variants with delay to match path enter animation timing. | ||
| * Animation transition for axis elements (grid lines, tick marks, tick labels). | ||
| * Matches web's axisUpdateAnimationTransition timing. | ||
| */ | ||
| export const axisTickLabelsInitialAnimationVariants = { | ||
| initial: { | ||
| opacity: 0, | ||
| }, | ||
| animate: { | ||
| opacity: 1, | ||
| transition: { | ||
| duration: 0, | ||
| delay: 0, | ||
| }, | ||
| }, | ||
| exit: { | ||
| opacity: 0, | ||
| transition: { | ||
| duration: 0.15, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| /** | ||
| * Animation variants for axis elements - updates (used for both grid lines and tick labels) | ||
| */ | ||
| export const axisUpdateAnimationVariants = { | ||
| initial: { | ||
| opacity: 0, | ||
| }, | ||
| animate: { | ||
| opacity: 1, | ||
| transition: { | ||
| duration: 0.15, | ||
| delay: 0.15, // For updates: fade out 150ms, then fade in 150ms | ||
| }, | ||
| }, | ||
| exit: { | ||
| opacity: 0, | ||
| transition: { | ||
| duration: 0.15, | ||
| }, | ||
| }, | ||
| export const axisUpdateAnimationTransition = { | ||
| duration: accessoryFadeTransitionDuration, | ||
| }; | ||
|
|
||
| export type AxisTickLabelComponentProps = Pick< | ||
|
|
@@ -70,6 +33,20 @@ export type AxisTickLabelComponentProps = Pick< | |
| export type AxisTickLabelComponent = React.FC<AxisTickLabelComponentProps>; | ||
|
|
||
| export type AxisBaseProps = { | ||
| /** | ||
| * Placement of grid lines relative to each band. | ||
| * Options: 'start', 'middle', 'end', 'edges' | ||
| * @note This property only applies to band scales. | ||
| * @default 'edges' | ||
| */ | ||
| bandGridLinePlacement?: AxisBandPlacement; | ||
| /** | ||
| * Placement of tick marks relative to each band. | ||
| * Options: 'start', 'middle', 'end', 'edges' | ||
| * @note This property only applies to band scales. | ||
| * @default 'middle' | ||
| */ | ||
| bandTickMarkPlacement?: AxisBandPlacement; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These props determine the location of the tick mark and grid lines. |
||
| /** | ||
| * Label text to display for the axis. | ||
| */ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We weren't correctly doing this animation on mobile so I removed it. The initial goal for this functionality was to nicely fade in and out grid lines coinciding with text as that previously wouldn't show immediately.
This is still the case on web but with our new mobile library we can immediately show text, since we are able to synchronously measure the bounding box of it with Skia.