cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
yanee
Level III

Append Graphs into the new window

my data has 2 groups of input data  which I store it under column "Source Table".

Then, I write the for loop to plot graphs and set local filter from the source table.  The individual plots turn out correct however, in the new window where I try to append the plot, the plots don't have the local filter applied.

 

New Window( "Plot", tb = tab Box() );
For( i = 1, i <= N Items( list ), i++, 
	obj = Graph Builder(
		Size( 1122, 1095 ),
		Variables( X( :sequence ), Y( :Data ), Group X( :Source Table), Group X(:SERIAL_NO ), Group Y( :Group ), Overlay( :Label ) ),
		Elements( Line( X, Y, Legend( 10 ) ) ),
		Local Data Filter(
		Add Filter( 
			columns( :Source Table ),
			Where( :Source Table == list [i] ),
			Display( :Source Table, Size( 181, 34 ), List Display )
		)
	),
		SendToReport(
			Dispatch(
				{},
				"400",
				ScaleBox,
				{Legend Model(
					10,
					Properties( 0, {Line Style( "DashDot" )}, Item ID( "CTAP1", 1 ) ),
					Properties( 1, {Line Style( "DashDot" )}, Item ID( "CTAP2", 1 ) ),
					Properties( 2, {Line Color( 0 ), Line Style( "DashDot" )}, Item ID( "CTAP3", 1 ) ),
					Properties( 3, {Line Color( 9 ), Line Style( "DashDot" )}, Item ID( "CTAP4", 1 ) ),
					Properties( 4, {Line Style( "Dotted" )}, Item ID( "Inline_X", 1 ) ),
					Properties( 5, {Line Style( "Dotted" )}, Item ID( "Inline_Y", 1 ) ),
					Properties( 8, {Line Color( 5 )}, Item ID( "MZ1_L", 1 ) ),
					Properties( 9, {Line Color( 5 ), Line Style( "Dashed" )}, Item ID( "MZ1_R", 1 ) ),
					Properties( 10, {Line Color( 3 )}, Item ID( "MZ2_L", 1 ) ),
					Properties( 11, {Line Color( 3 ), Line Style( "Dashed" )}, Item ID( "MZ2_R", 1 ) ),
					Properties( 12, {Line Color( 0 )}, Item ID( "MZ3_L", 1 ) ),
					Properties( 13, {Line Color( 0 ), Line Style( "Dashed" )}, Item ID( "MZ3_R", 1 ) ),
					Properties( 14, {Line Color( 9 )}, Item ID( "MZ4_L", 1 ) ),
					Properties( 15, {Line Color( 9 ), Line Style( "Dashed" )}, Item ID( "MZ4_R", 1 ) )
				)}
			)
		)
	);
	tb << append( "Tab",Report( obj ) );
	//obj << delete;
	
);
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Append Graphs into the new window

I changed your script slightly, and it seems to be running without error.  The Local Filters are making the different selections.  Here is my script

Names Default To Here( 1 );
dt = Current Data Table();

Summarize( unique_value = by( :Source Table ) );
list = unique_value;

