Skip to content

Commit

Permalink
fix: Add missing *TickValues prop type
Browse files Browse the repository at this point in the history
This adds two field types, fields already available in `<BaseGrid>`, to
the `CommonGridTProps` type.
  • Loading branch information
f1multiviewer committed Jun 21, 2024
1 parent 1aed091 commit 61edd41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/visx-grid/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CSSProperties, ReactNode } from 'react';
import { D3Scale, NumberLike } from '@visx/scale';
import { D3Scale, NumberLike, ScaleInput } from '@visx/scale';

// In order to plot values on an axis, output of the scale must be number.
// Some scales return undefined.
Expand Down Expand Up @@ -31,8 +31,12 @@ export type CommonGridProps = {
strokeWidth?: string | number;
/** Grid line stroke-dasharray attribute. */
strokeDasharray?: string;
/** Approximate number of grid lines. Approximate due to d3 alogrithm, specify `tickValues` for precise control. */
/** Approximate number of grid lines. Approximate due to d3 alogrithm, specify `rowTickValues` or `columnTickValues` for precise control. */
numTicks?: number;
/** Exact values to be used for GridRows lines, passed to yScale. Use this if you need precise control over GridRows values. */
rowTickValues?: ScaleInput<GridScale>[];
/** Exact values to be used for GridColumns lines, passed to xScale. Use this if you need precise control over GridColumns values. */
columnTickValues?: ScaleInput<GridScale>[];
/** Styles to apply as grid line style. */
lineStyle?: CSSProperties;
/** Pixel offset to apply as a translation (y- for Rows, x- for Columns) to each grid lines. */
Expand Down
4 changes: 4 additions & 0 deletions packages/visx-xychart/src/components/grid/BaseGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default function BaseGrid({
columns = true,
GridRowsComponent,
GridColumnsComponent,
rowTickValues,
columnTickValues,
...props
}: BaseGridProps) {
const {
Expand All @@ -43,6 +45,7 @@ export default function BaseGrid({
lineStyle={gridLineStyles}
width={innerWidth}
scale={rowsScale}
tickValues={rowTickValues}
{...props}
/>
)}
Expand All @@ -52,6 +55,7 @@ export default function BaseGrid({
lineStyle={gridLineStyles}
height={innerHeight}
scale={columnsScale}
tickValues={columnTickValues}
{...props}
/>
)}
Expand Down

0 comments on commit 61edd41

Please sign in to comment.