Skip to content

Commit

Permalink
Fixing weird editor save bugs + renaming function
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicScrewdriver committed Aug 28, 2024
1 parent d4a4fd5 commit cde544d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ const YGridTick = ({y, range}: {y: number; range: [Interval, Interval]}) => {

// If the graph displays both the y and x axis lines within the graph, we want
// to hide the label at -1 on the y-axis to prevent overlap with the x-axis label
const hideNegative1 = range[X][MIN] < 0 && range[X][MAX] > -1;
const showLabel = shouldShowLabel(y, range);

return (
<g className="tick">
<line x1={x1} y1={y1} x2={x2} y2={y2} style={tickStyle} />
{hideNegative1 && y === -1 && (
{showLabel && (
<text
height={20}
width={50}
Expand Down Expand Up @@ -141,6 +141,20 @@ const XGridTick = ({x, range}: {x: number; range: [Interval, Interval]}) => {
);
};

// Determines whether to show the label for the given tick
// Currently, the only condition is to hide the label at -1
// on the y-axis when the x-axis is within the graph
const shouldShowLabel = (number: number, range: [Interval, Interval]) => {
let showLabel = true;

// If the x-axis is within the graph and the y-axis is at -1, hide the label
if (range[X][MIN] < 0 && range[X][MAX] > -1 && number === -1) {
showLabel = false;
}

return showLabel;
};

export function generateTickLocations(
tickStep: number,
min: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ describe("MafsGraph", () => {
]);
});
});
calculateNestedSVGCoords;
});

describe("calculateNestedSVGCoords", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ export const MafsGraph = (props: MafsGraphProps) => {
range={state.range}
containerSizeClass={props.containerSizeClass}
markings={props.markings}
width={width}
height={height}
/>
{/* Axis Ticks, Labels, and Arrows */}
{
Expand Down

0 comments on commit cde544d

Please sign in to comment.