How can I have the action button reveal the graph of a function that already exists in the calculator?
Absolutely!
Try something like this…
In calculator (note that “howGraph” should be in subscript)
f(x)=9x+1 {showGraph=1}
In the Graph’s CL
this.number("s_{howGraph}"): when myActionButton.pressCount>0 1 otherwise 0
The CL will set the showGraph variable to 1 or 0 depending on whether or not the button has been pressed at least once. The curly braces on the calculator are a restriction so that the function is only graphed when showGraph equals 1.
If that isn’t clear or doesn’t immediately work for you, let me know and I can make you an example to send you.
Thanks for the rapid response. Unfortunately I couldn’t get this to work. When I enter the command
this.number("s_{howGraph}"): when myActionButton.pressCount>0 1 otherwise
in the Graph CL I get an error “unterminated string” What is the this object, I don’t see it in the documentation. And why is the subscript notation used?
Thanks for your help.
Bruce Samuels
Take a look at this…
Again, let me know if that still doesn’t help.
Thanks so much, that works fine.
Is there a way to do this with having just a point to show up , instead of a whole function?
Yes, just put the condition inside the parentheses of the point.
Example:
A=(0,2 {s_howgraph=1})
It does affect the moveability though because the 2 gets “locked”, unless it’s determined by a function, although technically still not freely moveable.
A=(0,f(0) {s_howgraph=1})
Is there a way to make a button show and hide a graph? (click to show, click to hide, click to show, click to hide) for at least a few iterations?
Short answer is yes.
showGraph = numericValue("\mod(${yourButtonName.pressCount},2)")
This would cycle the variable between 0 and 1. If you want to hide an entire graph component, you could use:
hidden: showGraph = 0
Or if there are individual functions or points in a graph (as in my post above yours), you can set a variable in the graph to the variable above:
number("s_{howgraph}"): showGraph
You can do something similar to change the button label.
Thank you!! I am super new to this and do not understand coding at all. Can you tell me what all would I enter into the graph’s CL script?
Currently I have this entered, which makes the graph show up when the button is pressed:
number(“s_{howGraph}”): when button1.pressCount>0 1 otherwise 0
This:
showGraph = numericValue("\mod(${button1.pressCount},2)")
number("s_{howGraph}"): showGraph
The first line creates a variable that just exists in the CL. The second line sets a variable in the graph to the first.
THANK YOU!!! Literally so excited right now! Here’s an example of it!