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

new(vx-axis): use numTicks when falling back on scale.domain #752

Merged
merged 2 commits into from
Jun 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/vx-axis/src/axis/Axis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,18 @@ export default function Axis<ScaleInput>({
tickComponent,
top = 0,
}: AxisProps<ScaleInput>) {
const values = tickValues || (scale.ticks ? scale.ticks(numTicks) : scale.domain());
const values =
tickValues ||
(scale.ticks
? scale.ticks(numTicks)
: scale
.domain()
.filter(
(_, index, arr) =>
numTicks == null ||
arr.length <= numTicks ||
index % Math.round((arr.length - 1) / numTicks) === 0,
));
const format = tickFormat || (scale.tickFormat ? scale.tickFormat() : toString);

const range = scale.range();
Expand Down