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(axis): pass all tick values in tickLabelProps signature #1044

Merged
merged 3 commits into from
Feb 5, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
fix(xychart/BaseAxis): implement new tickLabelProps signature
  • Loading branch information
williaster committed Feb 3, 2021
commit f6cce4201bb9b792b1c5406f0082e06956989033
9 changes: 4 additions & 5 deletions packages/visx-xychart/src/components/axis/BaseAxis.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo, useContext } from 'react';
import { AxisScale } from '@visx/axis';
import { AxisScale, TickLabelProps } from '@visx/axis';
import { AxisProps as VxAxisProps } from '@visx/axis/lib/axis/Axis';
import { ScaleInput } from '@visx/scale';
import DataContext from '../../context/DataContext';
Expand Down Expand Up @@ -34,10 +34,10 @@ export default function BaseAxis<Scale extends AxisScale>({
[theme, orientation],
);

const tickLabelProps = useMemo(
const tickLabelProps = useMemo<TickLabelProps<ScaleInput<Scale>> | undefined>(
() =>
props.tickLabelProps || axisStyles // construct from props + theme if possible
? (value: ScaleInput<Scale>, index: number) =>
? (value, index, values) =>
// by default, wrap vertical-axis tick labels within the allotted margin space
// this does not currently account for axis label
({
Expand All @@ -46,10 +46,9 @@ export default function BaseAxis<Scale extends AxisScale>({
orientation === 'left' || orientation === 'right'
? margin?.[orientation]
: undefined,
...props.tickLabelProps?.(value, index),
...props.tickLabelProps?.(value, index, values),
})
: undefined,

[props.tickLabelProps, axisStyles, orientation, margin],
);

Expand Down