707228_zh-TW
根據變數建模類型動態變更圖形產生器圖表類型

本節介紹如何動態變更圖形產生器中的元素類型,取決於使用者在列切換器中選擇連續或分類 x 軸變數。元素是在圖形產生器選項板頂部顯示為圖示的圖形類型。對於連續輸入,新增了一個單選按鈕,讓使用者可以在擬合線和輪廓之間進行選擇。當為非 JMP 專家並且只需要有限數量的選項的人建立互動式圖表時,此秘訣非常有用。
腳步- Start with 名稱預設為此處(1) and open 大班.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
- Create a function which sends a message to the 圖形產生器 platform that removes the existing element then adds a new one. It assumes that the 積分 element is already displayed and is element number 1, therefore the element to be removed is number 2.
// This function changes the type of chart being displayed.
// It takes a reference to a Graph Builder report (gbr) and the chart type required (gr)
// At the moment it assumes the Points element will always be included
changeElement = function( {gbr, gr},
{default local},
Eval(
Substitute(
Expr(
gbr << remove element( 1, 1, 2 ) << add element( 1, 1, {Type( __aa__ ), X, Y} )
), Expr( __aa__ ), gr
)
)
);
- Create the new window which contains the column switcher (CS) to change the x-axis, a radio box (RB) to control the element type for continuous variables, and the Graph Builder (國標).
rb_out = "Line of Fit";
win1 = New Window( "Demo",
Text Box(
"Column switching between continuous and nominal variables will change line of fit to box plots",
<<SET wrap=""></SET>
<P>列切換器是在圖形生成器外部特意創建的,因此我們可以稍後創建一個函數,以便在切換器更改時採取操作。</P>
<OL start="6">
<LI>Link the column switcher <FONT face="courier new,courier">CS</FONT> to the Graph Builder <FONT face="courier new,courier">國標</FONT>
<PRE><CODE class=" language-jsl">cs << link platform( gb );
Create a Column Switch Handler. The function post is called by the handler once the change has been completed. The format comes directly from the Scripting Index.
post = Function( {previousColumn, currentColumn, switcher},
gbr = Report( gb )[GraphBuilderBox( 1 )];
If( Column( dt, cs << get current ) << get modeling type == "Continuous",
changeElement( gbr, rb_out ),
changeElement( gbr, "Box Plot" )
);
);
cs << Make Column Switch Handler( 1, post );
請注意,切換完成之前不需要發生任何事情,因此Make Column Switch Handler的第一個參數不執行任何操作。
Finally, start the column switcher running for demo purposes.
cs << run();
潛在的變化:
- 建立一個「預」更改函數,該函數迭代圖形產生器中的現有元素(使用<< Get Elements ),找到需要刪除的元素並以程式設計方式設定<< remove element 中的第三個參數(而不是依賴它)是第二個元素)。
<LINGO-LABS id="lingo-labs-707228" slang="en-US" mode="UPDATE"><LINGO-LABEL>自動化和腳本編寫</LINGO-LABEL><LINGO-LABEL>甜點</LINGO-LABEL></LINGO-LABS>
Comments
There are no comments yet