Message Boards Message Boards

1
|
3700 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Strange (updating) behaviour of dynamic sliders deployed to the cloud

Posted 8 years ago

(Testsystem: Windows 7, Mathematica 10.3.1.0, Firefox 24.0) Try the following:


gui[] := DynamicModule[
  {a, b, c, d},
  Row[{
    Column[{
      Slider[Dynamic[a], {0, 2}],
      Slider[Dynamic[b], {0.1, 2.1}],
      Slider[Dynamic[c], {0, 2.1*Pi}],
      Slider[Dynamic[d], {0, 2*Pi}]
      }],
    Dynamic[
     Plot[a * t + b * t^2 + c * t^(-2) + d * t^(-1), {t, 0, 10}, 
      PlotRange -> {{0, 10}, {-10, 10}}]]
    }]
  ]

CloudConnect[]
CloudDeploy[gui[]]

And check out the result in a web browser - and wonder... ...why just the movement of the last dynamic slider (the one connected to variable d) leads to an update of the belonging dynamic plot. It seems that just the product of an integer with a constant alike Pi in the slider's range is able to accomplish a proper updating behaviour of the slider/plot!?

(Note that the behaviour in a Mathematica Notebook differs from said behaviour in a webbrowser)

Any idea why? Any idea how to improve the situation in a webbrowser/cloud without corrupting the (relatively proper) behaviour in a notebook?

Regards, Dominik

PS: By the way, it is not helpful, that the post preview differs significantly from my input - e.g. an 'at' is transformed to an 'at' - which is definitely not the same (without a space in between!!) - so I had to insert some spaces around the '' manually...

POSTED BY: Dominik Niedenzu
2 Replies

Dear Sean,

Thanks for answering and forwarding!

Awsome, if I got it right, you perhaps found another pecularity in the vicinity of slider ranges... It might be connected to what I meant - at least in terms of the underlying Mathematica code - but I am not sure... :)

Perhaps I have to render my description of the problem more precisely:

1) Copy my code-block gui[]:=DynamicModule[ ... ] from above and paste it into a fresh Mathematica Notebook 2) Evaluate it 3) Write and evaluate: gui[] 4) Move the last slider (must be moved first, else you see nothing) - the plot is dynamically updated 5) Now move any other slider - the plot then is dynamically updated too

Try the same procedure but instead of 3) you write and evaluate: CloudConnect[] CloudDeploy[gui[]] and instead of checkinging out anything in the Notebook check out the example in the webbrowser with the www-address given by the deploy command - you then (hopefully) will see, that 4) is still true whereas 5) is not.

In other words, the plot then is just updated when the (last) slider connected to the variable d is moved. Moving the other sliders does not have any effect on the plot. That means: the (updating) behaviour in a Notebook is another than that in a Webbrowser / Cloud. That's what I meant and what drove me crazy said night...

I do not have any insight in the underlying Mathematica code but my first guess would be that this behaviour might be due to: + the code for updating in connection with Dynamic does not run in the kernel and it expects an integer (=> b, c fails...) + the constant Pi is available just in the kernel, so that evaluating the expression 2 * Pi (=> d) somehow might trigger a communication between kernel and GUI leading to triggering the update of the plot too - or alike...???

Regards from the other side of the atlantic pond Dominik

POSTED BY: Dominik Niedenzu

That is strange. The behavior is wrong, but it's the same both in Mathematica and in the Cloud.

Fortunately, you can easily solve the problem by either

  • Initializing the value of the variables in the module
  • Giving your Slider's range in floating point instead of symbolic numbers.

To do that letter, wrap N[] around 2 Pi.

I've forwarded a simple example of the issue to the developers so that they can take a look at it:

DynamicModule[{x}, {Slider[Dynamic[x, 2 Pi]], Dynamic[x]}]

As you can see in this example, the value of x isn't initialized to 0. The problem only seems to happen when the slider's range is a symbolic number containing some operation.

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract