cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
SpannerHead
Level V

Custom Dialog

I have a custom dialog script I find very useful but it has a small annoyance.  The script allows me to select parameters for a number of bivariate plots that will be annotated.  The one issue I have relates to the fact that I'm dealing with grouped columns and the selection dialog is blind to the grouping.  I have other dialogs that show the columns grouped, so I know it can work.

 

This works

 

dt = Current Data Table();
cdg = Column Dialog( exx = ColList( "X", Min Col( 1 ), Max Col( 1 ) ) );
cdg2 = Column Dialog( exy = ColList( "Y", Min Col( 1 ), Max Col( 1 ) ) );
Notes = cdg2["exy"][1] << Get Property( "Notes" );
lstColGroups = dt << get column groups names;
myColGroup = "";
For Each( {i}, lstColGroups,
	lstCols = dt << get column group( i );
	If( Contains( lstCols, cdg2["exy"][1] ),
		myColGroup = i
	);
);
Graph Builder(
	Size( 798, 624 ),
	Show Control Panel( 1 ),
	Variables( X( cdg["exx"][1] ), Y( cdg2["exy"][1] ) ),
	Elements( Points( X, Y, Legend( 2 ) ), Smoother( X, Y, Legend( 3 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Add Text Annotation(
				Text( "Category: " || Notes ),
				Fixed Size( 0 ),
				Text Box( {1, -30, 382, 184} ),
				Filled( 0 )
			)}
		)
	)
);

This does not

 

Names Default To Here( 1 );
dt = Current Data Table();
If( !Namespace Exists( "Custom Dialog" ),
	dialogRecallNS = New Namespace(
		"Custom Dialog",
		{
			ycolRecall =
			{
			}
			,
			orderRecall =
			{
			}
			,
			byRecall =
			{
			}
		}
	)
,
	dialogRecallNS = Namespace( "Custom Dialog" )
);
nc = N Col( dt );
lbWidth = 130;
pgm = Expr(
	nw = New Window( "Annotated Multiple Plots",
		For( i = 1, i <= N Items( exy ), i++,
			Notes = Try( Column( dt, exy[i] ) << Get Property( "Notes" ) );
			Try(
				Bivariate(
					Y( exy[i] ),
					X( exx[1] ),
					SendToReport(
						Dispatch(
							{},
							"",
							AxisBox( 2 ),
							Add Text Annotation(
								Text( "Category: " || Notes ),
								Fixed Size( 0 ),
								Text Box( {-80, 25, 0, 50} ),
								Filled( 0 )
							)
						)
					)
				)
			);
		)
	)
);
clearRoles = Expr(
	colListY << RemoveAll;
	colListX << RemoveAll;
);
recallRoles = Expr(
	dialogRecallNS:ycolRecall = colListY << GetItems;
	dialogRecallNS:orderRecall = colListX << GetItems;
);
customDlg = New Window( "Enter Variables",
	Border Box( Left( 3 ), top( 2 ),
		V List Box(
			Text Box( "Bivariate Modeling" ), 
			H List Box(
				V List Box(
					Panel Box( "Select Columns",
						colListData = Col List Box(
							All,
							width( lbWidth ),
							nLines( Min( nc, 10 ) )
						)
					)
				),
				Panel Box( "Cast Selected Columns into Roles",
					Lineup Box( N Col( 2 ), Spacing( 3 ),
						Button Box( "Y",
							colListY << Append( colListData << GetSelected )
						),
						colListY = Col List Box(
							width( lbWidth ),
							nmin( 1 ),
							nLines( 5 ),
							numeric
						),
						Button Box( "X",
							colListX << Append( colListData << GetSelected )
						),
						colListX = Col List Box(
							width( lbWidth ),
							nLines( 1 ),
							numeric
						)
					)
				),
				Panel Box( "Action",
					Lineup Box( N Col( 1 ),
						Button Box( "OK",
							recallRoles;
							exy = colListY << get items;
							exx = colListX << get items;
							pgm;
							customDlg << CloseWindow;
						),
						Button Box( "Cancel", customDlg << CloseWindow ),
						Button Box( "Reset", clearRoles ),
						Text Box( " " ),
						Button Box( "Remove",
							colListY << RemoveSelected;
							colListX << RemoveSelected;
						),
						Button Box( "Recall",
							clearRoles;
							Try(
								colListY << Append( dialogRecallNS:ycolRecall );
								colListX << Append( dialogRecallNS:orderRecall );
							);
						)
					)
				)
			)
		)
	)
);
colListx << set min items( 1 );
colListy << set min items( 1 );

