cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
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
10 REPLIES 10
spudton
Level III

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

actually, i solved this one, adding another vlist box and appending the distribution to it within the onchange( script.

thanks for the advice!