Jarmo
I modified the script with your suggestions and it works except in a very isolated case where the data has an odd interdigitisation resulting from a transpose.
dt = Current Data Table();
dt << Clear Column Selection();
colList = dt << get column names( string );
check_list = {"VT", "ID", "DI", "IK", "GM"};
New Window( "Select Variables",
<<Modal,
<<On Validate( window:validated ),
window:enable function = Function( {},
{Default Local},
X = window:lbMajor << Get Selected;
Y = window:lbMinor << Get Selected;
If( N Items( X ) & N Items( Y ) & X != Y,
window:validated = 1,
window:validated = 0
);
window:ok button << Enable( window:validated );
);
H List Box(
V List Box(
Text Box( "Select X Variable" ),
window:lbMajor = List Box(
check_list,
<<Set Max Selected( 1 ),
enable function
)
),
V List Box(
Text Box( "Select Y Variable" ),
window:lbMinor = List Box(
check_list,
<<Set Max Selected( 1 ),
enable function
)
)
);,
H List Box(
window:ok button = Button Box( "OK",
X = window:lbMajor << Get Selected;
Y = window:lbMinor << Get Selected;
If( N Items( X ) & N Items( Y ) & X != Y,
window:validated = 1,
window:validated = 0
);
If( window:validated,
Print( "Processing with X: " || Char( X ) || ", Y: " || Char( Y ) );
Window( "Select Variables" ) << Close Window;
,
Beep();
Show( "Invalid Selection" );
{window:lbMajor, window:lbMinor} << Select;
window:lbMajor << Inval << Update Window;
Wait( 0.25 );
{window:lbMajor, window:lbMinor} << DeSelect;
window:lbMajor << Inval << Update Window;
Wait( 0.25 );
{window:lbMajor, window:lbMinor} << Select;
window:lbMajor << Inval << Update Window;
Wait( 0.25 );
{window:lbMajor, window:lbMinor} << DeSelect;
window:lbMajor << Inval << Update Window;
);,
<<Enable( 0 )
),
Button Box( "Cancel", Throw( "!Canceled Analysis" ) )
)
);
If(
X[1] == "VT", Xparam = "VT",
X[1] == "ID", Xparam = "ID",
X[1] == "DI", Xparam = "DI",
X[1] == "IK", Xparam = "IK",
X[1] == "GM", Xparam = "GM"
);
If(
Y[1] == "VT", Yparam = "VT",
Y[1] == "ID", Yparam = "ID",
Y[1] == "DI", Yparam = "DI",
Y[1] == "IK", Yparam = "IK",
Y[1] == "GM", Yparam = "GM"
);
Show( Xparam );
Show( Yparam );
For( i = 1, i <= N Cols( dt ), i++,
If(
Contains( Munger( Head Name( As Namespace( colList[i] ) ), 0, 2 ), Xparam )
& Contains(
Head Name( As Namespace( colList[i] ) ),
"% Delta From Target"
),
Column( colList[i] ) << Set Selected( 1 )
)
);
non_excluded_rows = dt << get rows where(!Excluded());
target = dt << get selected columns();
found_list = {};
Show( target );
New Window( "Compilation",
For( j = 1, j <= N Items( target ), j++,
Notes = target[j] << Get Property( "Notes" );
If(
Contains(
Munger( Head Name( As Namespace( target[j] ) ), 0, 2 ),
Xparam
),
Connected = Substitute( Head Name( As Namespace( target[j] ) ),
Xparam, Yparam
);
Insert Into( found_list, Connected );
Try(
biv = Bivariate(
Y( Column( dt, found_list[j] ) ),
X( Column( dt, target[j] ) ),
Automatic Recalc( 1 ),
SendToReport(
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Frame Size( 470, 470 ),
Add Text Annotation(
Text( "Category: " || Notes ),
Fixed Size( 0 ),
Filled( 0 ),
Font( "Segoe UI", 10, "Bold" )
), Add Graphics Script(
2,
Description( "" ),
Transparency( 0.5 );
Pen Color( "Black" );
Fill Color( "Red" );
Oval( -100, -100, 100, 100, 1 );
Pen Color( "Black" );
Fill Color( "Green" );
Oval( -90, -90, 90, 90, 1 );
Pen Color( "Black" );
Fill Color( "Blue" );
Oval( -80, -80, 80, 80, 1 );
Pen Color( "Black" );
Line( [-110 0 110], [0 0 0] );
Line( [0 0 0], [-110 0 110] );
Oval( -80, -80, 80, 80 );
Oval( -90, -90, 90, 90 );
Oval( -100, -100, 100, 100 );
)}
)
)
);
ms = Report( biv )[FrameBox( 1 )] << Find Seg( Marker Seg( 1 ) );
xs = ms << Get X Values |/ 110;
ys = ms << Get Y Values |/ 110;
x_there = Loc( !Is Missing( xs[non_excluded_rows] ) );
y_there = Loc( !Is Missing( ys[non_excluded_rows] ) );
ind = Associative Array( x_there );
ind << Intersect( Associative Array( y_there ) );
ind = Matrix( ind << Get Keys );
xs = xs[ind];
ys = ys[ind];
val = Max( Max( Abs( xs|/ 110 ) ), Max( Abs( ys|/ 110 ) ) );
xaxis = Report( biv )[AxisBox( 1 )];
yaxis = Report( biv )[AxisBox( 2 )];
xaxis << Min( -1 * val ) << Max( val );
yaxis << Min( -1 * val ) << Max( val );
);
);
)
);
Slán
SpannerHead