我绘制了图表,我想要一个表格脚本,我可以使用它来删除轴,并将图表的 x 轴值发送到图表标题,然后再将其保存为 PPT。 我不想隐藏图表中的轴,直到我有机会手动重新缩放它们(数据变化太大而无法使用设定值),所以我可以稍后将它们用作演示文稿的插图。 这可行吗?
这是将删除轴的 2 段代码,然后是重新显示轴的代码
Names Default To Here( 1 );
obj = Current Report();
(obj << xpath( "//AxisBox" )) << visibility( "collapse" );
Names Default To Here( 1 );
obj = Current Report();
(obj << xpath( "//AxisBox" )) << visibility( "visible" );
此外@txnelson这是一个如何工作的例子。
XPath 的使用有点棘手,因为它将处理该类型的所有项目,您需要查看具体(或全部)要更改/评估的项目。
要获得 x 值(最小值最大值),我最好的想法是评估脚本。 可能还有另一种选择。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
obj = dt << Graph Builder(
Size( 528, 454 ),
Show Control Panel( 0 ),
Graph Spacing( 5 ),
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);
obj << bring window to front();
Wait( 1 );
// change the x-axis of the graph
obj << SendToReport( Dispatch( {}, "height", ScaleBox, {Min( 60.50 ), Max( 65 ), Inc( 2 ), Minor Ticks( 0 )} ) );
Wait( 3 );
// get title of x-axis and show result in log
x_axis_text = (obj << xpath( "//TextEditBox" ))[3] << get text();
Show( x_axis_text );
// collapse x-axis
(obj << xpath( "//AxisBox" ))[1] << visibility( "collapse" );
// get script of Graph Builder to evaluate min and max values
script = obj << get script();
min_txt = Regex( Char( Name Expr( script ) ), "Min\([0-9]+[.]*[0-9]*\)" );
max_txt = Regex( Char( Name Expr( script ) ), "Max\([0-9]+[.]*[0-9]*\)" );
Show( min_txt, Type( max_txt ) );
// set graph title accordingly
(obj << xpath( "//TextEditBox" ))[1] << set text( x_axis_text || " from " || min_txt || " to " || max_txt );