-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set math bounds #4
Comments
I found this in the source of the desmos types, so it seems like the feature is supported - unsure how to use it though: /**
* Updates the math coordinates of the graphpaper bounds.
* If invalid bounds are provided, the graphpaper bounds will not be changed.
*/
setMathBounds(bounds: { left?: number; right?: number; bottom?: number; top?: number }): void; |
Also wondering if observers are supported: https://www.desmos.com/api/v1.6/docs/index.html#managing-observers Similarly to math bounds, it's a method on calculator |
All Desmos methods on the calculator are accessible by passing a ref to function Demo() {
const calc = React.useRef<Desmos.Calculator>();
React.useEffect(() => {
calc.current.setMathBounds({
left: -20, right: 20,
bottom: -20, top: 20
});
}, [calc]);
return (
<GraphingCalculator
attributes={{className: "calculator"}}
fontSize={18} keypad projectorMode
ref={calc}
>
<Expression id="slider" latex="a=3" />
<Point />
</GraphingCalculator>
);
} |
Hi there, Thanks for this, I'm now using your example, but when I use I receive this error, on line ref={calc_ref}: Type 'MutableRefObject<Calculator | undefined>' is not assignable to type 'Ref<Calculator> | undefined'.
Type 'MutableRefObject<Calculator | undefined>' is not assignable to type 'RefObject<Calculator>'.
Types of property 'current' are incompatible.
Type 'Calculator | undefined' is not assignable to type 'Calculator | null'.
Type 'undefined' is not assignable to type 'Calculator | null'.ts(2322) Update: Generating a mutable ref is what's expected in the documentation: https://reactjs.org/docs/hooks-reference.html#useref Update2: Seems to be a common issue: DefinitelyTyped/DefinitelyTyped#35572 Update3: Resolved, by replacing the first line with |
(old question was here) |
Oh it might be worth including your above example in the documentation - I'm sure someone else might find it as useful as I did! |
This may just be a documentation issue, but I wish to set the bounds on the graph (which is typically done with "setMathBounds" (see here: https://www.desmos.com/api/v1.7/docs/index.html#document-layout)
Does desmos-react support the various methods on GraphingCalculator? Is so, could there perhaps be an example of this in the documentation?
Thanks,
Mark
The text was updated successfully, but these errors were encountered: