Re: Dynamically generating Manipulate
- To: mathgroup at smc.vnet.net
- Subject: [mg87628] Re: Dynamically generating Manipulate
- From: dh <dh at metrohm.ch>
- Date: Tue, 15 Apr 2008 05:44:56 -0400 (EDT)
- References: <ftsd24$bbs$1@smc.vnet.net>
Hi Yaroslav,
there are some problems with HoldAll and Evaluate, but it can be done.
Here is a function that uses doit[] and draws whatever is in myStocks:
fu[myStocks_]:=Module[{n=Length[myStocks],vars,ctrls},
vars=Table[Unique[v],{n}];
ctrls={{#,True},{True,False},ControlPlacement->Bottom}&/@ vars;
With[{vars0=vars,ctrls0=Sequence@@ctrls},
vars=Thread[Interpretation[myStocks,vars]];
Manipulate[doit[vars0],ctrls0]]
]
hope this helps, Daniel
Yaroslav Bulatov wrote:
> I'm looking to make something like below, except that I want the
> Manipulate section to construct it's controls from "mystocks" list
> dynamically. What is the easiest way to achieve this?
>
> mystocks = {"CHYIX", "OREAX", "IGNBX","ZEUS"};
> doit[stocks_] := (
> poses = Position[stocks, True] // Flatten;
> DateListPlot[
> FinancialData[mystocks[[#]], "Jan. 1,2000"] & /@ poses]
> );
> Manipulate[doit[{s1, s2, s3}],
> {{s1, True}, {True, False},
> ControlPlacement -> Bottom}, {{s2, False}, {True, False},
> ControlPlacement -> Bottom}, {{s3, False}, {True, False},
> ControlPlacement -> Bottom}]
>