cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
GgGgGg2024
Level II

Column switcher and Graph Builder

Hi,

 

I have a number of columns which I have grouped together.

In the graph builder I have the X axis constant, but the Y axis should have the column switcher function where we can chose which parameter we want to switch between from the said group of columns.

 

First I tell JSL what columns should be in the group and which column should be my first column

colList = dttable << get column names( continuous );
	col1 = colList[1];

This is the code and the error I am getting,

 

Graph Builder(
	Size( 570, 621 ),
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Variables( X( :batch_no ), Y( :col1 ) /*###*/ ),
	Elements( Points( X, Y, Legend( 8 ) ) ),
	Column Switcher( :col1, {:colList} )
)

 

Can you tell me what I should write for the Y variable so I can get the first column to start with and then add the column switcher.

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Column switcher and Graph Builder

You are specifying 

:col1

The colon is telling JMP there is a column in the data table called "col1"(see scoping in JMP documentation);  Col1 is a memory variable, not a column.  Remove the colon and your code should work.

Jim

View solution in original post

12 REPLIES 12
txnelson
Super User

Re: Column switcher and Graph Builder

You are specifying 

:col1

The colon is telling JMP there is a column in the data table called "col1"(see scoping in JMP documentation);  Col1 is a memory variable, not a column.  Remove the colon and your code should work.

Jim
GgGgGg2024
Level II

Re: Column switcher and Graph Builder

Hi Jim,

 

Thanks for your help.

 

I get the graph now, but the column switcher still does not work. 

dtrelsplit << Newscript ("graph",
	Graph Builder(
	Size( 570, 621 ),
Show Control Panel( 0 ), Show Legend( 0 ), Variables( X( :batch_no ), Y(col1), ), Elements( Points( X, Y, Legend( 8 ) ) ), Column Switcher( col1, {colList} ), ),


Column Switcher cannot find specified column col1 in platform script

This is the error  shown

 

txnelson
Super User

Re: Column switcher and Graph Builder

Here are my modifications

Graph Builder(
	Size( 570, 621 ),
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Variables( X( :batch_no ), Y( as column(col1) ) ),
	Elements( Points( X, Y, Legend( 8 ) ) ),
	Column Switcher( col1, colList )
		
)
;

colList is a list, so it does not require a second set of {}

Jim
GgGgGg2024
Level II

Re: Column switcher and Graph Builder

Thanks 

 

 

 

 

Ressel
Level VII

Re: Column switcher and Graph Builder

Has JMP become stricter?

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

colLst = { :Height, :Weight, :Age };

// doesn't work
dt << New Script( "test",
	Graph Builder(
    Variables( X( :Weight ), Y( :Height ) ),
    Elements( Points( X, Y ) ),
    Column Switcher( :Height, colLst )
	)
);

// does work
dt << New Script( "test2",
	Graph Builder(
    Variables( X( :Weight ), Y( :Height ) ),
    Elements( Points( X, Y ) ),
    Column Switcher( :Height, { :Height, :Weight, :Age } )
	)
);

// does work
Eval( Eval Expr( dt << New Script( "test3",
	Graph Builder(
    Variables( X( :Weight ), Y( :Height ) ),
    Elements( Points( X, Y ) ),
    Column Switcher( :Height, Expr( colLst ) )
	)
)));
txnelson
Super User

Re: Column switcher and Graph Builder

What two versions of JMP are you referencing?

Jim
Ressel
Level VII

Re: Column switcher and Graph Builder

JMP19.

 

edit: I wouldn't be able to tell without effort whether the colList variable worked in JMP18 or earlier. I am surprised because I have found several references regarding the use of variables having lists passed to them for further use.

txnelson
Super User

Re: Column switcher and Graph Builder

@Ressel ,

Using a newly executed, therefore, clean instance of JMP 18, the example script you included of the case you implied was working for you in JMP 18 did not work for me.  

The issue is because of the isolation that JMP provides for the sample script you included, where it has as the first line 

Names Default To Here( 1 );

This function isolates the variables created to be unique to that execution of the script.  Therefore, the variable collist is only known to the script when it is run.  When the embedded script that is saved to the data table is run, that is a new script environment, and it does not have the variable collist defined.

The reason your two versions of the code that do execute properly, do actually work is because in the first case, the values are hardcoded into the script, and in the second case, the 

Expr( colLst ) 

expands the variable colist into hardcoded values before the code is executed, making the script embedded in the data table a hardcoded version of the script.

Thus, in your case, JMP 19 has not changed from version 18

Jim
Ressel
Level VII

Re: Column switcher and Graph Builder

Ah, OK. I assume this is what is a "name space" issue? 

Also, I did not claim it worked for me in JMP18. I was wondering why the solution that was proposed here and looked so clear didn't work. I then incorrectly suspected it may be related to JSL's evolution. This is not the case.

Thanks for the clarification!

Recommended Articles