Skip to content

Commit

Permalink
Fixing to graph settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
catandthemachines committed Dec 19, 2024
1 parent a043f20 commit db4829f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions packages/perseus-editor/src/components/graph-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ function numSteps(range: any, step: any) {
return Math.floor((range[1] - range[0]) / step);
}
type Props = {
editableSettings: any[];
editableSettings: ReadonlyArray<
"canvas" | "graph" | "snap" | "image" | "measure"
>;
box: readonly number[];
labels: readonly string[];
range: Coords;
step: readonly number[];
gridStep: readonly number[];
snapStep: number[];
step: [number, number];
gridStep: [number, number];
snapStep: [number, number];
valid: boolean;
backgroundImage: any;
markings: "graph" | "grid" | "none";
Expand Down Expand Up @@ -100,7 +102,7 @@ class GraphSettings extends React.Component<Props, State> {
showTooltips: false,
};

_isMounted: any;
_isMounted = false;

constructor(props) {
super(props);
Expand Down Expand Up @@ -131,8 +133,6 @@ class GraphSettings extends React.Component<Props, State> {
}

UNSAFE_componentWillReceiveProps(nextProps) {
// Make sure that state updates when switching
// between different items in a multi-item editor.
if (
!_.isEqual(this.props.labels, nextProps.labels) ||
!_.isEqual(this.props.gridStep, nextProps.gridStep) ||
Expand Down Expand Up @@ -358,7 +358,9 @@ class GraphSettings extends React.Component<Props, State> {
const scale = Util.scaleFromExtent(ranges[i], this.props.box[i]);
if (this.validRange(ranges[i]) === true) {
step[i] = Util.tickStepFromExtent(ranges[i], this.props.box[i]);
// don't like this use of as. :(
// Need to use the cast to number since gridStepFromTickStep
// can return null or undefined. Ideally in the future let's adjust
// the code to take this into account.
gridStep[i] = Util.gridStepFromTickStep(step[i], scale) as number;
snapStep[i] = gridStep[i] / 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type Graph = {
box: ReadonlyArray<number>;
labels: ReadonlyArray<string>;
range: Coords;
tickStep: ReadonlyArray<number>;
gridStep: ReadonlyArray<number>;
tickStep: [number, number];
gridStep: [number, number];
markings: "graph" | "grid" | "none";
valid?: boolean;
};
Expand Down

0 comments on commit db4829f

Please sign in to comment.