Current Data Table(dt);
dt << New column("Time Point Months", Formula(Round(:Time Point Days/30.438), 2));
gb_collector = Tab Box();
For(i = 1, i <= N Items(numPar), i++,
// Column box for plot of all batches
col1 = Col Box( "" );
// Column box for plot of actual data
col2 = Col Box( "" );
// Column box for plot of difference
col3 = Col Box( "" );
//tab = Tab Page Box("",
gb = dt << Graph Builder(
//invisible,
Size(700, 400),
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(gb);
//filter << close;
gb << close window;
// Within the loop through parameters we are now also looping through batches
For(k = 1, k <= N Items( cyc ), k++,
check = dt << get rows where(:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt_name | :Batch == bat[k] & :Component == numPar[i] & :Source Table == dt_name);
if(N items(check) > 0, // Create check to see if parameter exist for current batch
// Create base plot
gb = Graph Builder(
//invisible,
Size( 700, 400 ),
Variables( X( :Time Point Months ), Y( :Result ), Overlay( :Batch ) ),
Elements( Points( X, Y), )
);
gb << Local Data Filter(invisible, Add Filter( columns( :Component, :Batch, :Source Table ), Where( :Component == numPar[i] ), Where( :Batch == {cyc[k], bat[k]}), 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 liniear 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[k] & :Source Table == dt_name | :Batch == bat[k] & :Component == numPar[i] & :Source Table == dt_name)])*0.95;
maxval = max(:Result[dt << get rows where(:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt_name| :Batch == bat[k] & :Component == numPar[i] & :Source Table == dt_name)])*1.05;
maxvalts = max(:Time Point Months[dt << get rows where(:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt_name| :Batch == bat[k] & :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[k] & :Source Table == dt_name | :Batch == bat[k] & :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] || "]" )
);
If( N Items( unitList ) != 1,
gbb[Text Edit Box( 4 )] << Set text( numPar[i] )
);
// Set graph titel
gbb[Text Edit Box( 1 )] << Set text( numPar[i] || " vs. Time Point ");
// Append
//gbba = Report( gbb );
col2 << Append( gbb );
//filter << close;
gb << close window;
// Start second plot
gb2 = Graph Builder(
//invisible,
Size( 700, 400 ),
Variables( X( Time Point Months ), Y( :Difference ), Color( :Batch ) ),
Elements( Points( X, Y) )
);
gb2 << Local Data Filter(invisible, Add Filter( columns( :Component, :Batch, :Source Table ), Where( :Component == numPar[i] ), Where( :Batch == cyc[k]), Where( :Source Table == dt5_name)));
dt4 << Clear Select();
// Remove the filter display from the graph
gb2 << Show Control Panel( 0 );
// Report for changing plot
gbb2 = Report( gb2 )[GraphBuilderBox( 1 )];
gbb2 << Add Element( 1, 1, {Type( "Line" ), X, Y} );
// Get the HC value
l_idx = dt4 << Get rows where(dt4:Component == numPar[i] & :Batch == cyc[k]);
ul = min(dt4:HC[l_idx]);
if(Ismissing(ul),
if(min(:Difference[dt << get rows where(:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt5_name)]) == 0,
minval = -5;
maxval = 5,
minval = min(:Difference[dt << get rows where(:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt5_name)])*0.95;
maxval = max(:Difference[dt << get rows where(:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt5_name)])*1.05;
),
minval = min(:Difference[dt << get rows where(:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt5_name)],-ul)*1.05;
maxval = max(:Difference[dt << get rows where(:Component == numPar[i] & :Batch == cyc[k] & :Source Table == dt5_name)], ul)*1.05;
);
if(!ismissing(ul), //if no HC value dont create limit line
gbb2[AxisBox(2)] << Add Ref Line(ul,"solid", black, char(round(ul,2)));
gbb2[AxisBox(2)] << Add Ref Line(-ul,"solid", black, char(round(-ul,2)));
);
gbb2[AxisBox(2)] << Add Ref Line(0,"Dashed");
gbb2[AxisBox(2)] << min(minval);
gbb2[AxisBox(2)] << max(maxval);
gbb2[AxisBox(2)] << inc((maxval-minval)/10);
//Append
//gbba2 = Report( gbb2 );
col3 << Append( gbba2 );
//filter << close;
gb2 << close window;
);
);
//);
tab = Tab Page Box(numPar[i],
V List Box(
col1
H List Box( col2,col3 ) // Placing the two plots next to each other
)
);
tab << Title(numPar[i]);
//gb << title(Char(1));
gb_collector << Append(tab);
);
gb_collector << Dockable( 1 );
gb_collector << Set Overflow Enabled( 1 );
nw = New Window("My dashboard",
gb_collector
);
Here is my script..
Attached is a screenshot of my current dashboard, which contains 8 graphs. Here are my specific requirements for organizing these graphs:
- Keep the First Graph: I would like to retain the first graph as it is.
- Remove the Second Graph: The second graph should be removed from the dashboard.
- Pair the Last Six Graphs: The last six graphs should be paired such that each pair is displayed side by side. Specifically, the graphs should be organized as follows:
- The third and fourth graphs should be displayed next to each other.
- The fifth and sixth graphs should be displayed next to each other.
- The seventh and eighth graphs should be displayed next to each other.
To summarize, the final layout should have the first graph followed by three pairs of graphs, with each pair displayed side by side.