我繪製了圖表,我想要一個表格腳本,我可以使用它來刪除軸,並將圖表的 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 );