cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
psundar6
Level III

Selecting data points across plots created from different tables

Hello,

 

I generate two plots -

 

1) Variability plot from a stacked data table (B) [B is created from a parent table (A)]

2) Bivariate plot created from parent table (A)

 

These two plots are generated as a report in tabs. The problem I face right now is that since these plots are generated from different tables, points selected on either of the plots do not get selected on the other plot. Is there a way to link these two plots/tables so we can select points from one graph to reflect on the other?

 

An example JSL to do this will help.

 

Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Selecting data points across plots created from different tables

Here is a way to get one of the charts(the bivariate), to select the values in both charts, but applying the same logic to both charts creates a timing issue.

names default to here(1);
dt=current data table("$SAMPLE_DATA/blood pressure.jmp");
dt<<new column("Row",formula(row()));
dt:row<<delete formula;

dtStack = dt << Stack(
	columns( :BP 8M, :BP 12M ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
);


biv = dt << Bivariate( Y( :BP 8M ), X( :BP 12M ) );



vc = dtStack << Variability Chart( Y( :Data ), X( :Label ) );

report(biv)[FrameBox(1)] << add graphics script(
	dtMat = dt << get selected rows;
	If(nrows(dtMat)>0  == 0,
		
		dtStack << select where(dtStack:row==dt:row[dtmat[1]]);
		for(i=2,i<=n rows(dtMat),i++,
			dtStack << select where(dtStack:row==dt:row[dtmat[i]], current selection("extend"));
		);
		
	)
);
Jim

View solution in original post

gzmorgan0
Super User (Alumni)

Re: Selecting data points across plots created from different tables

@psundar6 ,

Another approach to your problem is to update table selections using table row state handler functions. Using @txnelson example, the script below creates these handlers.  Then any graph you create from this two tables will have linked selection states, unless a local data filter is deployed.

names default to here(1);
dt=open("$SAMPLE_DATA/blood pressure.jmp");
dt<<new column("Row",formula(row()));
dt:row<<delete formula;

dtStack = dt << Stack(
	columns( :BP 8M, :BP 12M ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
);

//Create functions to handle row state changes
//if dt selected row state is changed, change dtStack selected state

f1 = Function({a}, {dtr1={}},
      if(Is Scriptable(dtStack),
     	dtr1 = AsList(dt << get selected rows);
		If(nitems(dtr1)>0,	
			dtStack << select where(contains(dtr1,dtStack:row) ),
		   nitems(dtr1)==0,
			dtStack << clear select 	
		);
      ); //end if
	);	
		
//if dtStack selected row state is changed, change dt selected state

f2 = Function({a}, {dtr2={}},
      If( Is Scriptable(dt),
     	dtr2 =  Associative Array(AsList(dtStack:row[dtStack << get selected rows])) <<get keys;
		If(nitems(dtr2)>0,	
			dt << select rows(dtr2) ,
		   nitems(dtr2)==0,
			dt << clear select 	
		);	
	); //end if	
);

//create the row state handlers
rs1 = dt << Make Row State Handler(f1);
rs2 = dtStack << Make Row State Handler(f2);

 //any graph created from these two tables will be linked, unless a local filter is deployed
nw = new window("", HListBox(
    biv = dt << Bivariate( Y( :BP 8M ), X( :BP 12M ) ),
    vc = dtStack << Variability Chart( Y( :Data ), X( :Label ) )
   )// end Hlist Box 
);

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Selecting data points across plots created from different tables

Here is a way to get one of the charts(the bivariate), to select the values in both charts, but applying the same logic to both charts creates a timing issue.

names default to here(1);
dt=current data table("$SAMPLE_DATA/blood pressure.jmp");
dt<<new column("Row",formula(row()));
dt:row<<delete formula;

dtStack = dt << Stack(
	columns( :BP 8M, :BP 12M ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
);


biv = dt << Bivariate( Y( :BP 8M ), X( :BP 12M ) );



vc = dtStack << Variability Chart( Y( :Data ), X( :Label ) );

report(biv)[FrameBox(1)] << add graphics script(
	dtMat = dt << get selected rows;
	If(nrows(dtMat)>0  == 0,
		
		dtStack << select where(dtStack:row==dt:row[dtmat[1]]);
		for(i=2,i<=n rows(dtMat),i++,
			dtStack << select where(dtStack:row==dt:row[dtmat[i]], current selection("extend"));
		);
		
	)
);
Jim
gzmorgan0
Super User (Alumni)

Re: Selecting data points across plots created from different tables

@txnelson ,

small typo?

If(nrows(dtMat)>0  == 0,

should be

If(nrows(dtMat)>0 ,
gzmorgan0
Super User (Alumni)

Re: Selecting data points across plots created from different tables

@psundar6 ,

Another approach to your problem is to update table selections using table row state handler functions. Using @txnelson example, the script below creates these handlers.  Then any graph you create from this two tables will have linked selection states, unless a local data filter is deployed.

names default to here(1);
dt=open("$SAMPLE_DATA/blood pressure.jmp");
dt<<new column("Row",formula(row()));
dt:row<<delete formula;

dtStack = dt << Stack(
	columns( :BP 8M, :BP 12M ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" )
);

//Create functions to handle row state changes
//if dt selected row state is changed, change dtStack selected state

f1 = Function({a}, {dtr1={}},
      if(Is Scriptable(dtStack),
     	dtr1 = AsList(dt << get selected rows);
		If(nitems(dtr1)>0,	
			dtStack << select where(contains(dtr1,dtStack:row) ),
		   nitems(dtr1)==0,
			dtStack << clear select 	
		);
      ); //end if
	);	
		
//if dtStack selected row state is changed, change dt selected state

f2 = Function({a}, {dtr2={}},
      If( Is Scriptable(dt),
     	dtr2 =  Associative Array(AsList(dtStack:row[dtStack << get selected rows])) <<get keys;
		If(nitems(dtr2)>0,	
			dt << select rows(dtr2) ,
		   nitems(dtr2)==0,
			dt << clear select 	
		);	
	); //end if	
);

//create the row state handlers
rs1 = dt << Make Row State Handler(f1);
rs2 = dtStack << Make Row State Handler(f2);

 //any graph created from these two tables will be linked, unless a local filter is deployed
nw = new window("", HListBox(
    biv = dt << Bivariate( Y( :BP 8M ), X( :BP 12M ) ),
    vc = dtStack << Variability Chart( Y( :Data ), X( :Label ) )
   )// end Hlist Box 
);