Re: Re: Using BarChart in a Widget

*To*: mathgroup at smc.vnet.net*Subject*: [mg56566] Re: [mg56539] Re: Using BarChart in a Widget*From*: Jeff Adams <jeffa at wolfram.com>*Date*: Fri, 29 Apr 2005 03:20:20 -0400 (EDT)*References*: <d4kl1t$edj$1@smc.vnet.net><d4mrr2$1u9$1@smc.vnet.net> <200504280640.CAA24677@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

On Apr 28, 2005, at 1:40 AM, Brett Patterson wrote: > Hi David, > > Thanks for the reply. > > Perhaps you could tell me what's wrong with the bar orientation in the > following: > > GUIRun[Widget["Panel", { > > Widget["MathPanel", {"preferredSize" -> > Widget["Dimension", {"width" -> 300, " > height" -> 300}]}, Name -> "zplot", > WidgetLayout -> {"Stretching" -> {True, Maximize}}], > > BindEvent["componentResized", Script[updateZernikes[]]], > > Script[updateZernikes[] := Block[{$DisplayFunction = Identity}, > Needs["Graphics`Graphics`"]; > expr = Show[ToExpression[" > Graphics`Graphics`BarChart"][bardata = Table[Random[] - 0.5, { > 13}], BarOrientation -> Horizontal]]; > SetPropertyValue[{"zplot", " > mathCommand"}, ToString[expr, InputForm]]] > ] > } > ] > ] > > The problem is that the bars are display vertically, even though I > specify BarOrientation -> Horizontal! > > Thanks for your help. > > Regards, > Brett Patterson Hello, I notice that you are trying to work around the issue that a single evaluation of a Mathematica expression when loading new symbols with Needs, does not provide those symbols during the evaluation (hence the use of ToExpression["Graphics`Graphics`BarChart"]) The problem you are running into is that there are other symbols in that expression that are in the Graphics` context and you would need to explicitly use full contexts for all of them. Fortunately, the recommended way of loading packages that are needed in GUIKit Scripts is to load them in separate Script[]s so that subsequent Scripts will know about those symbols and there is no need for explicit contexts. This is identical to how you would load packages and use them with webMathematica and jsp pages. So I would suggest the following form which eliminates the need for any full contexts and makes all the Graphics` contexted symbols known: GUIRun[ Widget["Panel", { Script[Needs["Graphics`Graphics`"]], Widget["MathPanel", {"preferredSize" -> Widget["Dimension", {"width" -> 300, "height" -> 300}]}, Name -> "zplot", WidgetLayout -> {"Stretching" -> {True, Maximize}}], BindEvent["componentResized", Script[updateZernikes[]]], Script[updateZernikes[] := Block[{$DisplayFunction = Identity}, expr = Show[BarChart[bardata = Table[Random[] - 0.5, {13}], BarOrientation -> Horizontal]]; SetPropertyValue[{"zplot", "mathCommand"}, ToString[expr, InputForm]]]] }] ] Jeff Adams Wolfram Research

**References**:**Re: Using BarChart in a Widget***From:*"Brett Patterson" <muckle.moose@gmail.com>