I want to control the variables (and other options) used in a plot through a number of popup menus. As the plot takes a little time to be drawn, I want to be able to make a selection on each of the popup menus before the plot is drawn.
As a bonus challenge, I'd like the user to be able to control when the plot is drawn by pressing a button - however, I want to deploy this using Mathematica Online and Button
cannot be cloud deployed.
Below is a toy example of my code so far. I use dynamic to link the popup menus to the plot. The problem is that it is a little too dynamic. I have tried using hold and unevaluated, then releasing/evaluating with a button but I couldn't get it to work.
(* create an association of variable values (random numbers) and variable names, a to e *)
values = AssociationThread[CharacterRange["a", "e"],RandomReal[{0, 1}, {5, 10}]];
(* define variable names *)
vars = Keys@values;
DynamicModule[{xvalue, yvalue},{
(* x value popup menu *)
PopupMenu[Dynamic[xvalue], vars],
(* x value popup menu *)
PopupMenu[Dynamic[yvalue], vars],
(* the plot *)
Dynamic[ListPlot[Transpose[{values[xvalue], values[yvalue]}]]]}]
So my two questions are:
- How can I let the user control the evaluation of the plot such that they can choose all options from popup menus before evaluating the plot?
- Is there a cloud-deployable alternative to
Button
?
Any suggestions would be much appreciated!