New Window( "Plot", Tab Box( "The Results", tb = H List Box() ) );
For( i = 1, i <= N Items( list ), i++,
	tb << append(
		obj = Graph Builder(
			Size( 1122, 1095 ),
			Variables(
				X( :sequence ),
				Y( :Data ),
				Group X( :Source Table ),
				Group X( :SERIAL_NO ),
				Group Y( :Group ),
				Overlay( :Label )
			),
			Elements( Line( X, Y, Legend( 10 ) ) ),
			Local Data Filter(
				Add Filter(
					columns( :Source Table ),
					Where( :Source Table == list[i] ),
					Display( :Source Table, Size( 181, 34 ), List Display )
				)
			),
			SendToReport(
				Dispatch(
					{},
					"400",
					ScaleBox,
					{Legend Model(
						10,
						Properties( 0, {Line Style( "DashDot" )}, Item ID( "CTAP1", 1 ) ),
						Properties( 1, {Line Style( "DashDot" )}, Item ID( "CTAP2", 1 ) ),
						Properties( 2, {Line Color( 0 ), Line Style( "DashDot" )}, Item ID( "CTAP3", 1 ) ),
						Properties( 3, {Line Color( 9 ), Line Style( "DashDot" )}, Item ID( "CTAP4", 1 ) ),
						Properties( 4, {Line Style( "Dotted" )}, Item ID( "Inline_X", 1 ) ),
						Properties( 5, {Line Style( "Dotted" )}, Item ID( "Inline_Y", 1 ) ),
						Properties( 8, {Line Color( 5 )}, Item ID( "MZ1_L", 1 ) ),
						Properties( 9, {Line Color( 5 ), Line Style( "Dashed" )}, Item ID( "MZ1_R", 1 ) ),
						Properties( 10, {Line Color( 3 )}, Item ID( "MZ2_L", 1 ) ),
						Properties( 11, {Line Color( 3 ), Line Style( "Dashed" )}, Item ID( "MZ2_R", 1 ) ),
						Properties( 12, {Line Color( 0 )}, Item ID( "MZ3_L", 1 ) ),
						Properties( 13, {Line Color( 0 ), Line Style( "Dashed" )}, Item ID( "MZ3_R", 1 ) ),
						Properties( 14, {Line Color( 9 )}, Item ID( "MZ4_L", 1 ) ),
						Properties( 15, {Line Color( 9 ), Line Style( "Dashed" )}, Item ID( "MZ4_R", 1 ) )
					)}
				)
			)
		)
	)
);
Jim

View solution in original post

9 REPLIES 9
txnelson
Super User

Re: Append Graphs into the new window

Try this...…..I don't have the data to test this against, however, the moving the append to include the actual platform, should provide you with the Local Data Filter.

New Window( "Plot", tb = Tab Box() );
For( i = 1, i <= N Items( list ), i++,
	tb << append(
		obj = Graph Builder(
			Size( 1122, 1095 ),
			Variables(
				X( :sequence ),
				Y( :Data ),
				Group X( :Source Table ),
				Group X( :SERIAL_NO ),
				Group Y( :Group ),
				Overlay( :Label )
			),
			Elements( Line( X, Y, Legend( 10 ) ) ),
			Local Data Filter(
				Add Filter(
					columns( :Source Table ),
					Where( :Source Table == list[i] ),
					Display( :Source Table, Size( 181, 34 ), List Display )
				)
			),
			SendToReport(
				Dispatch(
					{},
					"400",
					ScaleBox,
					{Legend Model(
						10,
						Properties( 0, {Line Style( "DashDot" )}, Item ID( "CTAP1", 1 ) ),
						Properties( 1, {Line Style( "DashDot" )}, Item ID( "CTAP2", 1 ) ),
						Properties( 2, {Line Color( 0 ), Line Style( "DashDot" )}, Item ID( "CTAP3", 1 ) ),
						Properties( 3, {Line Color( 9 ), Line Style( "DashDot" )}, Item ID( "CTAP4", 1 ) ),
						Properties( 4, {Line Style( "Dotted" )}, Item ID( "Inline_X", 1 ) ),
						Properties( 5, {Line Style( "Dotted" )}, Item ID( "Inline_Y", 1 ) ),
						Properties( 8, {Line Color( 5 )}, Item ID( "MZ1_L", 1 ) ),
						Properties( 9, {Line Color( 5 ), Line Style( "Dashed" )}, Item ID( "MZ1_R", 1 ) ),
						Properties( 10, {Line Color( 3 )}, Item ID( "MZ2_L", 1 ) ),
						Properties( 11, {Line Color( 3 ), Line Style( "Dashed" )}, Item ID( "MZ2_R", 1 ) ),
						Properties( 12, {Line Color( 0 )}, Item ID( "MZ3_L", 1 ) ),
						Properties( 13, {Line Color( 0 ), Line Style( "Dashed" )}, Item ID( "MZ3_R", 1 ) ),
						Properties( 14, {Line Color( 9 )}, Item ID( "MZ4_L", 1 ) ),
						Properties( 15, {Line Color( 9 ), Line Style( "Dashed" )}, Item ID( "MZ4_R", 1 ) )
					)}
				)
			)
		)
	);
);
Jim
yanee
Level III

