BookmarkSubscribe
Choose Language Hide Translation Bar
matth1
New Contributor

Programmable number of multiple graph boxes in a new window

Apologies if this answered somewhere else I haven't been able to find.

 

I want to generate a number of separate graph boxes within a Window, which I can then draw custom shapes in. There should be X columns and Y rows - i.e. the number and format has to be programmable.

 

I would like it to look a bit like the attached image. This was created with each Graph Box written out in full, which is obviously not ideal.

 

As a simple starting point, I tried this:

 

 

win01 = New Window( "test",
	Outline Box( "test",
		V List Box(
			For( yy = 1, yy <= 5, yy++,
				H List Box(
					For( xx = 1, xx <= 5, xx++,
						aa = xx + 5 * ( yy - 1 );
						Graph Box(
							framesize( 200, 200 ),
							X Scale( 0, 10 ),
							Y Scale( 0, 10 ),
							X Axis( Inc( 2 ), Minor Ticks( 1 ), Show Major Grid( 1 ), Show Minor Grid( 1 ) ),
							Y Axis( Inc( 2 ), Minor Ticks( 1 ), Show Major Grid( 1 ), Show Minor Grid( 1 ) ),
							XName( "Die X" ),
							YName( "Die Y" ),
							Text({1,5}, char(aa) )
						)
					)
				)
			)
		)
	)
);

 

But of course that didn't work. I probably need to enclose this in some sort of eval(substitute(expr())) type expression, but my JSL is very rusty and I'm not sure where to start!

 

Any suggestions would be gratefully received.

 

Many thanks,

 

Matthew.

 

multiple_graph_boxes.png

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
vince_faller
Super User

Re: Programmable number of multiple graph boxes in a new window

Would something like this work?

 

Names default to here(1);
vlb = V List Box();
For( yy = 1, yy <= 5, yy++,
	vlb << Append(hlb = H List Box());
	For( xx = 1, xx <= 5, xx++,
		aa = xx + 5 * ( yy - 1 );
		Eval(EvalExpr(
			hlb << Append(
				Graph Box(
					framesize( 200, 200 ),
					X Scale( 0, 10 ),
					Y Scale( 0, 10 ),
					X Axis( Inc( 2 ), Minor Ticks( 1 ), Show Major Grid( 1 ), Show Minor Grid( 1 ) ),
					Y Axis( Inc( 2 ), Minor Ticks( 1 ), Show Major Grid( 1 ), Show Minor Grid( 1 ) ),
					XName( "Die X" ),
					YName( "Die Y" ),
					Text({1,5}, Expr(char(aa)) )
				)
			);
		));
	);
);

win01 = New Window( "test",
	Outline Box( "test",
		vlb
	)
);
Vince Faller - Predictum

View solution in original post

3 REPLIES 3
vince_faller
Super User

Re: Programmable number of multiple graph boxes in a new window

Would something like this work?

 

Names default to here(1);
vlb = V List Box();
For( yy = 1, yy <= 5, yy++,
	vlb << Append(hlb = H List Box());
	For( xx = 1, xx <= 5, xx++,
		aa = xx + 5 * ( yy - 1 );
		Eval(EvalExpr(
			hlb << Append(
				Graph Box(
					framesize( 200, 200 ),
					X Scale( 0, 10 ),
					Y Scale( 0, 10 ),
					X Axis( Inc( 2 ), Minor Ticks( 1 ), Show Major Grid( 1 ), Show Minor Grid( 1 ) ),
					Y Axis( Inc( 2 ), Minor Ticks( 1 ), Show Major Grid( 1 ), Show Minor Grid( 1 ) ),
					XName( "Die X" ),
					YName( "Die Y" ),
					Text({1,5}, Expr(char(aa)) )
				)
			);
		));
	);
);

win01 = New Window( "test",
	Outline Box( "test",
		vlb
	)
);
Vince Faller - Predictum

View solution in original post

Highlighted
matth1
New Contributor

Re: Programmable number of multiple graph boxes in a new window

Great, that works well! Now I will try and work out why it works.

 

Many thanks,

 

Matthew.

 

0 Kudos
vince_faller
Super User

Re: Programmable number of multiple graph boxes in a new window

Sorry for my late laziness.  Should have put that in there.  Here's my general thing on why yours doesn't work.  

JMP makes expressions return the last expressions in a glue statement ( which is what the ; operator does)

 

x = 1;
y = 2;
// is the same as 
glue(x=1, y=2);
//that's why it returns 2 if you run it.  

For loops however don't return the last thing.  THey just run.  But even if they did, in a displaybox like HListbox, it would only show the last thing (a single graphbox).  When dealing with displayboxes, in its construction.  You can put regular glue statements within it to return each display box.  

 

new window("Test", 
	x = 2;
	textbox("This won't show up");
	textbox("This will show up"), //notice this is a comma.  The whole glue will return just this last textbox
	hlb = hlistbox(); // this will also show up because nothing is after it even though it's a semicolon
);
// to add to the hlistbox dynamically, append is often used.  
wait(2);
hlb << Append(Textbox("Some other box"));

basically, instead of for()ing inside of your hlistbox constructor, create it with a reference and then append to it (them) in your for loops.  

With your hlb, I create hlb with each iteration of the row and append and then just overwrite the reference because I don't need it anymore.  

 

I hope this makes things more clear and not less.  

Vince Faller - Predictum