I found an alternate solution that in my view is cleaner then Jim's brute force method.
Instead I am defining two lists at the beginning of my function:
p = {};
l = {};
summarize(unique_values=by(OverlayCol));
NSplits = N Items (unique_values);
For(i=0, i < NSplits, i+=1,
p = Insert(p, -1);
l = Insert(l, i);
);
pl = Insert(p, l);
to create the two lists needed for the points and lines (in my case) legend items then passing those lists as matrices that into the graph builder dispatch as follows:
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, Matrix(p), 9, Matrix(l)} ),
Position( Matrix(pl))}
)
Full version of the updated function:
RadPlotCreator1XGroupTest = Function({dt, XCol, YCol, OverlayCol, GroupXCol}, {Default Local},
p = {};
l = {};
summarize(unique_values=by(OverlayCol));
NSplits = N Items (unique_values);
For(i=0, i < NSplits, i+=1,
p = Insert(p, -1);
l = Insert(l, i);
);
pl = Insert(p, l);
gb = dt << Graph Builder(
Size( 849, 622 ),
Fit to Window( "Off" ),
Show Control Panel(0),
Grid Color( "Black" ),
Variables(
X( XCol ),
Y( YCol ),
Group X( GroupXCol ),
Overlay( OverlayCol )
),
Elements(Points(X, Y, Legend(3)), Smoother( X, Y, Legend( 9 ) )),
SendToReport(
Dispatch(
{},
"",
ScaleBox,
{}
),
Dispatch(
{},
"",
ScaleBox,
{}
),
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, Matrix(p), 9, Matrix(l)} ),
Position( Matrix(pl))}
)
)
);
sb = report(gb)[ScaleBox(5)];
For(i=0, i < NSplits, i+=1,
sb << Legend Model(3, Properties(i, {Transparency(0.2)}));
);
frame_list = gb << xpath("//FrameBox");
num_frames = N Items (frame_list);
For(i=1, i <= num_frames, i+=1,
Report(gb)[Framebox(i)] << Background Color(White);
Report(gb)[Framebox(i)] << Grid Line Order( Back );
Report(gb)[Framebox(i)] << Reference Line Order( Back );
Report(gb)[Framebox(i)] << Frame Size(250, 250);
Report(gb)[Framebox(i)] << X Axis(0, 150, Inc(20), Minor Ticks(1),
Add Ref Line( 70, Solid, "Black", "", 2 ),
Add Ref Line( 120, Solid, "Black", "", 2 ),
Add Ref Line( 135, Solid, "Black", "", 2 ), Show Major Grid( 1 ));
Report(gb)[Framebox(i)] << Y Axis(Minor Ticks(1));
);
gbp = Report( gb );
img = gbp << getpicture();
return(img);
);