Re: Append Graphs into the new window

Hi. txnelson

thanks for your quick reply but it doesn't work. Now it doesn't append anything in new window and for each graph, I got 2 plots.
txnelson
Super User

Re: Append Graphs into the new window

If you attach some sample data, I will take a look at it. The method I used is a tested method, I suspect there is something minor going wrong.
Jim
yanee
Level III

Re: Append Graphs into the new window

here is the sample. Thanks.

txnelson
Super User

Re: Append Graphs into the new window

I added a list named "list", and I had to move the closing ")" from the New Window statement to the end of the code.  And now it works on your sample data

names default to here(1);
dt=current data table();
list={"data"};

New Window( "Plot", tb = Tab Box() ,
For( i = 1, i <= N Items( list ), i++,
	tb << append(
		obj = Graph Builder(
			Size( 1122, 1095 ),
			Variables(
				X( :sequence ),
				Y( :Data ),
				Group X( :Source Table ),
				Group X( :SERIAL_NO ),
				Group Y( :Group ),
				Overlay( :Label )
			),
			Elements( Line( X, Y, Legend( 10 ) ) ),
			Local Data Filter(
				Add Filter(
					columns( :Source Table ),
					Where( :Source Table == list[i] ),
					Display( :Source Table, Size( 181, 34 ), List Display )
				)
			),
			SendToReport(
				Dispatch(
					{},
					"400",
					ScaleBox,
					{Legend Model(
						10,
						Properties( 0, {Line Style( "DashDot" )}, Item ID( "CTAP1", 1 ) ),
						Properties( 1, {Line Style( "DashDot" )}, Item ID( "CTAP2", 1 ) ),
						Properties( 2, {Line Color( 0 ), Line Style( "DashDot" )}, Item ID( "CTAP3", 1 ) ),
						Properties( 3, {Line Color( 9 ), Line Style( "DashDot" )}, Item ID( "CTAP4", 1 ) ),
						Properties( 4, {Line Style( "Dotted" )}, Item ID( "Inline_X", 1 ) ),
						Properties( 5, {Line Style( "Dotted" )}, Item ID( "Inline_Y", 1 ) ),
						Properties( 8, {Line Color( 5 )}, Item ID( "MZ1_L", 1 ) ),
						Properties( 9, {Line Color( 5 ), Line Style( "Dashed" )}, Item ID( "MZ1_R", 1 ) ),
						Properties( 10, {Line Color( 3 )}, Item ID( "MZ2_L", 1 ) ),
						Properties( 11, {Line Color( 3 ), Line Style( "Dashed" )}, Item ID( "MZ2_R", 1 ) ),
						Properties( 12, {Line Color( 0 )}, Item ID( "MZ3_L", 1 ) ),
						Properties( 13, {Line Color( 0 ), Line Style( "Dashed" )}, Item ID( "MZ3_R", 1 ) ),
						Properties( 14, {Line Color( 9 )}, Item ID( "MZ4_L", 1 ) ),
						Properties( 15, {Line Color( 9 ), Line Style( "Dashed" )}, Item ID( "MZ4_R", 1 ) )
					)}
				)
			)
		)
	);
);
);
Jim
yanee
Level III

Re: Append Graphs into the new window

hi,

 

sorry for not making myself clear. I try to create 2 plots based on column "Source Table". In the raw data, there are 2 categories (inner and outer).

 

I tried your script but change the list back to source table type.

Now the graph show in the new window but both graphs show local filter Source Table = inner.

 

I want it to show 

- first graph : local filter Source Table = inner.

- 2nd graph : local filter Source Table = outter.

 

 

Names Default To Here( 1 );
dt = Current Data Table();

Summarize( unique_value = by( :Source Table ) );
list = unique_value;

