MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

DynamicModule question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88549] DynamicModule question
  • From: "J. McKenzie Alexander" <jalex at lse.ac.uk>
  • Date: Thu, 8 May 2008 04:13:19 -0400 (EDT)

Can someone please explain to me why the following happens?  It's a  
silly little example to illustrate a problem I ran into recently...

First, evaluate the following in separate cells:

	Needs["PieCharts`"];

	data = {.25, .75}

Then evaluate the following:

	DynamicModule[{size = 300},
	 Column[{
	   Slider[Dynamic[size], {100, 500}],
	   Dynamic[PieChart[data, ImageSize -> size]]
	   }]
	 ]

Notice that you can not only resize the graphic by  dragging the  
slider, but if you change the definition of data, that's reflected  
automatically in the graphic as well.

However, suppose you wrap the DynamicModule in a function like so:

	foo[data_] := DynamicModule[{size = 300},
	  Column[{
	    Slider[Dynamic[size], {100, 500}],
	    Dynamic@PieChart[data, ImageSize -> size]
	    }]
	  ]

Now evaluate

	foo[ data ]

If you change the definition of data in the notebook, the second  
DynamicModule doesn't update the pie charts. I don't understand what  
breaks when you wrap the DynamicModule in a function definition.

Many thanks!

Jason


--
Dr J. McKenzie Alexander
Department of Philosophy, Logic and Scientific Method
London School of Economics and Political Science
Houghton Street, London WC2A 2AE




Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm


  • Prev by Date: Re: ListDensityPlot with irregular data and InterpolationOrder
  • Next by Date: Re: Question on the Limiting Value of Ratios of Consecuative Primes...
  • Previous by thread: Re: A bug in Show[]?
  • Next by thread: Re: DynamicModule question