SpannerHead_0-1741715084704.png

 

 


Slán



SpannerHead
1 ACCEPTED SOLUTION

Accepted Solutions
SpannerHead
Level V

Re: Custom Dialog

Looks like replacing

 

Col List Box(

with

 

Filter Col Selector(

Does the trick.

 

Finished product looks like this.

Names Default To Here( 1 );
dt = Current Data Table();
If( !Namespace Exists( "Custom Dialog" ),
	dialogRecallNS = New Namespace(
		"Custom Dialog",
		{
			ycolRecall =
			{
			}
			,
			orderRecall =
			{
			}
			,
			byRecall =
			{
			}
		}
	)
,
	dialogRecallNS = Namespace( "Custom Dialog" )
);
nc = N Col( dt );
lbWidth = 130;
pgm = Expr(
	nw = New Window( "Annotated Multiple Plots",
		For( i = 1, i <= N Items( exy ), i++,
			Notes = Try( Column( dt, exy[i] ) << Get Property( "Notes" ) );
			Try(
				Bivariate(
					Y( exy[i] ),
					X( exx[1] ),
					SendToReport(
						Dispatch(
							{},
							"",
							AxisBox( 2 ),
							Add Text Annotation(
								Text( "Category: " || Notes ),
								Fixed Size( 0 ),
								Text Box( {-80, 25, 0, 50} ),
								Filled( 0 )
							)
						)
					)
				)
			);
		)
	)
);
clearRoles = Expr(
	colListY << RemoveAll;
	colListX << RemoveAll;
);
recallRoles = Expr(
	dialogRecallNS:ycolRecall = colListY << GetItems;
	dialogRecallNS:orderRecall = colListX << GetItems;
);
customDlg = New Window( "Example of a Custom Dialog",
	Border Box( Left( 3 ), top( 2 ),
		V List Box(
			Text Box( "Example dialog to demonstrate a Recall button" ),
			H List Box(
				V List Box(
					Panel Box( "Select Columns",
						colListData = Filter Col Selector(
							All,
							width( lbWidth ),
							nLines( Min( nc, 10 ) )
						)
					)
				),
				Panel Box( "Cast Selected Columns into Roles",
					Lineup Box( N Col( 2 ), Spacing( 3 ),
						Button Box( "Y",
							colListY << Append( colListData << GetSelected )
						),
						colListY = Col List Box(
							width( lbWidth ),
							nmin( 1 ),
							nLines( 5 ),
							numeric
						),
						Button Box( "X",
							colListX << Append( colListData << GetSelected )
						),
						colListX = Col List Box(
							width( lbWidth ),
							nLines( 1 ),
							numeric
						)
					)
				),
				Panel Box( "Action",
					Lineup Box( N Col( 1 ),
						Button Box( "OK",
							recallRoles;
							exy = colListY << get items;
							exx = colListX << get items;
							pgm;
							customDlg << CloseWindow;
						),
						Button Box( "Cancel", customDlg << CloseWindow ),
						Button Box( "Reset", clearRoles ),
						Text Box( " " ),
						Button Box( "Remove",
							colListY << RemoveSelected;
							colListX << RemoveSelected;
						),
						Button Box( "Recall",
							clearRoles;
							Try(
								colListY << Append( dialogRecallNS:ycolRecall );
								colListX << Append( dialogRecallNS:orderRecall );
							);
						)
					)
				)
			)
		)
	)
);
colListx << set min items( 1 );
colListy << set min items( 1 );

 

 


Slán



SpannerHead

View solution in original post

2 REPLIES 2
SpannerHead
Level V

Re: Custom Dialog

I figured out that

 

Column Dialog(

allows me to see the categories.  However, it is not clear where I would add this in the dysfunctional script to get it fixed?

 


Slán



SpannerHead
SpannerHead
Level V

Re: Custom Dialog

Looks like replacing

 

Col List Box(

with

 

Filter Col Selector(

Does the trick.

 

Finished product looks like this.

Names Default To Here( 1 );
dt = Current Data Table();
If( !Namespace Exists( "Custom Dialog" ),
	dialogRecallNS = New Namespace(
		"Custom Dialog",
		{
			ycolRecall =
			{
			}
			,
			orderRecall =
			{
			}
			,
			byRecall =
			{
			}
		}
	)
,
	dialogRecallNS = Namespace( "Custom Dialog" )
);
nc = N Col( dt );
lbWidth = 130;
pgm = Expr(
	nw = New Window( "Annotated Multiple Plots",
		For( i = 1, i <= N Items( exy ), i++,
			Notes = Try( Column( dt, exy[i] ) << Get Property( "Notes" ) );
			Try(
				Bivariate(
					Y( exy[i] ),
					X( exx[1] ),
					SendToReport(
						Dispatch(
							{},
							"",
							AxisBox( 2 ),
							Add Text Annotation(
								Text( "Category: " || Notes ),
								Fixed Size( 0 ),
								Text Box( {-80, 25, 0, 50} ),
								Filled( 0 )
							)
						)
					)
				)
			);
		)
	)
);
clearRoles = Expr(
	colListY << RemoveAll;
	colListX << RemoveAll;
);
recallRoles = Expr(
	dialogRecallNS:ycolRecall = colListY << GetItems;
	dialogRecallNS:orderRecall = colListX << GetItems;
);
customDlg = New Window( "Example of a Custom Dialog",
	Border Box( Left( 3 ), top( 2 ),
		V List Box(
			Text Box( "Example dialog to demonstrate a Recall button" ),
			H List Box(
				V List Box(
					Panel Box( "Select Columns",
						colListData = Filter Col Selector(
							All,
							width( lbWidth ),
							nLines( Min( nc, 10 ) )
						)
					)
				),
				Panel Box( "Cast Selected Columns into Roles",
					Lineup Box( N Col( 2 ), Spacing( 3 ),
						Button Box( "Y",
							colListY << Append( colListData << GetSelected )
						),
						colListY = Col List Box(
							width( lbWidth ),
							nmin( 1 ),
							nLines( 5 ),
							numeric
						),
						Button Box( "X",
							colListX << Append( colListData << GetSelected )
						),
						colListX = Col List Box(
							width( lbWidth ),
							nLines( 1 ),
							numeric
						)
					)
				),
				Panel Box( "Action",
					Lineup Box( N Col( 1 ),
						Button Box( "OK",
							recallRoles;
							exy = colListY << get items;
							exx = colListX << get items;
							pgm;
							customDlg << CloseWindow;
						),
						Button Box( "Cancel", customDlg << CloseWindow ),
						Button Box( "Reset", clearRoles ),
						Text Box( " " ),
						Button Box( "Remove",
							colListY << RemoveSelected;
							colListX << RemoveSelected;
						),
						Button Box( "Recall",
							clearRoles;
							Try(
								colListY << Append( dialogRecallNS:ycolRecall );
								colListX << Append( dialogRecallNS:orderRecall );
							);
						)
					)
				)
			)
		)
	)
);
colListx << set min items( 1 );
colListy << set min items( 1 );

 

 


Slán



SpannerHead