你好。 有沒有一種方法可以獲取圖形生成器窗口中使用的變量名稱和角色? 假設我有一個包含圖形生成器繪圖的窗口。 有沒有辦法以編程方式確定哪個變量用於 X、Y、Xgroup、Ygroup 等?
例如,假設用戶創建了一個以 GB 為單位的繪圖。 現在他們希望在繪圖上運行一些通用腳本(例如圖形腳本)。 腳本需要知道哪些變量在哪些角色中使用,而無需用戶告知。
假設我從這個情節開始:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
Variables(X(:height), Y(:weight)),
Elements(Points(X, Y), Smoother(X, Y))
);
現在我希望在生成的圖上運行腳本。 我的劇本不知道情節中包含什麼。 這是我嘗試過但沒有成功的兩件事:
Names Default to Here(1);
//Try to get script used to create plot
win = Window(1); //gets most recent window clicked on
gb = win << Report; //DNW: returns missing (win is not a platform)
scr = gb << Get Script; //from here I could parse the string to determine the roles
//Another stab: try to read the XML
win = Window(1);
str = win << Get XML; //This gives me the XML of the window, but does not provide the actual variable names used in the roles.
如果我能弄清楚如何將窗口引用轉換為報告,我想我可以讓第一種方法發揮作用。 有任何想法嗎?
</CODE></P></LINGO-BODY><LINGO-LABS id="lingo-labs-272624" slang="en-US" mode="NONE"><LINGO-LABEL>高級統計建模</LINGO-LABEL><LINGO-LABEL>大規模定制</LINGO-LABEL><LINGO-LABEL>質量和工藝工程</LINGO-LABEL></LINGO-LABS><LINGO-SUB id="lingo-sub-273136" slang="en-US" mode="NONE">回复:從 graphbuilder 獲取變量名稱</LINGO-SUB><LINGO-BODY id="lingo-body-273136" slang="en-US" mode="NONE">謝謝。 這正是我所需要的。</LINGO-BODY><LINGO-SUB id="lingo-sub-273026" slang="en-US" mode="NONE">回复:從 graphbuilder 獲取變量名稱</LINGO-SUB><LINGO-BODY id="lingo-body-273026" slang="en-US" mode="NONE"><P><A href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3648" target="_blank">@尼克爾斯</A>你是對的,懸停標籤功能是基於交互性的。 有多種方法可以使用 JSL 觸發該操作(通過移動鼠標、暫停等),但這會給解決方案增加很多您實際上不需要的複雜性。</P>
<P>根據您的回復和提出的解決方案<A href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687" target="_blank">@tx尼爾森</A>,這裡有一個腳本,它將帶您從窗口引用一直到圖形生成器變量引用。</P>
<PRE><CODE class=" language-jsl">Names Default to Here(1);
win = New Window("A Title", // Let's create a Window that contains a Graph Builder
Graph Builder( // with a LDF to make things interesting (multiple OutlineBoxes).
Size( 517, 448 ),
Show Control Panel( 0 ),
Variables( X( :sex ), Y( :height ) ),
Elements( Bar( X, Y, Legend( 6 ) ) ),
Local Data Filter(
Add Filter( columns( :height ), Where( :height >= 60.048 & :height <= 70 ) )
)
));
ob = win[OutlineBox("Graph Builder")]; // This is how you get the Display Box that contains the GB object
gbb = ob << Get Scriptable Object; // Now we extract the GB object from the Display Box
gb_expr = gbb << Get Script; // You could wrap in Char() to get the GB script as a string
gb_nargs = NArg(gb_expr); // and use pattern matching. Instead,
for(i = 1, i <= gb_nargs, i++, // let's see how to inspect it as an expression.
child = Arg(gb_expr, i);
If (HeadName(child) == "Variables",
var_nargs = NArg(child);
for(j = 1, j <= var_nargs, j++,
Show(Arg(child, j))
);
Break();
)
);
你應該看到:
Arg(child, j) = X(:sex);
Arg(child, j) = Y(:height);
JMP 15 中添加的懸停標籤擴展允許您定義將在圖形上下文(準確地說是懸停標籤執行上下文)中執行的腳本。 此上下文在有關懸停在其上的視覺元素的局部變量中提供信息,包括哪些變量被用作“分組”(X、GroupX、GroupY 等)和測量值(Y、顏色、大小等)。
您可以在自己的腳本中訪問這些變量,或許還可以使用它們來定義新的可視化或分析。 這正是懸停標籤預設的工作原理。 您可能想要選擇一個,然後在懸停標籤編輯器(或通過保存腳本)中查看生成的 JSL 代碼以查看示例。
您還可以使用 Textlet“上下文”預設來查看它們的值(可從懸停標籤編輯器上的 Textlet 面板獲取):

給出了執行上下文中可用的變量的完整列表這裡。
我以為我記得以前有過一個關於這個的問題,但是我搜索了一下,沒有找到。無論如何,我用來做這種事情的方法是向圖形生成器發送一條消息,以檢索用於創建顯示的腳本,並將其轉換為字符變量,然後解析字符串以查找提到的變量。
劇本
names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");
gb = Graph Builder(
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 6 ) ), Smoother( X, Y, Legend( 7 ) ) )
);
theScript = char(gb << get script);
show(theScript);
檢索:
theScript = "Graph Builder(Variables(X(:weight), Y(:height)), Elements(Points(X, Y, Legend(6)), Smoother(X, Y, Legend(7))))";