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
spudton
Level III

Use list box to change the root name of multiple variables in a time series plot

Hi, I'm trying to give the user the ability to choose a tag name, and create a time series plot of multiple variables that have that tag name as their root.

However, I'm struggling on how to dynamically update that.

The list box contains a list of tags , then the variables to be plotted will have that tag name, plus an extension, .PV, .ETARG, etc in this example.

spudton_0-1593967671313.png

 

I parse the  following statement to generate the variable names

 

				vars = {};
					str = "Variables(
		X( :Time ),
		Y( :" || TAG || ".ETARG, Position (1) ),
		Y( :" || TAG || ".LO, Position( 1 ) ),
		Y( :" || TAG || ".PV, Position( 1 ) ),
		Y( :" || TAG || ".UP, Position( 1 ) )
	)";
					vars = parse(str);

then the graph builder references these, instead of having fixed tags to plot

Eval Expr(		
	DataTable1<<Graph Builder(
						Size( 466, 405 ),
						Show Control Panel( 0 ),
						Fit to Window( "Maintain Aspect Ratio" ),
						Expr(Name Expr(vars)),
						Elements(
							Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 3 ) )
						),

I have a list box where the user can choose the root name of the variables

ChooseET = List Box( ( ET_TAG_LIST ),
					maxSelected( 1 ),
					onChange(
						TAG = ChooseET << Get Selected;

But the variable names in the graph builder are static. How do I make this dynamic? I've tried making the list box an expression within the graph builder, but this doesn;t work.

the list box and graph builder are within an allocate statement. I'm not sure what this is and how relevant that is.

thanks in advance, here's the full code!

JMP App(
	Set Name( "Application" ),
	Set Description(
		"An empty workspace for creating custom applications with one or more windows and scripts"
	),
	Auto Launch( 1 ),
	Snap To Grid( 1 ),
	Show Grid( 1 ),
	Show Properties( 1 ),
	Show Sources( 1 ),
	Group By Category( 1 ),
	Dashboard Mode( 0 ),
	Parameters,
	Tables(
		DataTable1 = GuiTable(
			Set Path( "" ),
			Set Label( "Output Table" ),
			Set Location( "Current Data Table" ),
			Set Invisible( 0 )
		)
	),
	Script(JSL Quote(// This script is executed when the application is run.
// Named objects have been created for the application modules
// (for example, "Module1") and the pre-defined object
// "thisApplication" refers to the application object itself.
// Variables and functions declared here are scoped to the
// Application namespace.

dt = Current data table();
					ETSelected = "A04004DD";
					TAG = ETSelected;;
					vars = {};
					str = "Variables(
		X( :Time ),
		Y( :" || TAG || ".ETARG, Position (1) ),
		Y( :" || TAG || ".LO, Position( 1 ) ),
		Y( :" || TAG || ".PV, Position( 1 ) ),
		Y( :" || TAG || ".UP, Position( 1 ) )
	)";
					vars = parse(str);
					show(vars);

	PDChartproperties = "	
			{Legend Model(
				3,
			Properties( 0, {Line Color( 4 )}, Item ID( \!"" || TAG ||".ETarg\!", 1 ) ),
				Properties(	1, {Line Color( 19 ), Marker Size( 1 )}, Item ID( \!"" || TAG ||".LO\!", 1 ) ),
				Properties( 2, {Line Color( 53 )}, Item ID( \!"" || TAG ||".PV\!", 1 ) ),
				Properties( 3, {Line Color( 19 ), Marker Size( 1 )},Item ID( \!"" || TAG ||".UP\!", 1 )
					)
			)}
				";
    props = parse(PDChartproperties);
    show(props);


dt = Current Data Table();
ET_LIST = {};
ET_TAG_List = {};
For( i = N Col( dt ), i >= 1, i--,
ET_col = Column (dt, i) << Get Name ();
       If(
       (Col N Missing( Column( i ) ) / N Row()) != 1 &
       Contains (ET_col, "ETarg"),
       Insert Into(ET_LIST, ET_col);
       );
	   );

Show (ET_LIST);


n = N Items( ET_LIST );
For( i = 1, i <= n, i++,
	ETARG = ET_LIST[i] ;
	NFull = Length(ETARG) ; 
	ETTAG = Left(ETARG,(NFull-6)) ;
Insert Into(ET_TAG_List, ETTAG);


);	
	Show(ET_TAG_List);
) ),
	Allocate(
		Module1 = Plan(
			PreAllocate,
			Script(JSL Quote(// This script is executed when a new module instance is
// created.  The pre-defined object "thisModuleInstance" refers
// to the instance object, but other objects such as boxes and
// scripts have not yet been created.  Variables declared here are
// scoped to the ModuleInstance namespace.

// This special function will receive parameters passed to CreateInstance()
OnModuleLoad({},
);

thisModuleInstance << Create Objects;

// After this point your module instance objects have been created
// and can be referred to by name (for example, "Button1").

ColList1Select=Function({this},{selectedIndices},
	// This function is called when the List Box selection changes
	selectedIndices = this << Get Selected Indices;
);


)			),
			Allocate(
				DataFilterContext1 = Data Filter Context Box();
				Lineup2 = Lineup Box();
				Report3 = Platform(
					DataTable1,
					Distribution(
						Continuous Distribution(
							Column( :A04004DD ET_DELTA Ratio )
						),
						SendToReport(
							Dispatch(
								{"A04004DD ET_DELTA Ratio"},
								"1",
								ScaleBox,
								{Min( -5 ), Max( 5 ), Inc( 0.1 ), Minor Ticks( 0 )}
							),
							Dispatch(
								{"A04004DD ET_DELTA Ratio"},
								"Quantiles",
								OutlineBox,
								{Close( 1 )}
							),
							Dispatch(
								{"A04004DD ET_DELTA Ratio"},
								"Summary Statistics",
								OutlineBox,
								{Close( 1 )}
							)
						)
					)
				);
				Report1 = Platform(
					DataTable1,
					Graph builder(
						Size( 430, 370 ),
						Show Control Panel( 0 ),
						Fit to Window( "Maintain Aspect Ratio" ),
						Variables(
							X( :Time ),
							Y( :ZZ ET Metric ),
							Y( :A04004DD ET_Pass, Position( 1 ) ),
							Y( :A04004DD ET_Pass Ave, Position( 1 ) )
						),
						Elements( Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 3 ) ) ),
						SendToReport(
							Dispatch(
								{},
								"Time",
								ScaleBox,
								{Min( 3675484152 ), Max( 3676021620 ),
								Interval( "Day" ), Inc( 5 ), Minor Ticks( 0 )}
							)
						)
					)
				);
				ChooseET = List Box( ( ET_TAG_LIST ),
					maxSelected( 1 ),
					onChange(
						TAG = ChooseET << Get Selected;
						If( N Items( TAG ) != 0,
							Show( TAG );
						);
					) );
				DataFilter1 = DataTable1 << Data Filter(
					Local,
					Add Filter(
						columns( :Day ),
						Display( :Day, Size( 0, 0 ), Height( 0 ) )
					)
				);
				Report2 = Platform(
					DataTable1,
					gb = Eval(
	Eval Expr(		
	DataTable1<<Graph Builder(
						Size( 466, 405 ),
						Show Control Panel( 0 ),
						Fit to Window( "Maintain Aspect Ratio" ),
						Expr(Name Expr(vars)),
						Elements(
							Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 3 ) )
						),
						SendToReport(
							Dispatch(
								{},
								"400",
								ScaleBox,
								Expr(Name Expr(props)),
							)
						)
					)
					)
					)
				);
			),
			Organize(
				Reparent( Lineup2( Report2 ) );
				Reparent( Lineup2( DataFilter1 ) );
				Placeholder( Lineup2 );
				Reparent( Lineup2( ChooseET ) );
				Reparent( Lineup2( Report1 ) );
				Reparent( Lineup2( Report3 ) );
				Reparent( DataFilterContext1( Lineup2 ) );
				Relocate( DataFilterContext1( 70, 20 ) );
			),
			Initialize(
				DataFilterContext1 << Background Color( 2147483647 );
				DataFilterContext1 << Border(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				);
				DataFilterContext1 << Enabled( 1 );
				DataFilterContext1 << Horizontal Alignment( "Default" );
				DataFilterContext1 << Margin(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				);
				DataFilterContext1 << Padding(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				);
				DataFilterContext1 << Text Color( 2147483647 );
				DataFilterContext1 << Vertical Alignment( "Default" );
				DataFilterContext1 << Visibility( "Visible" );
				Lineup2 << N Col( 2 );
				Lineup2 << Background Color( 2147483647 );
				Lineup2 << Border( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Lineup2 << Enabled( 1 );
				Lineup2 << Horizontal Alignment( "Default" );
				Lineup2 << Margin( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Lineup2 << Padding( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Lineup2 << Text Color( 2147483647 );
				Lineup2 << Vertical Alignment( "Default" );
				Lineup2 << Visibility( "Visible" );
				Lineup2 << Spacing( 2 );
				Report3 << Background Color( 2147483647 );
				Report3 << Border( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Report3 << Enabled( 1 );
				Report3 << Horizontal Alignment( "Default" );
				Report3 << Margin( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Report3 << Padding( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Report3 << Text Color( 2147483647 );
				Report3 << Vertical Alignment( "Default" );
				Report3 << Visibility( "Visible" );
				Report3 << set horizontal( 0 );
				Report1 << Background Color( 2147483647 );
				Report1 << Border( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Report1 << Enabled( 1 );
				Report1 << Horizontal Alignment( "Default" );
				Report1 << Margin( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Report1 << Padding( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Report1 << Text Color( 2147483647 );
				Report1 << Vertical Alignment( "Default" );
				Report1 << Visibility( "Visible" );
				Report1 << set horizontal( 0 );
				ChooseET << Background Color( 2147483647 );
				ChooseET << Border( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				ChooseET << Enabled( 1 );
				ChooseET << Horizontal Alignment( "Default" );
				ChooseET << Margin( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				ChooseET << Padding(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				);
				ChooseET << Text Color( 2147483647 );
				ChooseET << User Resizable( {1, 1} );
				ChooseET << Vertical Alignment( "Default" );
				ChooseET << Visibility( "Visible" );
				ChooseET << Set Size( 269, 174 );
				ChooseET << Set N Lines( 10 );
				ChooseET << Set Base Font( "Text" );
				ChooseET << Set Font Scale( 1 );
				ChooseET << Set Min Size( 269, 174 );
				ChooseET << Set Max Size( 269, 174 );
				ChooseET << Set Auto Stretching( 0, 0 );
				DataFilter1 << Background Color( 2147483647 );
				DataFilter1 << Border(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				);
				DataFilter1 << Enabled( 1 );
				DataFilter1 << Horizontal Alignment( "Default" );
				DataFilter1 << Margin(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				);
				DataFilter1 << Padding(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				);
				DataFilter1 << Text Color( 2147483647 );
				DataFilter1 << Vertical Alignment( "Default" );
				DataFilter1 << Visibility( "Visible" );
				Report2 << Background Color( 2147483647 );
				Report2 << Border( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Report2 << Enabled( 1 );
				Report2 << Horizontal Alignment( "Default" );
				Report2 << Margin( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Report2 << Padding( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} );
				Report2 << Text Color( 2147483647 );
				Report2 << Vertical Alignment( "Default" );
				Report2 << Visibility( "Visible" );
				Report2 << set horizontal( 0 );
			)
		)
	),
	Initialize(
		Module1 << Auto Launch( 1 );
		Module1 << Set Module Type( "Report" );
		Module1 << Set Window Title( "^TABLENAME - ^APPNAME" );
		Module1 << Set Min Size( 0, 0 );
		Module1 << Set Max Size( 30000, 30000 );
		Module1 << Set Auto Stretching( ., . );
	)
) << Run
1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Use list box to change the root name of multiple variables in a time series plot

@spudton,

 

Messages available for one JMP platform might not be available on others. The GraphBuilder platform allows a a user via the UI to drag and drop to add and remove variables. Hence, JSL implemented an Add Variable() and Remove Variable() to the GraphBuilderBox.

 

Distribution has no such interface, so there is no method to add and remove variables.  The JMP Scripting Index, found under the Help menu will show most if not all of the messages available for a platform.  Main Menu > Help > Scripting Index > Object s(top left corner field) > Distribution.

 

You will find there is typically more than one method to do something using JSL.  A couple options are:

Option: Change your distribution platform to be a GraphBuilder that creates a distribution. It will not have the same options or look the identical. However you can add and remove variables

gbdist =Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( Y( :A04004DD ET_DELTA Ratio ) ),
	Elements( Histogram( Y, Legend( 3 ), Counts( 1 ) ) )
);

Option: Use a container for your distribution. You need to have a placeholder in your display for it. Then when changing a variable, you delete the existing Distribution in that container, then add a new one. Recall I said there were items to clean up in your code. I did not clean all of them.

The code has an empty container, Lineup2. If you make Report3, nested within that box. Actually I'd change it to a VListBox since you are not using the power of the LineupBox. 

				Lineup2 = Lineup Box();
				Report3 = Platform(
					DataTable1,
					Distribution(
						Continuous Distribution(
							Column( :A04004DD ET_DELTA Ratio )
						),

Below is a portion of the script 7_InteractiveDisplays.jsl written for JSL Companion Applications of the JMP Scripting Language, 2nd  Edition.

clear globals();
orig_dt = Open( "$SAMPLE_DATA/Fitness.jmp" );

cnt = 0; Chosen Columns={};  //initiate values

//----Refresh display script---------------------------
refresh_script = Expr(
   Try(dist_vlist << delete);
   	If( (cnt > 0 & N Items( Chosen Columns ) >= 1),
   	  show(Chosen Columns);
	  dist_vlist = VListBox(
		orig_dist = orig_dt << Distribution( Column( Eval( Chosen Columns ) ), invisible )
	  ); //end VListBox
	result_ob << append( dist_vlist );
	) //end If
);  //end Expr

//----Action to take for Add-----------------------------
add_script = Expr(
	cnt = cnt + 1;
	listocols << Append( selcol << Get Selected );
	
);

//----Action to take for Remove -----------------------------
remove_script= Expr(
	cnt = cnt + 1;
	listocols << Remove Selected;
);
//_______________________________________________________________________________

//-----Dialog Window layout---------------------------------
dist_win = New Window( "Create Distributions",
	H List Box(
		selcol = Col List Box( All, width( 100 ), nlines( 6 ) ),
		Lineup Box( N Col( 1 ), Spacing( 3 ),
			Button Box( "Add Column >>", add_script ),
			Button Box( "<< Remove Column", remove_script )
		), 
// listocols is a Col List Box
		listocols = Col List Box( width( 100 ), nlines( 6 ),
		   OnChange( Chosen Columns = listocols << Get Items;
                     refresh_script;)
        )  //end listocols
	),  //end HListBox
	Text Box( " " ),
	result_ob = Outline Box( "Current Selections" )
);

I know you are likely working on a task with a deadline. But try this script. It provides examples of several features I referred to in the posts to this discussion. It provides a how to for adding and removing distributions, the 2nd option.

 

Good Luck!

View solution in original post

10 REPLIES 10
gzmorgan0
Super User (Alumni)

Re: Use list box to change the root name of multiple variables in a time series plot

@spudton,

 

There are multiple methods to do this. Which method you choose depened on the actiion you expect for the UI.

A user can select 1 tem in your list then using control, select others, and hold in shift maybe a range and then remove some. My pont is do you want the report to update with each selection, or maybe add a button, so once selected the user presses a Go or Rerun or Do It button to redo teh analyses.

 

Regarding the report  GraphBuilder you can add and remove variables to the Graph Builder Box. or you could add a local filter of Exclude whose Visibility is collapse that captures all but the users selections. These might be options instead of the Eval Expr.  When JSL Companion 2nd Edition was writte, the use of the GraphBuilderBox was missed. 

 

I suggest you make a graph with the filters and try different options, to understand how this might work.  

 

Personally, unless the user can make only one selection, I like a button to initiate a task if multiple selections are possible.

 

 I did not read your code very closely, but you can refer to a display box using the window namespace maybe window:GraphBuilderBox(2) or  establish a relationship like (this<< parent) etc.

 

 So there are multiple options to achieve what you want and it depends on the current tree structure of teh report and the behavior you want from your UI.

spudton
Level III

Re: Use list box to change the root name of multiple variables in a time series plot

Thanks for the response.

I don;t want the user to have to select multiple tags. I want them to choose one item from the list, then the application displays the time series plot of multiple columns, all with that tag as the root of the name.

So select TAG ABC123, and the time series will display ABC123.ETARG, ABC123.UP, ABC123.LO and ABC123.PV

gzmorgan0
Super User (Alumni)

Re: Use list box to change the root name of multiple variables in a time series plot

@spudton ,

Below is a screenshot of an application with a list box , whee a user selects a variable then the report changes. In this example all graphs are premade (see the tabs) and the action on selesct is to change the visible tab. Your on select action would be to remove the current "tag" and add the new tag ,  I am gessing it would be done by using the messages for removing and adding variables to your 2nd GraphBuilderBox.

image.png

If you change your application from << Run to << Edit,

you should see the ApplicationBuilder UI. The ListBox (cart_lb) is highlighted and the red outline shows where to add a function/script for trh action to be taken when a selection is made

image.png

 

Here is the script for this application's ListBox

Local({idx, nme, tList},
  tlist = (cart_lb << get selected);
  if(nitems(tlist) >0, 
    nme = tlist[1];
    //show(nme);
	idx = var_tabs << index of tab(nme);
	var_tabs << set selected(idx);
	//show(idx);
  ); //end if
);   //end Local

As stated for this application, I get the index of the list. The tabs are aligned with the list so once the index is known, the associated tab is displayed. 

 

Not knowing whether you named the 2nd GraphBuilder display, I cannot help with the script. I have not tried your aplication since I do not have a data table with expected column names.

 

Maybe this is nothing new to you.  Just trying to give you a few leads, just in case.  

 

gzmorgan0
Super User (Alumni)

Re: Use list box to change the root name of multiple variables in a time series plot

@spudton 

I looked at your code.  The script has a handle to the second GraphBuilder.  I had to make some changes, because I did not have a data table to use.

Your code  has several hardcoded elements, I suggest you remove, e.g.

  • Send to Report X axis date ranges
  • Send to Report Legend Items ( or you need to maintain them) 

It  seems you have your starting TAG hardcoded.  So I set the starting curr_TAG to that value.  Below I show the JSL to Remove, Add variables to the GraphBuilderBox. I think it might be more elegant to have a container around gb, and on change remove gb and then add a new gb.

 

A couple comments are you sure  the data table will always have the  PV, LO, UP columns?  Is this something you need to check for?  

 

As stated previously, there are multiple methods to achiev the same result.  Good Luck!

				curr_TAG = "A04004DD";
				ChooseET = List Box( ( ET_TAG_LIST ),
					maxSelected( 1 ),
					onChange(
						TAG = ChooseET << Get Selected;
						If( N Items( TAG ) != 0,
							Show( TAG );
							gbb2 = Report(gb)[GraphBuilderBox(1)];   
							Eval( EvalExpr(gbb2 << Remove Variable({Expr(column(dt,curr_TAG||".ETARG")), Role("Y"), Position(1)} ); 
							gbb2 << Remove Variable({Expr(column(dt,curr_TAG||".LO")), Role("Y"), Position(1)} );
							gbb2 << Remove Variable({Expr(column(dt,curr_TAG||".PV")), Role("Y"), Position(1)} );
							gbb2 << Remove Variable({Expr(column(dt,curr_TAG||".UP")), Role("Y"), Position(1)} );
							));
							curr_TAG = TAG[1];
							//show(curr_TAG);
							wait(0);
							Eval( EvalExpr(gbb2 << Add Variable({Expr(column(dt,curr_TAG||".ETARG")), Role("Y"), Position(1)} ); 
							gbb2 << Add Variable({Expr(column(dt,curr_TAG||".LO")), Role("Y"), Position(1)} );
							gbb2 << Add Variable({Expr(column(dt,curr_TAG||".PV")), Role("Y"), Position(1)} );
							gbb2 << Add Variable({Expr(column(dt,curr_TAG||".UP")), Role("Y"), Position(1)} );
							));
							);
							
						);
					) ;
spudton
Level III

Re: Use list box to change the root name of multiple variables in a time series plot

Hi, thanks again. I've attached a table which contains all the columns with some data.

I will remove the hardcoded statements and do some housekeeping as you've recommended once I've got a clear method on how I'm going to do this.

I popped your code in but got the error "jsl argument should be character in access or evaluation of 'Concat'"

regards

wayne

 

gzmorgan0
Super User (Alumni)

Re: Use list box to change the root name of multiple variables in a time series plot

@spudton,

 

I attached the script that runs on your table on my PC.

 

The error that you are getting might be occurring is you did not use the JSL

curr_TAG = TAG[1];

TAG is the result of ListBox << get selected ; that returns a list, you must get the first item in the list.

 

Oh the other issue is my generated table used extension ETARG.  The code you popped in cahnge ETARG to ETarg That might be the other source of error.

 

The script has a commented line  show(curr_TAG) . Uncomment and look at the log.

 

Note you will see a couple lines commented out. I made up some variables in the table I generated to test it yesterday. 

spudton
Level III

Re: Use list box to change the root name of multiple variables in a time series plot

That's great, thanks.

I've repeated the syntax with my second time series plot and that works fine.

I can;t work out the syntax to change the column in the distribution box when the TAG name is changed.

should this work on a Distribution object?

Eval( Eval Expr( Dstr3 << Remove Variable( {Expr( Column( dt, curr_TAG || " ET_DELTA Ratio" ) )} ) ) );

I've attached the full script.

Thanks again for the help. It's nearly sinking in!

 

 

gzmorgan0
Super User (Alumni)

Re: Use list box to change the root name of multiple variables in a time series plot

@spudton,

 

Messages available for one JMP platform might not be available on others. The GraphBuilder platform allows a a user via the UI to drag and drop to add and remove variables. Hence, JSL implemented an Add Variable() and Remove Variable() to the GraphBuilderBox.

 

Distribution has no such interface, so there is no method to add and remove variables.  The JMP Scripting Index, found under the Help menu will show most if not all of the messages available for a platform.  Main Menu > Help > Scripting Index > Object s(top left corner field) > Distribution.

 

You will find there is typically more than one method to do something using JSL.  A couple options are:

Option: Change your distribution platform to be a GraphBuilder that creates a distribution. It will not have the same options or look the identical. However you can add and remove variables

gbdist =Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( Y( :A04004DD ET_DELTA Ratio ) ),
	Elements( Histogram( Y, Legend( 3 ), Counts( 1 ) ) )
);

Option: Use a container for your distribution. You need to have a placeholder in your display for it. Then when changing a variable, you delete the existing Distribution in that container, then add a new one. Recall I said there were items to clean up in your code. I did not clean all of them.

The code has an empty container, Lineup2. If you make Report3, nested within that box. Actually I'd change it to a VListBox since you are not using the power of the LineupBox. 

				Lineup2 = Lineup Box();
				Report3 = Platform(
					DataTable1,
					Distribution(
						Continuous Distribution(
							Column( :A04004DD ET_DELTA Ratio )
						),

Below is a portion of the script 7_InteractiveDisplays.jsl written for JSL Companion Applications of the JMP Scripting Language, 2nd  Edition.

clear globals();
orig_dt = Open( "$SAMPLE_DATA/Fitness.jmp" );

cnt = 0; Chosen Columns={};  //initiate values

//----Refresh display script---------------------------
refresh_script = Expr(
   Try(dist_vlist << delete);
   	If( (cnt > 0 & N Items( Chosen Columns ) >= 1),
   	  show(Chosen Columns);
	  dist_vlist = VListBox(
		orig_dist = orig_dt << Distribution( Column( Eval( Chosen Columns ) ), invisible )
	  ); //end VListBox
	result_ob << append( dist_vlist );
	) //end If
);  //end Expr

//----Action to take for Add-----------------------------
add_script = Expr(
	cnt = cnt + 1;
	listocols << Append( selcol << Get Selected );
	
);

//----Action to take for Remove -----------------------------
remove_script= Expr(
	cnt = cnt + 1;
	listocols << Remove Selected;
);
//_______________________________________________________________________________

//-----Dialog Window layout---------------------------------
dist_win = New Window( "Create Distributions",
	H List Box(
		selcol = Col List Box( All, width( 100 ), nlines( 6 ) ),
		Lineup Box( N Col( 1 ), Spacing( 3 ),
			Button Box( "Add Column >>", add_script ),
			Button Box( "<< Remove Column", remove_script )
		), 
// listocols is a Col List Box
		listocols = Col List Box( width( 100 ), nlines( 6 ),
		   OnChange( Chosen Columns = listocols << Get Items;
                     refresh_script;)
        )  //end listocols
	),  //end HListBox
	Text Box( " " ),
	result_ob = Outline Box( "Current Selections" )
);

I know you are likely working on a task with a deadline. But try this script. It provides examples of several features I referred to in the posts to this discussion. It provides a how to for adding and removing distributions, the 2nd option.

 

Good Luck!

spudton
Level III

Re: Use list box to change the root name of multiple variables in a time series plot

Hi, many thanks, that clarified a few things and I've invested in the book.

I initially built the application graphically, and I think the Distribution is nested in the lineup2, but defined in the Organize(reparent (Lineup2(ChooseET) statement.

When I run my script, it does almost everything i want, deleting the old distribution 'onchange' but it creates a new distribution outside of the dashboard/application, rather than nested in the Lineup box.

I've attached the full script. Would appreciate any further insight, I can;t find any reference material on the reparent/allocate commands.