如何以编程方式遍历图形构建器树结构并将框架框与其标题相关联。我有一个分析(见下文),我想使用我编写的脚本来注释特定图表。 例如我想给XXX104和XXX107添加注释。 在这两个图表上,我将添加自定义图形和文本来标识我想要引起注意的一组点。

使用命令“<<显示树结构”我可以识别具有每个图表的框架框。 但是,我没有看到与它们相关的图表“名称”。 例如,我希望能够使用图表名称(例如 XXX107)作为查找来遍历该树并识别关联的框架框(例如 FrameBox(7)),以便我可以引用它并以自动方式添加注释。

事实上,在整个树中,我没有看到任何具有“图表名称”的“树节点”,例如 XXX107
最终下图是我想要实现的目标

这是我用来手动执行此操作的代码。 文件也已上传。
我的问题是我无法弄清楚如何通过识别显示树中相应的“标题”来引用框架框。
干杯,特洛伊
clearLog();
try(close(DT, noSave));
DT = open("PRE_CLEAN_DATA.jmp", invisible);
DT << newColumn("ENT_CLUSTER", character, nominal, formula(:ENTITY || "_" || :CLUSTER));
Plat = newWindow("CHART",
myGraphBox = DT << Graph Builder(
Size( 1446, 747 ),
Show Control Panel( 0 ),
Variables(
X( :WW ),
Y( :ENTITY_MEAN ),
Y( :GRAND_MEAN, Position( 1 ) ),
Wrap( :ENTITY ),
Color( :CLUSTER )
),
Elements(
Points( X, Y( 1 ), Y( 2 ), Legend( 23 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Legend( 24 ) )
),
SendToReport(
Dispatch(
{},
"WW",
ScaleBox,
{Min( 202301.28 ), Max( 202320.72 ), Inc( 1 ), Minor Ticks( 1 ),
Label Row(
{Automatic Tick Marks( 0 ), Label Orientation( "Vertical" ),
Show Minor Ticks( 0 )}
)}
)
)
);
summarize(DT, clusters = by(:ENT_CLUSTER));
foreach({item}, clusters,
if(contains(item, "NON_CLUSTER"), continue());
ent = word(1, item, "_");
clust = word(2, item, "_");
write("Entity = " || ent || "\!n");
write("Cluster = " || clust || "\!n");
left = min(DT:WW[DT << getRowsWhere(:ENT_CLUSTER == item)]);
right = max(DT:WW[DT << getRowsWhere(:ENT_CLUSTER == item)]);
group_mean_min = min(DT:ENTITY_MEAN[DT << getRowsWhere(:ENT_CLUSTER == item)]);
group_mean_max = max(DT:ENTITY_MEAN[DT << getRowsWhere(:ENT_CLUSTER == item)]);
grand_mean_min = min(DT:GRAND_MEAN[DT << getRowsWhere(:ENT_CLUSTER == item)]);
grand_mean_max = max(DT:GRAND_MEAN[DT << getRowsWhere(:ENT_CLUSTER == item)]);
if(group_mean_min < grand_mean_min, bot = group_mean_min, bot = grand_mean_min);
if(group_mean_max > grand_mean_max, top = group_mean_max, top = grand_mean_max);
write("Left, Right, Top, Bot = " || char(left) || ", " || char(right) || ", " || char(top) || ", " || char(bot) || "\!n");
// ##########################################################
// ## This is what I want to do:
// ##########################################################
// 1. Traverse the graphbox tree
// 2. Identify Frame Box for each of the entities found
// 3. Get the Framebox Reference
// 4. Add my annotation.
// This is a manual Example I made using the show properties and tree structure commands
//myGraphBox << Show Properties();
//myGraphBox << Show tree structure();
rep = myGraphBox << report;
framebox = rep[frame box( 7 )];
framebox << Add Graphics Script(
penColor( "Black" );
fillcolor("Blue");
Transparency(0.1);
rect( left, top, right, bot, 0 );
rect( left, top, right, bot, 1 );
);
framebox << Add Graphics Script(
textSize(9);
textColor("Blue");
text( {left, top}, "Cluster 1" );
);
write("\!n");
);
);
自动化和脚本编写回复:如何以编程方式遍历图形构建器树结构并将框架框与其标题相关联。GFrameBox 按特定顺序排序(使用 Value Order 列属性强制它可能是一个好主意)。 您可以根据该顺序获取框架索引
cluster_rows = Loc(dt[0, "ENT_CLUSTER"], "XXX104_CLUSTER1");
fb_idx = Contains(clusters, "XXX104_CLUSTER1"); // framebox idx // might not work in all cases!
fbs = Report(myGraphBox) << XPath("//FrameBox");
Eval(EvalExpr(
fbs[fb_idx] << Add Graphics Script(
Pen Color("Black");
Fill Color("Red");
Transparency(0.1);
Rect(Expr(left), Expr(top), Expr(right), Expr(bot), 0);
Rect(Expr(left), Expr(top), Expr(right), Expr(bot), 1);
);
));
还要记住将这些值评估为图形脚本,这样您就不会得到这样的结果。

一般来说,GraphBuilderGroupBox 非常难以访问/操作,我会尽力避免它。 您可以使用 XPath 获取标题,但可能会有额外的标题
(Report(myGraphBox) << XPath("//GraphBuilderGroupBox/text()"))
{"ENTITY", "XXX101", "XXX102", "XXX103", "XXX104", "XXX105", "XXX106", "XXX107","XXX112", "XXX118", "XXX119"}回复:如何以编程方式遍历图形构建器树结构并将框架框与其标题相关联。快速而肮脏的完整示例:
Names Default To Here(1);
dt = Open("$DOWNLOADS/PRE_CLEAN_DATA.jmp", invisible);
dt << New Column("ENT_CLUSTER", character, nominal, formula(:ENTITY || "_" || :CLUSTER));
gb = dt << Graph Builder(
Size(1446, 747),
Show Control Panel(0),
Variables(X(:WW), Y(:ENTITY_MEAN), Y(:GRAND_MEAN, Position(1)), Wrap(:ENTITY), Color(:CLUSTER)),
Elements(Points(X, Y(1), Y(2), Legend(23)), Smoother(X, Y(1), Y(2), Legend(24))),
SendToReport(
Dispatch(
{},
"WW",
ScaleBox,
{Min(202301.28), Max(202320.72), Inc(1), Minor Ticks(1), Label Row(
{Automatic Tick Marks(0), Label Orientation("Vertical"), Show Minor Ticks(0)}
)}
)
)
);
rep = Report(gb);
fbtitles = (rep << XPath("//GraphBuilderGroupBox/text()"));
Remove From(fbtitles, Contains(fbtitles, "ENTITY")); // we "know" we have wrap variable
// or we could perform filtering using Filter Each
Summarize(dt, clusters = by(:ENT_CLUSTER));
For Each({item}, clusters,
If(Contains(item, "NON_CLUSTER"),
Continue()
);
ent = Word(1, item, "_");
clust = Word(2, item, "_");
Write("Entity = " || ent || "\!n");
Write("Cluster = " || clust || "\!n");
left = Min(DT:WW[DT << getRowsWhere(:ENT_CLUSTER == item)]);
right = Max(DT:WW[DT << getRowsWhere(:ENT_CLUSTER == item)]);
group_mean_min = Min(DT:ENTITY_MEAN[DT << getRowsWhere(:ENT_CLUSTER == item)]);
group_mean_max = Max(DT:ENTITY_MEAN[DT << getRowsWhere(:ENT_CLUSTER == item)]);
grand_mean_min = Min(DT:GRAND_MEAN[DT << getRowsWhere(:ENT_CLUSTER == item)]);
grand_mean_max = Max(DT:GRAND_MEAN[DT << getRowsWhere(:ENT_CLUSTER == item)]);
If(group_mean_min < grand_mean_min,
bot = group_mean_min,
bot = grand_mean_min
);
If(group_mean_max > grand_mean_max,
top = group_mean_max,
top = grand_mean_max
);
Write("Left, Right, Top, Bot = " || Char(left) || ", " || Char(right) || ", " || Char(top) || ", " || Char(bot) || "\!n");
framebox = rep[frame box(Contains(fbtitles, ent);)];
Eval(EvalExpr(
framebox << Add Graphics Script(
Pen Color("Black");
Fill Color("Blue");
Transparency(0.1);
Rect(Expr(left), Expr(top), Expr(right), Expr(bot), 0);
Rect(Expr(left), Expr(top), Expr(right), Expr(bot), 1);
);
));
Eval(EvalExpr(
framebox << Add Graphics Script(
Text Size(9);
Text Color("Blue");
Text({Expr(left), Expr(top)}, Expr(clust));
);
));
Write("\!n");
);

(我之前为晶圆图做过类似的事情)
回复:如何以编程方式遍历图形构建器树结构并将框架框与其标题相关联。感谢贾莫的帮助。
我还没有完成一大堆遍历这些树的工作,但你解释它的方式很棒......也许这可能是明年脚本俱乐部的主题:)
干杯,特洛伊
回复:如何以编程方式遍历图形构建器树结构并将框架框与其标题相关联。深入研究报告层绝对是一个好主题。