I have a script that generates boxplots in Graph Builder, but as it was first captured from a graph. Here is the code:
inboundDataTable << New Script("Boxplots and Means for Sites w/Low Read Rates",
Names Default to Here(1);
Delete Symbols();
inboundData = Current Data Table();
inboundData << Graph Builder(
Size(650, 481),
Grid Color({79, 98, 40}),
Variables(X(:IDENT Code), Y(:Read Rate)),
Elements(
Box Plot(X, Y, Legend(2), Jitter("Random Normal")),
Points(X, Y, Legend(3), Summary Statistic("Mean"))
),
SendToReport(
Dispatch(
{},
"Read Rate",
ScaleBox,
{
Format("Percent", 5, 0),
Minor Ticks(4),
Add Ref Line(0.95, "Solid", {255, 0, 0}, "", 1),
Label Row({Show Major Grid(1), Show Minor Grid(1)})
}
),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
2,
Base(1, 0, 0, Item ID("Read Rate", 2)),
Properties(1, {Fill Color(0)}, Item ID("Read Rate", 2)),
Properties(
-1,
{Line Color(-4221340), Marker("FilledCircle"), Fill Color(0)},
Item ID("Mean", 1)
)
), Legend Model(
3,
Properties(
0,
{Line Color(-16776960), Marker("Diamond"), Fill Color(0)},
Item ID("Mean", 1)
)
)}
),
Dispatch({}, "X title", TextEditBox, {Set Text("Crossing (Site)")}),
Dispatch(
{},
"Graph Builder",
FrameBox,
{
Marker Size(5), Grid Line Order(1), Reference Line Order(2),
DispatchSeg(
Box Plot Seg("Box Plot (ALC)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (CIA)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (JKM)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (POR)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (RAI)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (THO)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
)
}
)
)
)
);
Near the bottom is the FrameBox block where you can see a DispatchSeg for each boxplot that was created from the original graph. What I wish to do is make that section of the code dynamic, as the number of sites may be different for each site population.
What I need is a way to capture the number of unique sites that have not been excluded, and then use that count to create a loop to set the line and fill colors for each boxplot. How can I go about this.