Skip to content

Commit

Permalink
Merge pull request #752 from hshoff/chris--axis-ticks
Browse files Browse the repository at this point in the history
new(vx-axis): use numTicks when falling back on scale.domain
  • Loading branch information
williaster authored Jun 18, 2020
2 parents a746e9f + 300c46c commit 9dc2254
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit 9dc2254

Please sign in to comment.