Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I am executing this code in notebook, there is no error but when I am deploying it in CDF, this error is coming.

$RecursionLimit::reclim: Recursion depth of 256 exceeded. >>

The code is

With[{y1 = {1, 2, 2, 1, 7}, y2 = {0, 3.27, 4.188, 7.331, 4.694}}, 
 Column[
   { Spacer[70], 
     Text[Style["iPhone and iPad quarterly sales- units, million", Bold, 18]], 
     Column[
       {Spacer[70], 
        Text[Style["Click on/off:", Bold, 14]], 
        q1 = True; q2 = True;
        Row[
          {Labeled[
             Button["     ", q1 = ! q1, Background -> Blue, Appearance->"Frameless"],
             "iPhone", {Right}
           ], 
           Spacer[19], 
           Labeled[
             Button["     ",q2 =!q2,Background -> Orange, Appearance -> "Frameless"], 
            "iPad", {Right}
           ]
          }
         ], 
         Column[
           {Dynamic@ BarChart[
                       Table[{If[q1, y1[[i]], 0], If[q2, y2[[i]], 0]},{i, 1, 5,  1}], 
                       BarSpacing -> 0.8, ChartStyle -> {Blue, Orange}, 
                       ImageSize -> {600, 280}, 
                       GridLines -> {None, Automatic}
                     ]
           }
         ]}]}]]

Mathematica graphics

I have tried using

$RecursionLimit = Infinity  

But it has not worked. Please help.

share|improve this question
    
There was one missing comma in your code. I've corrected that. Does that make a difference? –  Sjoerd C. de Vries Jun 13 '12 at 19:52
    
@SjoerdC.deVries: Now buttons are not working in cdf. But there is no error coming. –  Jennifer Jun 13 '12 at 20:16

1 Answer 1

up vote 6 down vote accepted

I got it to work in my browser by replacing the first line by

DynamicModule[{y1 = {1, 2, 2, 1, 7}, y2 = {0, 3.27, 4.188, 7.331, 4.694}, q1, q2}

It has probably to do with this statement in the documentation:

All interactive content must be generated with the Manipulate command

(and DynamicModule with all necessary variables localized is a good Manipulateproxy).

share|improve this answer
    
Thanks.....it is working. But can you tell me why it was not working earlier when I was using "With"? –  Jennifer Jun 13 '12 at 20:55
    
You can try the CDF here –  Sjoerd C. de Vries Jun 13 '12 at 20:59
    
@Jennifer explanation below the line of code –  Sjoerd C. de Vries Jun 13 '12 at 21:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.