Skip to main content

Actions and Tickers

Actions and tickers greatly expand what a Desmos graph can do by updating variables and running operations repeatedly.

Actions​

Action basics​

Define aa, then enter a->a+1. Desmos converts the arrow and recognizes the expression as an action. Press its action button to increase aa by one.

1
a=1a=1
2
a→a+1a\to a+1
Running an action to increase variable a

Multiple updates​

Comma-separated updates run simultaneously. Their right-hand sides use values from before the action runs.

1
a=2a=2
2
b=1b=1
3
a→a+1,b→aa\to a+1,b\to a

After one run, a=3,b=2a=3,b=2. One action cannot contain multiple update rules for the same variable.

Assigning actions to variables​

1
a=2a=2
2
b=1b=1
3
A=a→a+1A=a\to a+1
4
B=b→b+1B=b\to b+1
5
C=A,BC=A,B

Running CC runs AA and BB together. The same no-duplicate-update rule still applies.

Running an action by clicking a graph​

Points, curves, and labels can be made clickable and assigned an action.

Making an expression clickable and assigning an action
Loading graph…
Open in Desmos ↗

Click the “increase/decrease by 1” labels to change aa.

Tickers​

A ticker runs an action at a regular interval. Select “ticker” from the Add menu. If it is not listed, create an action first.

Selecting ticker from the Add menu

Enter an action in the Run field and an interval in milliseconds on the right, then use the metronome button to start it.

Setting a ticker action and interval

Measuring elapsed time with dt​

Heavy calculations may prevent a ticker from keeping its requested interval. This example runs t→t+1t\to t+1 every millisecond, but its displayed time drifts from real time.

Loading graph…
Open in Desmos ↗

The special variable dt\mathrm{dt} contains the elapsed milliseconds since the previous tick. Updating t→t+dtt\to t+\mathrm{dt} reduces dependence on device performance.

Using dt in a ticker
Loading graph…
Open in Desmos ↗

Lists and index​

When clicking one of several list-generated objects, the special variable index\mathrm{index} identifies which item was clicked.

Using index with a clickable list
Loading graph…
Open in Desmos ↗

Click the green circles to see a different update for each list item.