Skip to content

Commit

Permalink
add symmetric mode for yaxis
Browse files Browse the repository at this point in the history
  • Loading branch information
riyavsinha committed May 10, 2024
1 parent 3155a4d commit 779fca4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/logo/YAxis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export type YAxisProps = {
zeroPoint?: number;
/** The y-axis label. Default is "bits". */
label?: string;
/** Whether the y-axis should show symmetric values in the positive and negative range. Defaults to true. */
symmetric?: boolean;
};

/**
Expand All @@ -32,11 +34,14 @@ export const YAxis = ({
height,
numTicks,
width,
// zeroPoint = 1.0,
symmetric = true,
label = "bits",
}: YAxisProps) => {
// const ticks = xrange(max + 1);
min = min < 0 ? min : 0;
if (symmetric && min < 0) {
min = Math.min(-max, min);
max = Math.max(-min, max);
}
const intMin = Math.ceil(min);
const intMax = Math.floor(max);
const _numTicks = numTicks || intMax - intMin;
Expand Down

0 comments on commit 779fca4

Please sign in to comment.