Skip to content

Commit

Permalink
fix(axis): include defaultTextProps in Axis labelProps (#1791)
Browse files Browse the repository at this point in the history
* fix: include defaultTextProps in Axis labelProps

This enables passing of partial labelProps per the docs.

* Apply suggestions from code review

Co-authored-by: Chris Williams <[email protected]>

* Update packages/visx-axis/src/axis/AxisRenderer.tsx

Co-authored-by: Chris Williams <[email protected]>

* Update packages/visx-axis/src/axis/AxisRenderer.tsx

Co-authored-by: Chris Williams <[email protected]>

---------

Co-authored-by: Chris Williams <[email protected]>
  • Loading branch information
RyKilleen and williaster authored Jan 25, 2024
1 parent a185cab commit 843d321
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/visx-axis/src/axis/AxisRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function AxisRenderer<Scale extends AxisScale>({
label = '',
labelClassName,
labelOffset = 14,
labelProps = defaultTextProps,
labelProps,
orientation = Orientation.bottom,
scale,
stroke = '#222',
Expand All @@ -42,6 +42,10 @@ export default function AxisRenderer<Scale extends AxisScale>({
ticks,
ticksComponent = Ticks,
}: AxisRendererProps<Scale>) {
const combinedLabelProps = {
...defaultTextProps,
...labelProps,
};
const tickLabelPropsDefault = {
...defaultTextProps,
...(typeof tickLabelProps === 'object' ? tickLabelProps : null),
Expand Down Expand Up @@ -89,13 +93,13 @@ export default function AxisRenderer<Scale extends AxisScale>({
className={cx('visx-axis-label', labelClassName)}
{...getLabelTransform({
labelOffset,
labelProps,
labelProps: combinedLabelProps,
orientation,
range: scale.range(),
tickLabelFontSize: maxTickLabelFontSize,
tickLength,
})}
{...labelProps}
{...combinedLabelProps}
>
{label}
</Text>
Expand Down

0 comments on commit 843d321

Please sign in to comment.