diff --git a/packages/visx-shape/src/shapes/Line.tsx b/packages/visx-shape/src/shapes/Line.tsx index fef20f552..39a60390b 100644 --- a/packages/visx-shape/src/shapes/Line.tsx +++ b/packages/visx-shape/src/shapes/Line.tsx @@ -28,6 +28,7 @@ export default function Line({ innerRef, ...restProps }: AddSVGProps) { + const isRectilinear = from.x === to.x || from.y === to.y; return ( ); diff --git a/packages/visx-shape/test/Line.test.tsx b/packages/visx-shape/test/Line.test.tsx index 91b364f84..715baa919 100644 --- a/packages/visx-shape/test/Line.test.tsx +++ b/packages/visx-shape/test/Line.test.tsx @@ -32,4 +32,35 @@ describe('', () => { ); }); }); + + test('it should set shapeRendering to auto if not rectilinear', () => { + expect( + LineWrapper({ + to: { + x: 50, + y: 100, + }, + }).prop('shapeRendering'), + ).toBe('auto'); + }); + + test('it should set shapeRendering to crispEdges if rectilinear', () => { + expect( + LineWrapper({ + to: { + x: 0, + y: 100, + }, + }).prop('shapeRendering'), + ).toBe('crispEdges'); + + expect( + LineWrapper({ + to: { + x: 100, + y: 0, + }, + }).prop('shapeRendering'), + ).toBe('crispEdges'); + }); });