cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
BayesRabbit7133
Level III

Can I set graph builder title based on variable from a H list box?

I have a H list box window that users can input parameters, after that I will do some calculations and provide a graph builder to user

My question is can I set graph builder title also based on the parameters from the H list box?  below is the sample code

Names Default To Here( 1 );
dt = current data table();
nw = New Window( "simulator",
	H List Box( Text Box( "   Input sample rate " ), sample rate = Number Edit Box() ), 
	H List Box( Text Box( "   Input threshold " ), threshold = Number Edit Box() ),
	Button Box( "OK",
    thesamplerate = sample rate << get;
	thethreshold = threshold << get;
    numthreshold = num(thethreshold);
    numtime = num(thetime);

    //Here are more code I already finished based on above variable

Graph Builder(
	Variables( X( :File Name ), Y( :greater ) ),
	Elements( Bar( X, Y, Legend( 4 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text( "Sample rate =    Threshold = " )} //I want to have sample rate & threshold shown on title
		)
	)
)
))

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Can I set graph builder title based on variable from a H list box?

You could build the title using Eval Insert or string concatenation. 

Here is one option

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

nw = New Window("simulator",
	H List Box(Text Box("   Input sample rate "), sample rate = Number Edit Box()),
	H List Box(Text Box("   Input threshold "), threshold = Number Edit Box()),
	Button Box("OK",
		thesamplerate = sample rate << get;
		thethreshold = threshold << get;
		//numthreshold = Num(thethreshold);
		//numtime = Num(thetime);
		gb = dt << Graph Builder(
			Variables(X(:age), Y(:weight)),
			Elements(Bar(X, Y, Legend(4)))
		);
		Report(gb)[TextEditBox(1)] << Set Text(Eval Insert("Sample rate = ^thesamplerate^   Threshold = ^thethreshold^"));
	)
);

You should be able to also insert it directly to the title in SendToReport. Here I also build title variable separately but it isn't necessary but can make debugging and such easier

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

nw = New Window("simulator",
	H List Box(Text Box("   Input sample rate "), sample rate = Number Edit Box()),
	H List Box(Text Box("   Input threshold "), threshold = Number Edit Box()),
	Button Box("OK",
		thesamplerate = sample rate << get;
		thethreshold = threshold << get;
		//numthreshold = Num(thethreshold);
		//numtime = Num(thetime);
		graph_title = Eval Insert("Sample rate = ^thesamplerate^   Threshold = ^thethreshold^");
		gb = dt << Graph Builder(
			Variables(X(:age), Y(:weight)),
			Elements(Bar(X, Y, Legend(4))),
			SendToReport(
				Dispatch(
					{},
					"graph title",
					TextEditBox,
					{Set Text(graph_title)} //I want to have sample rate & threshold shown on title
				)
			)
		);
	)
);
-Jarmo

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Can I set graph builder title based on variable from a H list box?

Here is the method that I normally use:

Names Default To Here( 1 );
dt = Current Data Table();
nw = New Window( "simulator",
	H List Box( Text Box( "   Input sample rate " ), sample rate = Number Edit Box() ),
	H List Box( Text Box( "   Input threshold " ), threshold = Number Edit Box() ),
	Button Box( "OK",
		thesamplerate = sample rate << get;
		thethreshold = threshold << get;
		numthreshold = Num( thethreshold );
		numtime = Num( thetime );

    //Here are more code I already finished based on above variable

		gb = Graph Builder( Variables( X( :File Name ), Y( :greater ) ), Elements( Bar( X, Y, Legend( 4 ) ) ) );
		// Set the title
		Report( gb )[Outline Box( 1 ), Text Edit Box( 1 )] << set text( "Sample Rate=" || Char( thesamplerate ) );
		
	)
);
Jim
jthi
Super User

Re: Can I set graph builder title based on variable from a H list box?

You could build the title using Eval Insert or string concatenation. 

Here is one option

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

nw = New Window("simulator",
	H List Box(Text Box("   Input sample rate "), sample rate = Number Edit Box()),
	H List Box(Text Box("   Input threshold "), threshold = Number Edit Box()),
	Button Box("OK",
		thesamplerate = sample rate << get;
		thethreshold = threshold << get;
		//numthreshold = Num(thethreshold);
		//numtime = Num(thetime);
		gb = dt << Graph Builder(
			Variables(X(:age), Y(:weight)),
			Elements(Bar(X, Y, Legend(4)))
		);
		Report(gb)[TextEditBox(1)] << Set Text(Eval Insert("Sample rate = ^thesamplerate^   Threshold = ^thethreshold^"));
	)
);

You should be able to also insert it directly to the title in SendToReport. Here I also build title variable separately but it isn't necessary but can make debugging and such easier

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

nw = New Window("simulator",
	H List Box(Text Box("   Input sample rate "), sample rate = Number Edit Box()),
	H List Box(Text Box("   Input threshold "), threshold = Number Edit Box()),
	Button Box("OK",
		thesamplerate = sample rate << get;
		thethreshold = threshold << get;
		//numthreshold = Num(thethreshold);
		//numtime = Num(thetime);
		graph_title = Eval Insert("Sample rate = ^thesamplerate^   Threshold = ^thethreshold^");
		gb = dt << Graph Builder(
			Variables(X(:age), Y(:weight)),
			Elements(Bar(X, Y, Legend(4))),
			SendToReport(
				Dispatch(
					{},
					"graph title",
					TextEditBox,
					{Set Text(graph_title)} //I want to have sample rate & threshold shown on title
				)
			)
		);
	)
);
-Jarmo
BayesRabbit7133
Level III

Re: Can I set graph builder title based on variable from a H list box?

Thank you both for your prompt reply