diff --git a/.changeset/perfect-kangaroos-press.md b/.changeset/perfect-kangaroos-press.md new file mode 100644 index 00000000..0689bdd1 --- /dev/null +++ b/.changeset/perfect-kangaroos-press.md @@ -0,0 +1,5 @@ +--- +"victory-native": patch +--- + +If user provided y domain, don't modify it diff --git a/lib/src/cartesian/utils/transformInputData.test.ts b/lib/src/cartesian/utils/transformInputData.test.ts index f2efc100..527bd32e 100644 --- a/lib/src/cartesian/utils/transformInputData.test.ts +++ b/lib/src/cartesian/utils/transformInputData.test.ts @@ -64,5 +64,20 @@ describe("transformInputData", () => { expect(y.y.i).toEqual([7, 5, 3]); }); + it("should use domain if provided", () => { + const { xScale, yScale } = transformInputData({ + data: DATA, + xKey: "x", + yKeys: ["y", "z"], + outputWindow: OUTPUT_WINDOW, + domain: { x: [0, 2.5], y: [0, 1.5] }, + }); + + expect(xScale(0)).toEqual(0); + expect(xScale(2.5)).toEqual(500); + expect(yScale(0)).toEqual(300); + expect(yScale(1.5)).toEqual(0); + }); + // TODO: Some day, test the gridOptions code. }); diff --git a/lib/src/cartesian/utils/transformInputData.ts b/lib/src/cartesian/utils/transformInputData.ts index 1a760edb..1e7a78d0 100644 --- a/lib/src/cartesian/utils/transformInputData.ts +++ b/lib/src/cartesian/utils/transformInputData.ts @@ -138,7 +138,8 @@ export const transformInputData = < const yScale = makeScale({ inputBounds: yScaleDomain, outputBounds: yScaleRange, - isNice: true, + // If user provided a domain, don't modify it + isNice: domain?.y?.[1] ? false : true, padEnd: typeof domainPadding === "number" ? domainPadding : domainPadding?.bottom, padStart: