获取图例项的问题在 JMP18 (18.1.1) 中,来自脚本索引的这个示例不起作用:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
Variables( X( :height ), Y( :weight ), Overlay( :sex ), Color( :age ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
server = gb << Get Legend Server;
items = server << Get Legend Items;
For Each( {item, index}, items[1],
item << Set Label( "Item " || Char( index ) )
);
它会产生错误消息:

因此,图例服务器<<获取图例项目()
不返回可编写脚本的对象?
自动化和脚本回复:获取图例物品:没有可编写脚本的对象解决方法:
使用获取图例项目
不要忘记预先评估i以获取传奇物品
- 对于设置标签,不需要进行预先评估。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
Variables( X( :height ), Y( :weight ), Overlay( :sex ), Color( :age ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
server = gb << Get Legend Server;
Nitems = Nitems(( server << Get Legend Items)[1]);
for(i=1, i<= Nitems, i++,
Eval(Eval Expr(item = server << Get Legend Item(1, Expr(i))));
item << Set Label( "Item " || Char( i ) )
);
回复:获取图例物品:没有可编写脚本的对象下一个陷阱:不适用于条形图吗?
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb =Graph Builder(
Variables( X( :age ), Y( :weight ), Overlay( :sex ) ),
Elements( Bar( X, Y ) )
);
server = gb << Get Legend Server;
items = server << Get Legend Items;
show(items);
server << get legend item(1,1) // error message

编辑:我无法在另一台计算机上/重新启动 JMP 后重现该问题(?)。
回复:获取图例物品:没有可编写脚本的对象它实际上确实返回了可编写脚本的对象。这似乎是 For Each() 的一个错误。如果您将代码更改为应该等效的代码,它就可以正常工作。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
Variables( X( :height ), Y( :weight ), Overlay( :sex ), Color( :age ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
server = gb << Get Legend Server;
items = server << Get Legend Items;
For Each( {item, index}, items[1],
items[1][index] /*isn't this exactly what item is?*/ << Set Label( "Item " || Char( index ) )
);回复:获取图例物品:没有可编写脚本的对象啊,抱歉,您是对的,单个项目确实是可以编写脚本的。
Interesting: a batch message like items << get label produces the same issue.
maybe batch messages use 对于每个 in the background ?
深入挖掘后,我发现了一张旧票:TS-00128192
幸运的是,与此同时,这个问题得到了足够的重视——在 JMP19 (EA5) 中它被修复了:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
Variables( X( :height ), Y( :weight ), Overlay( :sex ), Color( :age ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
);
server = gb << Get Legend Server;
items = server << Get Legend Items;<BR /><BR />items << get label // same issue as with for each
show(items[1][1])
items[1][1] << get label(); // OK, on the lowest level, there <U>is</U> a scriptable object
Show(tmp = items[1][1::2]); // then this is a list of ...
tmp[1] << get Label(); // ...no
回复:获取图例物品:没有可编写脚本的对象
@mmarchandFSLR写道:
它实际上确实返回了可编写脚本的对象。
另一方面......有点令人惊讶:

JMP19:
