創建“值顏色”屬性如何編寫為數據表列創建一組值顏色的腳本,而不必指定它們實際是什麼?
我問是因為我有一個應用程序希望找到與選定列關聯的“值顏色”屬性,如果該屬性不存在,它將崩潰。 我不想自己定義實際顏色,因為它們無關緊要:我只需要在那裡是值顏色屬性。
只需右鍵單擊相關列,然後從屬性列表中選擇“Value Colors”,我就可以非常輕鬆地以交互方式執行此操作,然後會自動為我定義一個默認集。 因此,我需要編寫腳本的本質是此操作 - 我猜想解決方案將是一行代碼,但恐怕我看不到它。 誰能幫忙?
回复:創建“值顏色”屬性完美的!問專家總是比試圖得到更好那某種構造權:)
非常感謝,吉姆!
回复:創建“值顏色”屬性ExprList 未正確構造。您需要在列表中包含文字值,而不是計算值。這是實現這一目標的一種方法
// Start of script;
Names Default To Here( 1 );
Clear Log();
dt = Open( "$SAMPLE_DATA/Big Class.JMP" );
Summarize( NamesList = by( :Name ) );
Show( NamesList );
// Build the ExprLIst to be exactly what the Value Colors
// list needs to be
ExprList = {};
For( i = 1, i <= N Items( NamesList ), i++,
Eval(
Substitute(
Expr(
Insert Into( ExprList, Expr( __Names__ = __color__ ) )
),
Expr( __Names__ ), NamesList[i],
Expr( __color__ ), 2 + i
)
)
);
Show( ExprList );
// Then insert the resulting expression as the Value Colors property of the :Names column, and I should get what I want.
:Name << set property( "Value Colors", ExprList );
// The Value Colors property is correct;
Show( :Name << get property( "Value Colors" ) );回复:創建“值顏色”屬性非常感謝 Peter 和 CWillden 的幫助;不幸的是,我仍然不在那裡 - 但我已經能夠將問題具體化一點。隨附的腳本顯示了我現在所處的位置:如果我能解決關於如何創建表達式列表的最後一個困難,然後我可以將其輸入到 Value Colors 屬性中,我應該能夠得到我需要的東西:
// Start of script;
clear log();
dt = Open( "$SAMPLE_DATA/Big Class.JMP" );
// The Value Colors property of the first column is initially empty;
show(:Name << get property("Value Colors"));
/*
I now want to create a Value Colors property for this column,
but I'd prefer to do it without having to identify all the names
beforehand if possible. Try CWillden's suggestion...
*/
:Name << set property("Value Colors", {});
// If I now try to color the cells by value, it DOES actually seem to have worked;
:Name << color cell by value(1);
// But the Value Colors property STILL only contains an empty list;
show(:Name << get property("Value Colors"));
/*
Unfortunately I do actually need a populated list - and it looks like I can't do it
without extracting the names explicity. Here's one way I think I COULD do it...
*/
summarize(NamesList=by(:Name));
show(NamesList);
/*
I now need to put those names into a list of expressions that follow the syntax
shown in PMRoz's post, and use that list to define the Value Colors property I need.
This next bit is WRONG - but you can see what I'm trying to do here.
What I need inside ExprList is a list of names, each coupled with an integer from 3 onwards
(to get some colors starting at red). I suspect I should probably be using the Substitute
and/or Eval Expr functions at this point, but I can't get the correct syntax.
*/
ExprList = {};
for(i=1, i<=nItems(NamesList), i++,
insert into(ExprList, expr(NamesList[i] = (2+i)))
);
show(ExprList);
// Then insert the resulting expression as the Value Colors property of the :Names column, and I should get what I want.
:Name << set property("Value Colors", ExprList);
// End of script.回复:創建“值顏色”屬性我能夠將 BS 值顏色屬性放入列中,這樣做:
:Column 1 << Set Property("Value Colors",{});似乎應用程序確實應該更新以更強大地工作。奇怪的要求。
回复:創建“值顏色”屬性您可以像這樣使用 JSL:
column(dt, "Column 1") << Set Property( "Value Colors", {2 = 45, 3 = 46, 4 = 47} );
解決這個問題的方法是
1. 創建一個只有一個數字列的小虛擬表
2.手動添加價值顏色屬性
3. 單擊表名旁邊的紅色小三角並選擇複製表腳本
4. 打開 JSL 腳本窗口並粘貼生成的代碼。
它看起來像這樣:
New Table( "Untitled 14",
Add Rows( 3 ),
New Column( "Column 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Property( "Value Colors", {1 = -13977687, 2 = -3780931, 3 = -4222943} ),
Set Selected,
Set Values( [1, 2, 3] )
)
);