Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
mes
mes
Level I

Scripting column switcher using variable

I am scripting a dashboard with graph builder in it. I want to add a column switcher that should use a variable as a column list, due to changing columns. For some reason this doesn't work, only first column in a list will show. Column list is created like this:

 

col_list3 = dt << get column names(Numeric);

for (i = nitems(col_list3), i > 0, i--,

if (!contains(col_list3[i], "%"),

remove from(col_list3, i);

);

);

 

But when I try to use col_list3 in the Column Switcher embedded in dasboard script, it doesn't work.

Column Switcher(

 

:FC 1244%,

{col_list3}

)

 

I have tried to use eval ect., but no success. What am I missing, any Ideas? For some reason I can't add any files to this post so whole script pasted below and a image of my example data table.

example image.JPG

 

Names default to here (1);

dt = Data Table("example");

//get only columns with %
col_list3 = dt << get column names(Numeric);
for (i = nitems(col_list3), i > 0, i--,
     if (!contains(col_list3[i], "%"),
           remove from(col_list3, i);
     );
);

//dashboard
JMP App(
	Set Name( "Dashboard" ),
	Set Description( "Selection in one report filters the second" ),
	Auto Launch( 1 ),
	Snap To Grid( 1 ),
	Show Grid( 1 ),
	Show Properties( 0 ),
	Show Sources( 1 ),
	Group By Category( 0 ),
	Dashboard Mode( 1 ),
	Parameters,
	Tables(
		DataTable1 = GuiTable(
			Set Path( "" ),
			Set Label( "example" ),
			Set Location( "Current Data Table" ),
			Set Invisible( 0 )
		)
	),
	Thumbnail(
		New Image(
			Char To Blob(
				"52417eJytVvs70w0b/262OSxzbBPDSActUz1Ccz7MISyHqRRbkuFFM5Upw8jhUUqodHBepaemzMhy3JorxxyaUjmHpHhJ1Gj07Hn/gvd6r/eHz/25Pvd9X/dP9/257ixvoquykrYSAADK7m7OvjJm/QMFmCyKbIO7ZAQ64+vqCDzpQc/KBCTMwcsBALg5cGkwVKYVY9wCzgAAQvgPQPzcyHlZDubu7ECKJ88XzfuRBnXbVlXWTM+u1Rc17hUfOd8fcRcVXfTgNlEnP1t81nfbg9R+yDa+9eclDKZXnU7QVHUmoJDv/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WU0k8iB9/XTfK8C6FENND7Y2WFEzkw7+l3lF5E8RetonZ0pjVvb+ghYFyECw8Sn3sw6hCoKvsk7ueHfy3mJLUetTgmWsylk3oqsx8QiU+2n2LC1KYJUDBTiRxgSM55Ouv/FWPezf0772R8ZtJB06Ph3ao67PN2SsK/e+9zK8edG+NY1rdKGX1ahSn0XItElD2kO4hgKLgvBxQGuuWAzbZdvPRvbrxfqX/Mol1NU3aZnHYupK0et/2T/qst2/z+s538p1HyBhhEiuH0Rj8Xhbv7nZi5fvuzm6ekcHFy26O7lle7Czo2kKhPggglKDJXqIlm8wFyaygrERu4kAx+nZc7wvRzo5zipY5SkFcC/ai/8+gH4+fm9zqQEBd2PwghPqOKLELYlh76Aqnm83Px8jRtRBwEylXt0j42N13v7biqPxMBisb42GaKJh6F+4Ji3fxQuLbWq30Wy3o3KpjuBFYit4EXsMW7chqH5oVawamcaRLVQf/OJiAh3suH17npw1b5ZISIpsqB8eFF/6Rx0HLs677kRI094TscXfYXb/ymniLHMA8xaUCicfRhGlTW2UKGATDqOx6ERYxMVLO+dzmo7pdUbnZ1KG1Cj2sRb0DJ+rexNAtwJROcnjidS/waEejzC",
				"base64compressed"
			),
			"png"
		)
	),
	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.

)	),
	Allocate(
		Module1 = Plan(
			PreAllocate,
			Script(JSL Quote(				thisModuleInstance << Create Objects;				Try(MainTabPage << Set Scriptable Object(thisApplication));			
)			),
			Allocate(
				DataFilterContext1 = Data Filter Context Box();
				MainTabPage = Tab Page Box();
				Splitter1 = H Splitter Box();
				DataFilterSource1 = Data Filter Source Box();
				TabPage1 = Tab Page Box();
				Scroll1 = Scroll Box();
				Report1 = Platform(
					DataTable1,
					Distribution(
						Automatic Recalc( 1 ),
						Nominal Distribution( Column( :Product ) )
					)
				);
				TabPage2 = Tab Page Box();
				Scroll2 = Scroll Box();
				Report2 = Platform(
					DataTable1,
					Graph Builder(
						Size( 534, 448 ),
						Show Control Panel( 0 ),
						Fit to Window( "Maintain Aspect Ratio" ),
						Variables( X( :DAY ), Y( :FC 1244% ) ),
						Elements( Points( X, Y, Legend( 3 ) ) ),
						Column Switcher(
							:FC 1244%,
							{col_list3} //not working
						)
					)
				);
			),
			Organize(
				Reparent( Scroll2( Report2 ) );
				Reparent( TabPage2( Scroll2 ) );
				Reparent( Splitter1( TabPage2 ) );
				Reparent( Scroll1( Report1 ) );
				Reparent( TabPage1( Scroll1 ) );
				Reparent( DataFilterSource1( TabPage1 ) );
				Reparent( Splitter1( DataFilterSource1 ) );
				Reparent( MainTabPage( Splitter1 ) );
				Reparent( DataFilterContext1( MainTabPage ) );
				Relocate( DataFilterContext1( 0, 0 ) );
			),
			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" ),
				MainTabPage << Background Color( 2147483647 ),
				MainTabPage << Border(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				MainTabPage << Enabled( 1 ),
				MainTabPage << Horizontal Alignment( "Default" ),
				MainTabPage << Margin(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				MainTabPage << Padding(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				MainTabPage << Text Color( 2147483647 ),
				MainTabPage << Vertical Alignment( "Default" ),
				MainTabPage << Visibility( "Visible" ),
				MainTabPage << Title( "Dashboard" ),
				MainTabPage << Tip( "" ),
				MainTabPage << Icon( "" ),
				MainTabPage << Closeable( 0 ),
				MainTabPage << Moveable( 0 ),
				Splitter1 << Background Color( 2147483647 ),
				Splitter1 << Border(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				Splitter1 << Enabled( 1 ),
				Splitter1 << Horizontal Alignment( "Default" ),
				Splitter1 << Margin(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				Splitter1 << Padding(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				Splitter1 << Text Color( 2147483647 ),
				Splitter1 << Vertical Alignment( "Default" ),
				Splitter1 << Visibility( "Visible" ),
				Splitter1 << Dockable( 1 ),
				Splitter1 << Set Width( 1036 ),
				Splitter1 << Set Height( 500 ),
				Splitter1 << Set Sizes( {0.210067763794773, 0.789932236205227} ),
				Splitter1 << set horizontal( 1 ),
				Splitter1 << Set Min Size( 456, 193 ),
				Splitter1 << Set Max Size( 60003, 30000 ),
				Splitter1 << Set Auto Stretching( 1, 1 ),
				DataFilterSource1 << Background Color( 2147483647 ),
				DataFilterSource1 << Border(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				DataFilterSource1 << Enabled( 1 ),
				DataFilterSource1 << Horizontal Alignment( "Default" ),
				DataFilterSource1 << Margin(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				DataFilterSource1 << Padding(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				DataFilterSource1 << Text Color( 2147483647 ),
				DataFilterSource1 << Vertical Alignment( "Default" ),
				DataFilterSource1 << Visibility( "Visible" ),
				TabPage1 << Background Color( 2147483647 ),
				TabPage1 << Border( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				TabPage1 << Enabled( 1 ),
				TabPage1 << Horizontal Alignment( "Default" ),
				TabPage1 << Margin( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				TabPage1 << Padding(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				TabPage1 << Text Color( 2147483647 ),
				TabPage1 << Vertical Alignment( "Default" ),
				TabPage1 << Visibility( "Visible" ),
				TabPage1 << Title( "Distributions" ),
				TabPage1 << Tip( "" ),
				TabPage1 << Icon( "Distrib" ),
				TabPage1 << Closeable( 1 ),
				TabPage1 << Moveable( 1 ),
				Scroll1 << Background Color( 2147483647 ),
				Scroll1 << Border( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				Scroll1 << Enabled( 1 ),
				Scroll1 << Horizontal Alignment( "Default" ),
				Scroll1 << Margin( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				Scroll1 << Padding( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				Scroll1 << Text Color( 2147483647 ),
				Scroll1 << User Resizable( {1, 1} ),
				Scroll1 << Vertical Alignment( "Default" ),
				Scroll1 << Visibility( "Visible" ),
				Scroll1 << Width( 218 ),
				Scroll1 << Height( 474 ),
				Scroll1 << Set Auto Scrollable( 1 ),
				Scroll1 << Set Scrollers( 1, 1 ),
				Scroll1 << Set Background Color( 2147483647 ),
				Scroll1 << Set Show Empty( 0 ),
				Scroll1 << Set Clip Printing( 0 ),
				Scroll1 << Set Min Size( 72, 36 ),
				Scroll1 << Set Max Size( 30000, 30000 ),
				Scroll1 << Set Auto Stretching( 1, 1 ),
				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 ),
				TabPage2 << Background Color( 2147483647 ),
				TabPage2 << Border( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				TabPage2 << Enabled( 1 ),
				TabPage2 << Horizontal Alignment( "Default" ),
				TabPage2 << Margin( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				TabPage2 << Padding(
					{Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )}
				),
				TabPage2 << Text Color( 2147483647 ),
				TabPage2 << Vertical Alignment( "Default" ),
				TabPage2 << Visibility( "Visible" ),
				TabPage2 << Title( "TabPage2" ),
				TabPage2 << Tip( "" ),
				TabPage2 << Icon( "Trellis" ),
				TabPage2 << Closeable( 1 ),
				TabPage2 << Moveable( 1 ),
				Scroll2 << Background Color( 2147483647 ),
				Scroll2 << Border( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				Scroll2 << Enabled( 1 ),
				Scroll2 << Horizontal Alignment( "Default" ),
				Scroll2 << Margin( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				Scroll2 << Padding( {Left( 0 ), Top( 0 ), Right( 0 ), Bottom( 0 )} ),
				Scroll2 << Text Color( 2147483647 ),
				Scroll2 << User Resizable( {1, 1} ),
				Scroll2 << Vertical Alignment( "Default" ),
				Scroll2 << Visibility( "Visible" ),
				Scroll2 << Width( 815 ),
				Scroll2 << Height( 474 ),
				Scroll2 << Set Auto Scrollable( 1 ),
				Scroll2 << Set Scrollers( 0, 0 ),
				Scroll2 << Set Background Color( 2147483647 ),
				Scroll2 << Set Show Empty( 0 ),
				Scroll2 << Set Clip Printing( 0 ),
				Scroll2 << Set Min Size( 381, 167 ),
				Scroll2 << Set Max Size( 30281, 30026 ),
				Scroll2 << Set Auto Stretching( 1, 1 ),
				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
Highlighted
txnelson
Super User

Re: Scripting column switcher using variable

The issue you are having, is that when you specify

Column Switcher(
:FC 1244%,
{col_list3}
)

you are placing col_list3 inside a set of {}.  But since col_list3 has been specified as a list, it already has the {} in the list.  So what JMP is seeing is a list within a list

Here is a simple script to illustrate how to code what you want

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
col_list3 = dt << get column names( Numeric );

For( i = N Items( col_list3 ), i > 0, i--,
	If( !Contains( col_list3[i], "PN" ),
		Remove From( col_list3, i )
	)
);

Graph Builder(
	Size( 534, 572 ),
	Show Control Panel( 0 ),
	Variables( X( :PNP1 ), Y( :NPN1 ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) ),
	Column Switcher( :NPN1, col_list3 )
);

 

Jim

View solution in original post

2 REPLIES 2
Highlighted
txnelson
Super User

Re: Scripting column switcher using variable

The issue you are having, is that when you specify

Column Switcher(
:FC 1244%,
{col_list3}
)

you are placing col_list3 inside a set of {}.  But since col_list3 has been specified as a list, it already has the {} in the list.  So what JMP is seeing is a list within a list

Here is a simple script to illustrate how to code what you want

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
col_list3 = dt << get column names( Numeric );

For( i = N Items( col_list3 ), i > 0, i--,
	If( !Contains( col_list3[i], "PN" ),
		Remove From( col_list3, i )
	)
);

Graph Builder(
	Size( 534, 572 ),
	Show Control Panel( 0 ),
	Variables( X( :PNP1 ), Y( :NPN1 ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) ),
	Column Switcher( :NPN1, col_list3 )
);

 

Jim

View solution in original post

Highlighted
mes
mes
Level I

Re: Scripting column switcher using variable

That was the problem, thank you :)!

Article Labels

    There are no labels assigned to this post.