创建“值颜色”属性如何编写为数据表列创建一组值颜色的脚本,而不必指定它们实际是什么?
我问是因为我有一个应用程序希望找到与选定列关联的“值颜色”属性,如果该属性不存在,它将崩溃。 我不想自己定义实际颜色,因为它们无关紧要:我只需要在那里是值颜色属性。
只需右键单击相关列,然后从属性列表中选择“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] )
)
);