-
Notifications
You must be signed in to change notification settings - Fork 33
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/custom tick values #255
Conversation
🦋 Changeset detectedLatest commit: 2162380 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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 is looking really good!! Nice work. Just some comments for now!
@@ -102,6 +102,7 @@ The `axisOptions` is an optional prop allows you to configure the axes and grid | |||
| :-----------------: | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | |||
| **`font`** | <pre>SkFont | null</pre> | Defines the font to be used for axis labels. If not provided, then no labels will be rendered. This font object is typically returned from Skia’s `useFont` hook. | | |||
| **`tickCount`** | <pre>number | {<br /> x: number; <br /> y: number;<br />}</pre> | Defines the number of ticks to be rendered on both axes, or if provided an object, specific to x and y. If not provided, then the chart will attempt to choose a reasonable number of ticks based on the size of the chart. <br /><br />Note: This is an approximation; the scale may return more or fewer values depending on the domain, padding, and axis labels. | | |||
| **`tickValues`** | <pre>[number] | {<br /> x: [number]; <br /> y: [number];<br />}</pre> | Defines the explicit set of numeric tick values to be rendered on both axes, or if provided an object, specific to x and y. The tickValues prop is used to specify the values of each tick, so we only accept numeric values. Use the `formatXLabel` or `formatYLabel` options to customize how the ticks should be labeled. <br /><br />Note: If `tickCount` value is also provided, it will be used to downsample the provided `tickValues` array to the specified length. | |
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.
It might be worth also adding a note about how it seems like the domain values take precedence over the tickValues
if it's present?
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.
@zibs technically, the domain should never take precedence over the tickValues, per se.
Instead, if a domain is NOT present, we attempt to create our own domain using the min/max of any tickValues provided (and if not, we fall back to getting the domain from the min/max of the data itself). In the end, we still use all of the tickValues to place the ticks on the chart.
This can create some fun cases where the provided tickValues
may land outside of the specified domain, which may benefit from a note. But, I wasn't sure how best to document this, so I chose not to include it (as is the case with the Victory docs on tickValues)
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.
Oh I see, okay great!
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.
Awesome, thanks!
Description
Fixes Issue #234
This PR adds the
tickValues
to theaxisOptions
prop. This option is modeled after the Victory web prop of the same name.Essentially,
tickValues
accepts an array of explicit numerical tick values that we use to draw the respective tick on the chart. This can be used to have more control over which ticks are displayed in your UI. Used in conjunction with theformatXLabel
andformatYLabel
options, a user should have more control over how their ticks are displayed.Type of Change
Checklist: (Feel free to delete this section upon completion)
yarn run check:code
and all checks pass