From 61edd419e9eb0edb3079769e96e5001f9ce0df72 Mon Sep 17 00:00:00 2001 From: MultiViewer <106821994+f1multiviewer@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:56:25 +0200 Subject: [PATCH] fix: Add missing `*TickValues` prop type This adds two field types, fields already available in ``, to the `CommonGridTProps` type. --- packages/visx-grid/src/types.ts | 8 ++++++-- packages/visx-xychart/src/components/grid/BaseGrid.tsx | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/visx-grid/src/types.ts b/packages/visx-grid/src/types.ts index 1c88708ec..071a433e3 100644 --- a/packages/visx-grid/src/types.ts +++ b/packages/visx-grid/src/types.ts @@ -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. @@ -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[]; + /** Exact values to be used for GridColumns lines, passed to xScale. Use this if you need precise control over GridColumns values. */ + columnTickValues?: ScaleInput[]; /** 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. */ diff --git a/packages/visx-xychart/src/components/grid/BaseGrid.tsx b/packages/visx-xychart/src/components/grid/BaseGrid.tsx index d4fae55c3..b1148b8b1 100644 --- a/packages/visx-xychart/src/components/grid/BaseGrid.tsx +++ b/packages/visx-xychart/src/components/grid/BaseGrid.tsx @@ -22,6 +22,8 @@ export default function BaseGrid({ columns = true, GridRowsComponent, GridColumnsComponent, + rowTickValues, + columnTickValues, ...props }: BaseGridProps) { const { @@ -43,6 +45,7 @@ export default function BaseGrid({ lineStyle={gridLineStyles} width={innerWidth} scale={rowsScale} + tickValues={rowTickValues} {...props} /> )} @@ -52,6 +55,7 @@ export default function BaseGrid({ lineStyle={gridLineStyles} height={innerHeight} scale={columnsScale} + tickValues={columnTickValues} {...props} /> )}