检测图形标题的图形脚本我想设置一个自定义图形脚本,以便每个图形根据关联数组中包含的信息获得一条唯一的线。 在下面的例子中,我想在每个类别的线上有一个不同的图表......对于我的实际使用,我需要图表来“识别”它下面的标题,这样我就可以使用正确的值来创建线.
对于下面的示例图像,我手动将“F”图形脚本更新为“F”。 所以我正在寻找“收集图形信息”的语法......在我的脑海中,如果我可以抓住大纲框标题,我可以操纵它来获得我需要的东西......但我不确定那是否是唯一/最好的选择。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
graphInfo = "M";// need to extract so it's "F" for female graph
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )
}
)
)
);

大规模定制回复:检测图形标题的图形脚本@马克贝利谢谢你的想法! 很高兴知道 summarize 将匹配图表在报告中的创建顺序。 这是我可以在我的几个脚本中看到的用途 
@Craige_Hales这个功能真是个很酷的主意,我也得试试看!
回复:检测图形标题的图形脚本如果你把整个图形脚本变成一个函数,它会得到一个这参数即框框。 你可以爬上大纲来抓住标题。 好处是知道你得到的大纲包含这图形。
Outline title copied into graph by graphic scriptOutline title copied into graph by graphic script通过图形脚本复制到图形中的大纲标题
dt = Open( "$sample_data/big class.jmp", invisible );
bv = dt << Bivariate( Y( :weight ), X( :height ), Fit Line );
(bv << report)[framebox( 1 )] << addgraphicsscript(
// if a function is used, it must be the only statement in the graphic script
Function( {this},{titlebox=this},
// the function can use this to find the frame box, climb to an Outline title...
While( (titlebox << classname) != "OutlineBox", titlebox = titlebox << parent );
// then other graphics commands
Text( center justified, {60, 120}, (titlebox << gettitle) );
Circle( {60, 120}, 30 );
this<<BACKGROUNDCOLOR></BACKGROUNDCOLOR>回复:检测图形标题的图形脚本另一种方法可能是在启动 Bivariate 之前确定这些值。 Summarize() 函数可用于确定级别以相同的顺序并且它们在使用 By 变量或 Where() 子句时出现。
Summarize( level = By( :Group ) );
变量 level 以正确的顺序在 :Group 数据列中存储所有唯一级别的字符串列表。 所以你的图形脚本不需要查询轮廓显示框来找出它在哪里。
回复:检测图形标题的图形脚本那也可以, @jthi ...如所写,它不会像我长期需要的那样动态,但我可以使用它来构建自定义迭代器变量,因此每个图都有相同的变量,但设置为不同的数字,对应于它的位置在报告中。
再次感谢大家的想法!
回复:检测图形标题的图形脚本通过以下方式扩展其中一个代码@txnelson :
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Grid Line Order(1 ), Reference Line Order( 3)}
)
)
);
rep = biv << Get As Report;
For( i = 1, i <= N Items(rep), i++,
keyForAa = Substr(Report(rep [i])[Outline Box( 1 )] << get title,
Contains(Report(rep [i])[Outline Box( 1 )] << get title, "=" ) + 1);
//see Add Graphics Script example from Scripting Index
framebox = Report(rep [i])[frame box(1)];
Eval(EvalExpr(framebox << Add Graphics Script(
2,
Description( "" ),
Y Function(Expr(test[keyForAa][1]) * x + Expr(test[keyForAa][2]), x );
)));
);回复:检测图形标题的图形脚本令人着迷的是你可以从 0 开始 i 并且它就像那样“神奇地”迭代...... 我在下面粘贴了错误,但似乎至少起到了一些作用。 我在创建 graphInfo 变量之前创建了一个 show(i) 命令。
它似乎对这两个图很有效,但由于某种原因,它还迭代了两次,导致无法定位 biv[i] ...所以我将该部分包装在 Try() 中,它似乎可以作为必要的!
1)我不确定为什么“i”会这样迭代,或者我什么时候可以将它用于 jsl 中的其他功能
2)我不确定为什么它似乎又重复了两次......每个图形一次,每个图形脚本一次?
3)太感谢了在这里寻求帮助... 我可能还不明白它是如何/为什么工作的,但如果我能让它始终如一地工作,那就是胜利!

Names default to here(1);
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
i=0;
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
i++;
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
show(i);
Try(
graphInfo = word(2,report(biv[i])[OutlineBox(1)] << get title,"=");
show(graphinfo);
);
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )
}
)
)
);回复:检测图形标题的图形脚本尝试这个
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
i=0;
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
i++;
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
graphInfo = word(2,report(biv[i])[OutlineBox(1)] << get title,"=");
show(graphinfo);
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )
}
)
)
);回复:检测图形标题的图形脚本就是这样....从图形脚本本身,我能知道那个信息吗?
从外面获得称号很容易。
我希望能够将完全相同的图形脚本放入报告的每个图形中,并让该脚本能够找出它的位置。
回复:检测图形标题的图形脚本您将需要知道您需要从哪个大纲框获取标题,但在那之后,这是一个简单的获取标题
graph title = report( biv[1] )[OutlineBox(1)] << get title;
回复:检测图形标题的图形脚本我不是要更新标题,而是要获取标题信息……从图形脚本中获取。 一旦我有了标题信息,我就可以进行所有的字符串操作。
理想情况下,我需要在图形脚本中放入一些内容,例如“graphTitle = graph << get title;”然后从那里开始,但我不确定这是可能的,除非对象“知道”它包含在树的哪一部分中......
回复:检测图形标题的图形脚本这是对您的脚本的修改,将更新标题

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
By( :sex ),
SendToReport(
Dispatch(
{},
"1",
ScaleBox,
{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
Minor Ticks( 1 )}
),
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
///gather graph info to get "F" or "M" from output
graphInfo = "M";// need to extract so it's "F" for female graph
Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
), Grid Line Order( 1 ), Reference Line Order( 3 )}
)
)
);
For( i = 1, i <= N Items( biv ), i++,
Report( biv[i] )[Outline Box( 1 )] << set title(
Substr(
Report( biv[i] )[Outline Box( 1 )] << get title,
Contains( Report( biv[i] )[Outline Box( 1 )] << get title, "=" ) + 1
)
)
);