New Window( "Plot",
	tb = Tab Box(),
	For( i = 1, i <= N Items( list ), i++,
		tb << append(
			obj = Graph Builder(
				Size( 1122, 1095 ),
				Variables(
					X( :sequence ),
					Y( :Data ),
					Group X( :Source Table ),
					Group X( :SERIAL_NO ),
					Group Y( :Group ),
					Overlay( :Label )
				),
				Elements( Line( X, Y, Legend( 10 ) ) ),
				Local Data Filter(
					Add Filter(
						columns( :Source Table ),
						Where( :Source Table == list[i] ),
						Display( :Source Table, Size( 181, 34 ), List Display )
					)
				),
				SendToReport(
					Dispatch(
						{},
						"400",
						ScaleBox,
						{Legend Model(
							10,
							Properties( 0, {Line Style( "DashDot" )}, Item ID( "CTAP1", 1 ) ),
							Properties( 1, {Line Style( "DashDot" )}, Item ID( "CTAP2", 1 ) ),
							Properties( 2, {Line Color( 0 ), Line Style( "DashDot" )}, Item ID( "CTAP3", 1 ) ),
							Properties( 3, {Line Color( 9 ), Line Style( "DashDot" )}, Item ID( "CTAP4", 1 ) ),
							Properties( 4, {Line Style( "Dotted" )}, Item ID( "Inline_X", 1 ) ),
							Properties( 5, {Line Style( "Dotted" )}, Item ID( "Inline_Y", 1 ) ),
							Properties( 8, {Line Color( 5 )}, Item ID( "MZ1_L", 1 ) ),
							Properties( 9, {Line Color( 5 ), Line Style( "Dashed" )}, Item ID( "MZ1_R", 1 ) ),
							Properties( 10, {Line Color( 3 )}, Item ID( "MZ2_L", 1 ) ),
							Properties( 11, {Line Color( 3 ), Line Style( "Dashed" )}, Item ID( "MZ2_R", 1 ) ),
							Properties( 12, {Line Color( 0 )}, Item ID( "MZ3_L", 1 ) ),
							Properties( 13, {Line Color( 0 ), Line Style( "Dashed" )}, Item ID( "MZ3_R", 1 ) ),
							Properties( 14, {Line Color( 9 )}, Item ID( "MZ4_L", 1 ) ),
							Properties( 15, {Line Color( 9 ), Line Style( "Dashed" )}, Item ID( "MZ4_R", 1 ) )
						)}
					)
				)
			)
		);
	);
);

 

txnelson
Super User

Re: Append Graphs into the new window

I changed your script slightly, and it seems to be running without error.  The Local Filters are making the different selections.  Here is my script

Names Default To Here( 1 );
dt = Current Data Table();

Summarize( unique_value = by( :Source Table ) );
list = unique_value;

New Window( "Plot", Tab Box( "The Results", tb = H List Box() ) );
For( i = 1, i <= N Items( list ), i++,
	tb << append(
		obj = Graph Builder(
			Size( 1122, 1095 ),
			Variables(
				X( :sequence ),
				Y( :Data ),
				Group X( :Source Table ),
				Group X( :SERIAL_NO ),
				Group Y( :Group ),
				Overlay( :Label )
			),
			Elements( Line( X, Y, Legend( 10 ) ) ),
			Local Data Filter(
				Add Filter(
					columns( :Source Table ),
					Where( :Source Table == list[i] ),
					Display( :Source Table, Size( 181, 34 ), List Display )
				)
			),
			SendToReport(
				Dispatch(
					{},
					"400",
					ScaleBox,
					{Legend Model(
						10,
						Properties( 0, {Line Style( "DashDot" )}, Item ID( "CTAP1", 1 ) ),
						Properties( 1, {Line Style( "DashDot" )}, Item ID( "CTAP2", 1 ) ),
						Properties( 2, {Line Color( 0 ), Line Style( "DashDot" )}, Item ID( "CTAP3", 1 ) ),
						Properties( 3, {Line Color( 9 ), Line Style( "DashDot" )}, Item ID( "CTAP4", 1 ) ),
						Properties( 4, {Line Style( "Dotted" )}, Item ID( "Inline_X", 1 ) ),
						Properties( 5, {Line Style( "Dotted" )}, Item ID( "Inline_Y", 1 ) ),
						Properties( 8, {Line Color( 5 )}, Item ID( "MZ1_L", 1 ) ),
						Properties( 9, {Line Color( 5 ), Line Style( "Dashed" )}, Item ID( "MZ1_R", 1 ) ),
						Properties( 10, {Line Color( 3 )}, Item ID( "MZ2_L", 1 ) ),
						Properties( 11, {Line Color( 3 ), Line Style( "Dashed" )}, Item ID( "MZ2_R", 1 ) ),
						Properties( 12, {Line Color( 0 )}, Item ID( "MZ3_L", 1 ) ),
						Properties( 13, {Line Color( 0 ), Line Style( "Dashed" )}, Item ID( "MZ3_R", 1 ) ),
						Properties( 14, {Line Color( 9 )}, Item ID( "MZ4_L", 1 ) ),
						Properties( 15, {Line Color( 9 ), Line Style( "Dashed" )}, Item ID( "MZ4_R", 1 ) )
					)}
				)
			)
		)
	)
);
Jim
yanee
Level III

