cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
antonio-domenic
Level III

how correctly use Graph Builder and Slider box in different windows

I would use graph builder in combination with slider to change the appearance of the plot. In the example below I create a window with a map and a slider box to change interactively the scale of the colors. I would use the script to create different windows (of course, even with different variables, but in the example this stuff is not needed). It works just for the last created window, despite I try to assign the variables using namespaces. I tried different way but all unsuccessfully. Can anyone help?

 

Names Default To Here(1);
dtable= Open("$SAMPLE_DATA/SAT.jmp");
name="Map";
For(k=1, k<=10, k++,
    If(Namespace Exists(Eval("ns" || name || Char(k))),
        //If(k = 10,
        // hanlde the max number of allowed namespaces
        //);
      ,
    name= name || char(k);
    nsRef = New Namespace(Eval("ns" || name ));
    Break();
      )
);
 
nsRef << Insert("column", "% Taking (2004)");
nsRef << Insert("min", col min(column(dtable, "% Taking (2004)")));
nsRef << Insert("max", col max(column(dtable, "% Taking (2004)")));
nsRef << Insert("slmin", col min(column(dtable, "% Taking (2004)")));
nsRef << Insert("slmax", col max(column(dtable, "% Taking (2004)")));
 
datacolumn=column(dtable, nsRef:column );
 
nsRef << Insert("slider1",
    slider box(nsRef:min,nsRef:max,nsRef:slmax,
        title= Current Window() << Get Window Title;
        ns = NameSpace(Eval("ns" || title));
             slmin=ns:slmin;
                slmax=ns:slmax;
        scale=Matrix( {slmin,slmax} );
             scale=scale`;
        ns:gb <<SendToReport( 
                       Dispatch({},"400",
                       ScaleBox,
                           {Legend Model( 3,
                           Properties(0,{gradient( {Scale Values( scale ), Width( 12 )} )})
                            )}
                      )
               );
        );
);
 
new window(name,
nsRef << Insert("gb",
          Graph Builder(
             Show Control Panel( 0 ),
             Variables( Color( datacolumn ), Shape( :State ) ),
             Elements(
                                  Map Shapes(
                      Legend( 2 ),
                      Summary Statistic( "Mean" ),
                      Show Missing Shapes( 0 )
                                 )
                          ),
                          SendToReport(
                                 Dispatch({},"",
                               ScaleBox,
                   {Scale( "Geodesic" ), Min( -137.654643872302 ), Max( -63.2427990180921 ),
                   Inc( 10 ), Minor Ticks( 0 )}
 
                                ),
                                Dispatch({},"",
                     ScaleBox( 2 ),
                     {Scale( "Geodesic" ), Min( 16.7170042692343 ), Max( 80.0833409028976 ),
                     Inc( 10 ), Minor Ticks( 0 )}
                          )
                     )
               ),
 ),
H List Box(
Text Box("scale: max"),
      nsRef:slider1,
),
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: how correctly use Graph Builder and Slider box in different windows

You are movng in the correct direction. You do need a local space, and depending upon the task here are several options, that I would recommend:

 

  1. Since you are only changing the legend, and each GB will be in a separate window, a simple method to do this is to use the window scope, window namespace window:slider1 = SliderBox(). See the attached script.  
  2. If only the legend is being changed and if you have multiple GBs in the window, use a  <<Set Function( Function()) for the slider box that uses a relative reference to the corresponding GB. If the GB, and HListBox(TextBox, Sliderbox) are nested in a VListBox the function would be something like  (this<< parent)<<parent to get to theVListBox then you can use messages to get to the legendbox and make the changes.  I like to use Xpath(). This type of coding is a little trickier.
  3. Suppose you have multiple GBs with different Y's  but same X. If you wanted to limit X  or exclude a row for Y1 but not Y2, then each GB should have its own Data Filter Context Box(), local data filter.

Hopefully, the attached script that uses window scoping will meet your  current need.

View solution in original post

2 REPLIES 2
gzmorgan0
Super User (Alumni)

Re: how correctly use Graph Builder and Slider box in different windows

You are movng in the correct direction. You do need a local space, and depending upon the task here are several options, that I would recommend:

 

  1. Since you are only changing the legend, and each GB will be in a separate window, a simple method to do this is to use the window scope, window namespace window:slider1 = SliderBox(). See the attached script.  
  2. If only the legend is being changed and if you have multiple GBs in the window, use a  <<Set Function( Function()) for the slider box that uses a relative reference to the corresponding GB. If the GB, and HListBox(TextBox, Sliderbox) are nested in a VListBox the function would be something like  (this<< parent)<<parent to get to theVListBox then you can use messages to get to the legendbox and make the changes.  I like to use Xpath(). This type of coding is a little trickier.
  3. Suppose you have multiple GBs with different Y's  but same X. If you wanted to limit X  or exclude a row for Y1 but not Y2, then each GB should have its own Data Filter Context Box(), local data filter.

Hopefully, the attached script that uses window scoping will meet your  current need.

antonio-domenic
Level III

Re: how correctly use Graph Builder and Slider box in different windows

excellent!! simple and effective. I appreciate your additional suggestions.
Thanks a lot!