Skip to content

Commit 61edd41

Browse files
committed
fix: Add missing *TickValues prop type
This adds two field types, fields already available in `<BaseGrid>`, to the `CommonGridTProps` type.
1 parent 1aed091 commit 61edd41

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/visx-grid/src/types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CSSProperties, ReactNode } from 'react';
2-
import { D3Scale, NumberLike } from '@visx/scale';
2+
import { D3Scale, NumberLike, ScaleInput } from '@visx/scale';
33

44
// In order to plot values on an axis, output of the scale must be number.
55
// Some scales return undefined.
@@ -31,8 +31,12 @@ export type CommonGridProps = {
3131
strokeWidth?: string | number;
3232
/** Grid line stroke-dasharray attribute. */
3333
strokeDasharray?: string;
34-
/** Approximate number of grid lines. Approximate due to d3 alogrithm, specify `tickValues` for precise control. */
34+
/** Approximate number of grid lines. Approximate due to d3 alogrithm, specify `rowTickValues` or `columnTickValues` for precise control. */
3535
numTicks?: number;
36+
/** Exact values to be used for GridRows lines, passed to yScale. Use this if you need precise control over GridRows values. */
37+
rowTickValues?: ScaleInput<GridScale>[];
38+
/** Exact values to be used for GridColumns lines, passed to xScale. Use this if you need precise control over GridColumns values. */
39+
columnTickValues?: ScaleInput<GridScale>[];
3640
/** Styles to apply as grid line style. */
3741
lineStyle?: CSSProperties;
3842
/** Pixel offset to apply as a translation (y- for Rows, x- for Columns) to each grid lines. */

packages/visx-xychart/src/components/grid/BaseGrid.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export default function BaseGrid({
2222
columns = true,
2323
GridRowsComponent,
2424
GridColumnsComponent,
25+
rowTickValues,
26+
columnTickValues,
2527
...props
2628
}: BaseGridProps) {
2729
const {
@@ -43,6 +45,7 @@ export default function BaseGrid({
4345
lineStyle={gridLineStyles}
4446
width={innerWidth}
4547
scale={rowsScale}
48+
tickValues={rowTickValues}
4649
{...props}
4750
/>
4851
)}
@@ -52,6 +55,7 @@ export default function BaseGrid({
5255
lineStyle={gridLineStyles}
5356
height={innerHeight}
5457
scale={columnsScale}
58+
tickValues={columnTickValues}
5559
{...props}
5660
/>
5761
)}

0 commit comments

Comments
 (0)