I would like to combine the tab page box method with the for loop, but it doesn't work.
Here is my part of the script:
New Window("My Dashboard",
H Splitter Box(
Size(1000, 1000),
// Loop for each parameter
For(i = 1, i <= N Items(numPar), i++,
// Column boxes for plots of all batches, actual data, and difference
col1 = Col Box(""),
col2 = Col Box(""),
col3 = Col Box(""),
// Tab Page Box for each parameter
Tab Page Box(
Title(numPar[i] || " vs. Time Point"),
// Create all batches plot
gb = Graph Builder(
Size(500, 500),
Variables(X(:Time Point Months), Y(:Result), Overlay(:Batch)),
Elements(Points(X, Y))
),
// Local filter: set the batch to only the batches that are in cyc with a ref, not all other batches
gb << Local Data Filter(
invisible,
Add Filter(
columns(:Component, :Batch, :Source Table),
Where(:Component == numPar[i]),
Where(:Batch == {cyc, bat}),
Where(:Source Table == dt_name)
)
),
dt << Clear Select(),
// Remove the filter display from the graph
gb << Show Control Panel(0),
// Report for changing plot
gbb = Report(gb)[GraphBuilderBox(1)],
// Add linear regression
gbb << Add Element(
1,
1,
{Type("Line Of Fit"), X, Y, Confidence of Fit(0), Equation(0)}
),
// Set Y axis
minval = Min(
:Result[dt << get rows where(
:Component == numPar[i] & :Batch == cyc & :Source Table == dt_name |
:Batch == bat & :Component == numPar[i] & :Source Table == dt_name
)]
) * 0.95,
maxval = Max(
:Result[dt << get rows where(
:Component == numPar[i] & :Batch == cyc & :Source Table == dt_name |
:Batch == bat & :Component == numPar[i] & :Source Table == dt_name
)]
) * 1.05,
maxvalts = Max(
:Time Point Months[dt << get rows where(
:Component == numPar[i] & :Batch == cyc & :Source Table == dt_name |
:Batch == bat & :Component == numPar[i] & :Source Table == dt_name
)]
) * 1.05,
gbb[AxisBox(1)] << Min(-0.1),
gbb[AxisBox(1)] << Max(maxvalts),
gbb[AxisBox(2)] << Min(minval),
gbb[AxisBox(2)] << Max(maxval),
gbb[AxisBox(2)] << inc((maxval - minval) / 10),
// Set Y axis label
unitList = Associative Array(
:Result Unit[dt << get rows where(
:Component == numPar[i] & :Batch == cyc & :Source Table == dt_name |
:Batch == bat & :Component == numPar[i] & :Source Table == dt_name
)]
) << Remove("") << Get Keys,
If(N Items(unitList) == 1,
gbb[Text Edit Box(4)] << Set text(numPar[i] || " [" || unitList[1] || "]"),
gbb[Text Edit Box(4)] << Set text(numPar[i])
),
// Set graph title
gbb[Text Edit Box(1)] << Set text(numPar[i] || " vs. Time Point"),
// Append
gbba = Report(gb),
col1 << Append(gbba),
<<Moveable(1)
)
)
),
<<Dockable(1)
);
Edit 2024-09-05 jthi: added jsl formatting