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
Neo
Neo
Level VI

Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

I use the following to display "my text" at the top of my charts.

Dispatch( {}, "graph title", TextEditBox, {Set Text( "my text" )} )

However, I would like to have the item(s) selected in the local data filter to be displayed in the graph title as I select them (perhaps multiple sections as comma delimited?).

How to achieve this in JSL?

When it's too good to be true, it's neither
21 REPLIES 21
Neo
Neo
Level VI

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

@hogi  Your script below now works in JMP 16.2 but with the following issues.

  • The chart starts with no age selected and no title shown but the last one remains shown on the chart title when all age checkboxes are unchecked.
  • In the actual problem, the title starts showing only when more than one check boxes are checked.

How to resolve these two issues (unless this is my JMP version specific) ?

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

gb = Graph Builder(
	Size( 570, 518 ),
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) ),
	Local Data Filter(
		Conditional,
		Add Filter(
			columns( :sex, :age, :weight ),
			Display( :sex, "Check Box Display" ),
			Display( :age, "Check Box Display" )
		)
	),
	SendToReport( Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ) )
);

ldf = Current Report()["Local Data Filter"] << get scriptable object;

changeTitle = Function( {this},
	print(this);
	ldfText = Regex(ldf << get where clause(),"\( *(:age == .*?)\)","\1");
	(Report( gb ) << XPath( "//TextEditBox" ))[1] << Set Text( ldfText );
);
fsh = ldf << Make Filter Change Handler(
	changeTitle();
);
When it's too good to be true, it's neither
hogi
Level XII

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

You are right.
If Regex doesn't find the age info, it returns missing.

 

So, after

ldfText = Regex(ldf << get where clause(),"\( *(:age == .*?)\)","\1");

please add

if(ismissing(ldfText),ldfText = "all ages");

to fix the issue.

 

 

hogi
Level XII

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

If you just select one entry at a time, you could use the page dropzone to automatically label the plot:
[if multiple entries are selected, the respective data gets split across multiple pages]

hogi_0-1686648512981.png

 



Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

Graph Builder(
	Variables( X( :height ), Y( :weight ), Page( :age ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) ),
	Local Data Filter(
		Add Filter(
			columns( :sex, :age, :weight ),
			Where( :age == 14 )
		)
	)
);
Neo
Neo
Level VI

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

My script below (for the actual case) appears to be triggering only after the second check box selection. Any leads as to why would be useful. 

changeTitle = Function( {this},
	print(this);
   	ldfText = Regex(ldf << get where clause(),"\( *(:Parameter == .*?)\)","\1");
	if(ismissing(ldfText),ldfText = " Selected Test Parameter ");
	(Report( gb ) << XPath( "//TextEditBox" ))[4] << Set Text(ldfText);
);

fsh = ldf << Make Filter Change Handler(
	changeTitle();
);
When it's too good to be true, it's neither
hogi
Level XII

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

Oh, sorry, I always started by selecting the age - and then I missed that the title didn't update for the case of one age selection + something else.

If there is just a single age selection, there is no need for additional brackets.
So, how about skipping the first bracket ?

NB: please don't use inverse with this version

hogi_1-1687288651230.png

 

changeTitle = Function( {this},
	print(this);
	print(ldf << get where clause());
	ldfText = Regex(ldf << get where clause(),"(:age == .*?)\)","\1");
	if(ismissing(ldfText),ldfText = "any text you want");
	(Report( gb ) << XPath( "//TextEditBox" ))[1] << Set Text( ldfText );
);
Neo
Neo
Level VI

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

@hogi . Does not work for me in JMP 16.2.0. I have opened a new thread on this with a better example on what is not working here (link).

When it's too good to be true, it's neither
hogi
Level XII

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

Actually, this version should with Jmp 16.2.0:

 

 

Neo
Neo
Level VI

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

@hogi  The following is (almost) working and the current issues reported here.

ldfText = Regex(ldf << get where clause(),"\(?\s*(:age == .*?)\)","\1");

When it's too good to be true, it's neither
hcarr01
Level VI

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

Bonjour à tous,

 

Comment on fait pour mettre une deuxième colonne dans le remplissage des titres automatiques ?

La colonne "name" ne fait pas parti du filtre des données locales, mais en fonction de la sélection des "ages" dans le filtre on aurait tous les noms correspondants à ces "ages" dans le titre du graphique. Tout ça de façon dynamique.

 

 

ldfText = Regex(ldf << get where clause(),"\( *(:age == .*?)\)","\1");

 

txnelson
Super User

Re: Is it possible to dynamically update "graph title" based item selection in local data filter (including multiple selections)?

Here is one approach in getting all of the names listed

changeTitle = Function( {this},
	Eval( Parse( "theRows = dt << get rows where" || Substr( ldf << get where clause(), 13 ) ) );
	If( Length( theRows ) > 0,
		ldfText = Concat Items( :name[theRows],"," ),
		ldfText = "All Names"
	);
	(Report( gb ) << XPath( "//TextEditBox" ))[1] << Set Text( ldfText );
);

 

txnelson_0-1709049088522.png

 

Jim