调度到动态生成的堆积图表大家好,
我尝试生成一个报告,其中每个“参数”有 2 个图表,用于中位数和标准差,我正在努力在其中添加线条。
“Summary.jmp”文件包含多个带有“Lot”的列(我将其用作 X 轴),然后是几个参数,每个参数都有一个带有后缀“_Q50”的中位数列和一个带有后缀“_StdDev”的列.
我有一个参数列表,其中包含 Target、LowerSpecsLimit 和 UpperSpecsLimits(TGT、LSL、USL)。 我没有将它们直接放在列中,因为它们可以根据我选择的“批次”集进行更改,实际上我宁愿根本不触摸文件,以确保如果脚本失败我不会留下一团糟无论出于何种原因。
我也有 Dispatch 来替换标题和轴标签。
然后我有一个函数可以生成中位数和标准差图表,图表很好。
但是无论我在调度部分放什么,我都会收到错误
“在 {} 找不到 ScaleBox ...”
并且所有 TextEditor 调度似乎什么都不做(甚至没有错误,但我假设函数在第一次调度错误时停止?)
我生成了图表并进行了手动修改以检查生成的脚本,但没有帮助。 它直接使用“Param1_Q50”,当我把它放回脚本时,即使这样也不起作用!
这是代码:
NamesDefaultToHere(1);
Open("Summary.jmp");
GraphXSize = 800;
GraphYSize = 600;
ParamsList = {
{"Param1", "Name1", 0, -10, 10},
{"Param2", "Name2", 50, 25, 75}
};
ParamGraph = Function (
{parameter, title, tgt=".", lsl=".", usl="."},
LOCAL(
{Default Local},
medianCol = parameter || "_Q50";
stdevCol = parameter || "_StdDev";
gb = Graph Builder(
Size(GraphXSize,GraphYSize),
Show Control Panel(0),
Show Footer(0),
Show Legend(0),
Variables(
X(:Name("Lot")),
Y(Column(medianCol)),
Y(Column(stdevCol)),
Color(:Lot)
),
Elements(
Points(X, Y, Legend(6))
),
SendToReport(
Dispatch(
{},
medianCol,
ScaleBox,
{IF(tgt != ".", Add Ref Line(tgt, "Solid", "Black", "TARGET", 1)),
IF(lsl != ".", Add Ref Line(lsl, "Solid", "Purple", "LSL", 1)),
IF(usl != ".", Add Ref Line(usl, "Solid", "Red", "USL", 1))}
),
Dispatch({}, "graph title", TextEditor, {Set Text(title)}),
Dispatch({}, "Y title", TextEditor, {Set Text("Median")}),
Dispatch({}, "Y 1 title", TextEditor, {Set Text("Std Dev")})
),
);
);
);
New Window("Summary - Report",
For(i=1, i<=Length(ParamsList), i++,
ParamGraph(ParamsList[i][1], ParamsList[i][2], ParamsList[i][3], ParamsList[i][4], ParamsList[i][5])
)
) << Set Window Icon("Trellis")
我什至尝试用“Param1_Q50”替换 Dispatch 部分中的 medianCol,看看这是否是一个替换问题,期望第一个图表会得到线条而不是其他图表,但是......它没有用!
我也尝试参考报告
rgb = gb << report;
rgb[TextEditBox(5)] << Set Text("Median");
但我再次收到一条错误消息:
Cannot subscript Display Box in access or evaluation of 'Subscript' , rgb[/*###*/"TextEditor"]
有谁知道我如何解决这些图表的元素?
提前致谢!!
回复:调度到动态生成的堆积图表
回复:调度到动态生成的堆积图表嗨,吉姆,
确实,它确实有效!
我手动复制了您的更改,我犯了两个错误:
1. 我没有意识到“元素”行是强制性的
2. 我写的是“Parse(title)”而不是title
而且我更喜欢您的解决方案(更清洁的代码,没有“残留物”)。
非常感谢!
回复:调度到动态生成的堆积图表我在 JMP 12.2 下使用您的汇总表运行了我的脚本,它运行时没有出现错误。 下面是包含您的摘要表的脚本,以及我重新编写的脚本
Names Default To Here( 1 );
//Open("Summary.jmp");
dtsumm = New Table( "Summary",
Add Rows( 6 ),
New Column( "Lot",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 2, 3, 4, 5, 6] )
),
New Column( "Param1_Q50",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [-3, 7, 8, -12, 5, 0] )
),
New Column( "Param1_StdDev",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [0.2, 1, 0.6, 2, 0.2, 0.3] )
),
New Column( "Param2_Q50",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [23, 18, 54, 62, 78, 45] )
),
New Column( "Param2_StdDev",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [0.9, 1.2, 7, 3.6, 4.2, 1] )
)
);
// Run the script
GraphXSize = 800;
GraphYSize = 600;
ParamsList = {{"Param1", "Name1", 0, -10, 10},
{"Param2", "Name2", 50, 25, 75}};
ParamGraph = Function( {parameter, title, tgt = ., lsl = ., usl = .},
Local( {Default Local},
medianCol = parameter || "_Q50";
stdevCol = parameter || "_StdDev";
Eval(
Substitute(
Expr(
gb = dtSumm << Graph Builder(
Size( __GraphXSize__, __GraphYSize__ ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Show Footer( 0 ),
Variables( X( :lot ), Y( __Q50__ ), Y( __Std__ ), Color( :lot ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 6 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 7 ) ) ),
SendToReport(
Dispatch( {}, "graph title", TextEditBox, {Set Text( __title__ )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Median" )} ),
Dispatch( {}, "Y 1 title", TextEditBox, {Set Text( "Std Dev" )} )
)
)
),
Expr( __GraphXSize__ ), GraphXSize,
Expr( __GraphYSize__ ), GraphYSize,
Expr( __Q50__ ), Parse( MedianCol ),
Expr( __Std__ ), Parse( stdevCol ),
Expr( __Title__ ), title
)
);
If( Is Missing( tgt ) == 0,
report(gb)[AxisBox( 3 )] << Add Ref Line( tgt, "Solid", Black, "TARGET", 1 )
);
If( Is Missing( lsl ) == 0,
report(gb)[AxisBox( 3 )] << Add Ref Line( lsl, "Solid", Purple, "LSL", 1 )
);
If( Is Missing( usl ) == 0,
report(gb)[AxisBox( 3 )] << Add Ref Line( usl, "Solid", Red, "USL", 1 )
);
)
);
New Window( "Summary - Report",
For( i = 1, i <= Length( ParamsList ), i++,
ParamGraph( ParamsList[i][1], ParamsList[i][2], ParamsList[i][3], ParamsList[i][4], ParamsList[i][5] )
)
) << Set Window Icon( "Trellis" );回复:调度到动态生成的堆积图表嗨,吉姆,
我在我的 ref summary.jmp 文件上试过了,然后......
Cannot find TextEditBox[ "graph title" ] at {}
Cannot find TextEditBox[ "Y title" ] at {}
Cannot find TextEditBox[ "Y 1 title" ] at {}
Cannot subscript Display Box in access or evaluation of 'Subscript' , Report( gb )[/*###*/AxisBox( 3 )]
所以,如果这是一个错误,我应该提到我使用的是 JMP 12.1.0 64 位。
但无论如何,它适用于我的(脏)代码,所以我会处理它。 我将只有大量的树形结构窗口要关闭...
回复:调度到动态生成的堆积图表我想你会发现这个例子是处理你想要的更直接的方法
我不确定最终格式是否完全正确,但我相信您可以轻松修改它以满足您的需求
Names Default To Here( 1 );
//Open("Summary.jmp");
// Create a Sample data table
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
dt:npn1 << delete property( "spec limits" );
dt:pnp1 << delete property( "spec limits" );
dt:npn1 << set name( "Param1" );
dt:pnp1 << set name( "Param2" );
dt:lot_id << set name( "lot" );
dtSumm = dt << Summary(
Group( :lot ),
Median( :Param1 ),
Std Dev( :Param1 ),
Median( :Param2 ),
Std Dev( :Param2 ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column stat" )
);
dtSumm:Param1 Median << set name( "Param1_Q50" );
dtSumm:Param2 Median << set name( "Param2_Q50" );
dtSumm:Param1 Std Dev << set name( "Param1_StdDev" );
dtSumm:Param2 Std Dev << set name( "Param2_StdDev" );
// Run the script
GraphXSize = 800;
GraphYSize = 600;
ParamsList = {{"Param1", "Name1", 0, -10, 10},
{"Param2", "Name2", 50, 25, 75}};
ParamGraph = Function( {parameter, title, tgt = ., lsl = ., usl = .},
Local( {Default Local},
medianCol = parameter || "_Q50";
stdevCol = parameter || "_StdDev";
Eval(
Substitute(
Expr(
gb = dtSumm << Graph Builder(
Size( __GraphXSize__, __GraphYSize__ ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Show Footer( 0 ),
Variables( X( :lot ), Y( __Q50__ ), Y( __Std__ ), Color( :lot ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 6 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 7 ) ) ),
SendToReport(
Dispatch( {}, "graph title", TextEditBox, {Set Text( __title__ )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Median" )} ),
Dispatch( {}, "Y 1 title", TextEditBox, {Set Text( "Std Dev" )} )
)
)
),
Expr( __GraphXSize__ ), GraphXSize,
Expr( __GraphYSize__ ), GraphYSize,
Expr( __Q50__ ), Parse( MedianCol ),
Expr( __Std__ ), Parse( stdevCol ),
Expr( __Title__ ), title
)
);
If( Is Missing( tgt ) == 0,
report(gb)[AxisBox( 3 )] << Add Ref Line( tgt, "Solid", Black, "TARGET", 1 )
);
If( Is Missing( lsl ) == 0,
report(gb)[AxisBox( 3 )] << Add Ref Line( lsl, "Solid", Purple, "LSL", 1 )
);
If( Is Missing( usl ) == 0,
report(gb)[AxisBox( 3 )] << Add Ref Line( usl, "Solid", Red, "USL", 1 )
);
)
);
New Window( "Summary - Report",
For( i = 1, i <= Length( ParamsList ), i++,
ParamGraph( ParamsList[i][1], ParamsList[i][2], ParamsList[i][3], ParamsList[i][4], ParamsList[i][5] )
)
) << Set Window Icon( "Trellis" );
回复:调度到动态生成的堆积图表经过多次尝试和失败,我设法做到了(不是很直观!)
所以,我没有使用 SendToReport,而是使用了下标。
如果我在函数内部有它,它就不起作用。 我不得不把它拿出来:
NamesDefaultToHere(1);
Open("Summary.jmp");
GraphXSize = 800;
GraphYSize = 600;
ParamsList = {
{"Param1", "Name1", 0, -10, 10},
{"Param2", "Name2", 50, 25, 75}
};
ParamGraph = Function (
{parameter, title, tgt=., lsl=., usl=.},
LOCAL(
{Default Local},
medianCol = parameter || "_Q50";
stdevCol = parameter || "_StdDev";
return = Graph Builder(
Size(GraphXSize,GraphYSize),
Show Control Panel(0),
Show Footer(0),
Show Legend(0),
Variables(
X(:Name("Lot")),
Y(Column(medianCol)),
Y(Column(stdevCol)),
Color(:Lot)
),
Elements(
Points(X, Y, Legend(6))
)
);
);
);
wind = New Window("Summary - Report",
For(i=1, i<=Length(ParamsList), i++,
gb= ParamGraph(ParamsList[i][1], ParamsList[i][2], ParamsList[i][3], ParamsList[i][4], ParamsList[i][5]);
rgb = gb << report;
rgb << showtreestructure;
IF(
IsMissing(ParamsList[i][3]) == 0,
rgb[PictureBox(1), GraphBuilderBox(1), GraphBuilderAxisBox(2)] << Add Ref Line(ParamsList[i][3], "Solid", "Black", "TARGET", 1);
);
IF(
IsMissing(ParamsList[i][4]) == 0,
rgb[PictureBox(1), GraphBuilderBox(1), GraphBuilderAxisBox(2)] << Add Ref Line(ParamsList[i][4], "Solid", "Purple", "LSL", 1);
);
IF(
IsMissing(ParamsList[i][5]) == 0,
rgb[PictureBox(1), GraphBuilderBox(1), GraphBuilderAxisBox(2)] << Add Ref Line(ParamsList[i][5], "Solid", "Red", "USL", 1);
);
rgb[PictureBox(1), GraphBuilderBox(1), GraphBuilderTitleBox(1)] << Set Text(ParamsList[i][2]);
rgb[PictureBox(1), GraphBuilderBox(1), GraphBuilderTitleBox(3)] << Set Text ("Median");
rgb[PictureBox(1), GraphBuilderBox(1), GraphBuilderTitleBox(4)] << Set Text ("Standard Deviation");
)
) << Set Window Icon("Trellis");
还要注意这一行:
rgb << showtreestructure;
如果我没有它,它就不起作用!
这很烦人,因为我不知道之后如何自动关闭它,但至少,它现在可以工作了!
回复:调度到动态生成的堆积图表嗨,吉姆,
谢谢! 我做了更正,但它没有解决我的问题。
在 {} 找不到 ScaleBox["medianCol"]
或者如果我硬编码它”:
在 {} 找不到 ScaleBox["Param1_Q50"]
请注意,如果我删除第二个 Y 轴图表,那么参考线会突然起作用,但不会重命名标题和轴。
回复:调度到动态生成的堆积图表谢谢 - 看起来吉姆已经覆盖了你
回复:调度到动态生成的堆积图表嗨大卫,
这是一个summary.jmp。
Re: Dispatch 到动态生成的堆积图您的限制的数据类型不匹配。 “添加参考线”要求线值(第一个值)必须是数值。 在您的函数中,您将其设置为字符串。
ParamGraph = Function( {parameter, title, tgt = ".", lsl = ".", usl = "."}
在你的 If 语句中
If( tgt != ".",
元素列表需要更改为数字
ParamGraph = Function( {parameter, title, tgt = ".", lsl = ., usl = .}
并且 If 语句需要更改为:
If( IsMissing(tgt) == 0,
Re: Dispatch 到动态生成的堆积图如果您可以提供我们可以运行的代码,那么帮助您会容易得多。 这意味着要么提供表“summary.jmp”,要么重写代码以使用 JMP 附带的示例数据表之一。