cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Sam619
Level I

Filter value to grah name

Hi. Can anyone please help me with a script to name my graph with the value of my filter. Thanks!
4 REPLIES 4
jthi
Super User

Re: Filter value to grah name

Could you provide more information? Which graph you want to name and how you want to name it?

In general I use Group X for "naming" my graphs when I have Local Data Filter. This helps users to see how it has been filtered, especially helpful if there is lots of options.

jthi_0-1651387612400.png

 

-Jarmo
Sam619
Level I

Re: Filter value to grah name

Thanks for the reply. In your example, I would like to take the graph title "height vs. age" and replace it with the selected filter "F". 

 

Thanks again!

 

 

jthi
Super User

Re: Filter value to grah name

This will require scripting to my knowledge and it wasn't as simple as I thought it would be... hopefully there are easier methods to do this than the example I have here:

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

gb = dt << Graph Builder(
	Size(529, 451),
	Show Control Panel(0),
	Variables(X(:age), Y(:height)),
	Elements(Points(X, Y, Legend(11))),
);

filter = gb << Local Data Filter(Add Filter(columns(:sex), Where(:sex == "F")));
//filter = gb << Local Data Filter(Add Filter(columns(:age), Where(:age == 12)));
f = Function({a}, 
	cur_filter_script = filter << Get Script;
	filtered_values = Parse(Word(2, Char(Arg(Arg(Arg(cur_filter_script, 1), 2), 1)), "=="));
	If(Type(filtered_values) == "List",
		num_to_str = Transform Each({val}, filtered_values, char(val));
		title = Concat Items(num_to_str, ", ");
	,
		title = char(filtered_values);
	);
	// set title changes wrong text (outline box)
	// but << Show Title() controls correct one
	// so we edit report layer 
	Report(gb)[TextEditBox(1)] << Set Text(title);
);

rs = filter << Make Filter Change Handler(f);
-Jarmo
Sam619
Level I

Re: Filter value to grah name

Awesome! Thank you. I'll give this a shot. 

Recommended Articles