Re: Append Graphs into the new window

thank you.
yanee
Level III

Re: Append Graphs into the new window

Now i try to add another layer by create different "tab" by Subgroup.

In side each subgroup will be the same plot (by :Source Table)

 

Below is script. I got the new tab created but all plots are in the Tab "???"

 

Summarize( unique_value = by( :SubGroup) );
list1 = unique_value;

Summarize( unique_value = by( :Source Table ) );
list2 = unique_value;


New Window( "Plot", Tab Box( "The Results", tb = Tab Box(), vlb = V List Box() ) );
For( j = 1, j <= N Items( list1 ), j++,
	tb << Add(
		"Group" || list1[j], 

		For( i = 1, i <= N Items( list2 ), i++,
			tb << append(
				vlb << append(
					obj = Graph Builder(
						Size( 1122, 1095 ),
						Variables(
							X( :sequence ),
							Y( :Data ),
							Group X( :Source Table ),
							Group X( :SERIAL_NO ),
							Group Y( :Group ),
							Overlay( :Label )
						),
						Elements( Line( X, Y, Legend( 10 ) ) ),
						Local Data Filter(
							Add Filter(
								columns( :Source Table, :SubGroup ),
								Where( :Source Table == list2[i] ),
								Where( :SubGroup == list1[j] ),
								Display( :Source Table, Size( 181, 34 ), List Display )
							)
						),
						SendToReport(
							Dispatch(
								{},
								"400",
								ScaleBox,
								{Legend Model(
									10,
									Properties( 0, {Line Style( "DashDot" )}, Item ID( "CTAP1", 1 ) ),
									Properties( 1, {Line Style( "DashDot" )}, Item ID( "CTAP2", 1 ) ),
									Properties( 2, {Line Color( 0 ), Line Style( "DashDot" )}, Item ID( "CTAP3", 1 ) ),
									Properties( 3, {Line Color( 9 ), Line Style( "DashDot" )}, Item ID( "CTAP4", 1 ) ),
									Properties( 4, {Line Style( "Dotted" )}, Item ID( "Inline_X", 1 ) ),
									Properties( 5, {Line Style( "Dotted" )}, Item ID( "Inline_Y", 1 ) ),
									Properties( 8, {Line Color( 5 )}, Item ID( "MZ1_L", 1 ) ),
									Properties( 9, {Line Color( 5 ), Line Style( "Dashed" )}, Item ID( "MZ1_R", 1 ) ),
									Properties( 10, {Line Color( 3 )}, Item ID( "MZ2_L", 1 ) ),
									Properties( 11, {Line Color( 3 ), Line Style( "Dashed" )}, Item ID( "MZ2_R", 1 ) ),
									Properties( 12, {Line Color( 0 )}, Item ID( "MZ3_L", 1 ) ),
									Properties( 13, {Line Color( 0 ), Line Style( "Dashed" )}, Item ID( "MZ3_R", 1 ) ),
									Properties( 14, {Line Color( 9 )}, Item ID( "MZ4_L", 1 ) ),
									Properties( 15, {Line Color( 9 ), Line Style( "Dashed" )}, Item ID( "MZ4_R", 1 ) )
								)}
							)
						)
					)
				)
			
			)
		)
	)
		
);