Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

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


  • Prev by Date: Re: Floor[] Not An Integer?
  • Next by Date: Re: Re: Re: odd mathematica blindspot
  • Previous by thread: Re: Using BarChart in a Widget
  • Next by thread: Re: Using BarChart in a Widget