
I've been happy with my development in the Wolfram Language but haven't played with deploying manipulatable content before. I've written a rather basic Manipulate
function to let users explore changing chord lengths on a spline. It's working as expected in my local notebook. It initializes a random spline and then lets the user change the chord length, and if desired choose a new random spline. However, when I deploy the function to the cloud (it's actually composed of 7 functions with the main two viz functions listed below) it unforuately triggers new random spline whenever the slider is moved. It's slow and not the desired behaviour. I isolated the set of functions in a new notebook and still the behaviour persists. I think I'm missing something about how variables are different locally and deployed. Does anyone have any suggestions about how to correct this behaviour?
dynamicViz[controlpoints_, step_] := Module[{var, curve, results},
curve = DiscretizeGraphics[BSplineCurve[controlpoints]];
results = objectiveFunction[controlpoints, step];
Graphics[{
{Orange, AbsoluteThickness[3], MeshPrimitives[curve, 1]},
{Red, AbsoluteThickness[5], Line@results[["points"]]},
{Black, AbsolutePointSize[7], Point /@ results[["points"]]}
},
PlotLabel -> Style[
"Chord Length: " <> ToString@step <>
" | Error: " <>
ToString@Round[results[["error"]] , 0.1] <>
" | Count: " <>
ToString@Length@(results[["points"]] - 1),
20, FontFamily -> "Sans Source Pro"
],
AspectRatio -> Automatic,
ImageMargins -> 20,
ImageSize -> 700,
Frame -> True,
GridLines -> Automatic
]
]
CloudDeploy[
Manipulate[
dynamicViz[pts, step], {{step, 2000, Style["Chord Length", 20]}, 300,
4000, 20}, Button["New Spline", pts = control],
Initialization :> {pts = control}]
]
Currently this deployed public version is active as of Dec 18 2020 so one can see the behaviour.