[图表构建器] 批量固定所选行的悬停标签各位,
目前我使用 JMP16 来创建图表。
我有一列图片,我想将图片固定在我选择的每个点上,所以我打开了该列的“添加标签”功能。
但我发现我只能将鼠标指针悬停在圆点上,等待悬停标签显示出来,然后点击图钉按钮才能逐个固定它。
有没有更快捷的方法,比如用JSL代码?我有上百万行数据需要显示图片。
谢谢!
自动化和脚本编写回复:[图表构建器] 批量固定所选行的悬停标签必须使用悬停标签吗?或者可以直接在图表中使用图片作为符号?例如,使用“大类家庭”示例数据集:

如果您只想为选定的行添加图片,可以选中这些行,并将“选定列”命名为“选定列”,然后使用该列创建一个“转换列”,如下所示:
// Open Data Table: Big Class Families.jmp
// → Data Table( "Big Class Families" )
Open( "$SAMPLE_DATA/Big Class Families.jmp" );
// Name selection in column: Use Images
Data Table( "Big Class Families" ) << Clear Select <<
Select Rows( [1, 6, 14, 15, 16] ) <<
Name Selection in Column( Column Name( "Use Images" ), Selected( 1 ) );
Graph Builder(
Transform Column( "Transform[height]", Formula( :height * :Use Images ) ),
Size( 648, 551 ),
Show Control Panel( 0 ),
Variables(
X( :weight ),
Y( :height ),
Y( :"Transform[height]"n, Position( 1 ) )
),
Elements(
Points( X, Y( 1 ), Y( 2 ), Legend( 3 ) ),
Points( X, Y( 2 ), Legend( 5 ), Set Shape Column( :picture ) )
)
);
我附上了脚本,方便您一键查看结果,但其实所有操作都可以在图表构建器中完成,无需编写脚本。主要功能包括“转换列”和“设置列形状” 。
回复:[图表构建器] 批量固定所选行的悬停标签这里有一个固定悬停标签的示例。值得注意的是,选择操作是从零开始索引的。可能需要修改代码以处理未选择任何行的情况。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
dt << Select Rows( [1 5 7] );
pin_expr = {};
For Each( {v, i}, dt << Get Selected Rows,
Insert Into(
pin_expr,
Eval(
Eval Expr(
{Add Pin Annotation(
Seg( Marker Seg( 1 ) ),
Index( Expr( v - 1 ) ),
Index Row( Expr( v - 1 ) ),
UniqueID( Expr( v - 1 ) )
)}
)
)
)
);
Eval(
Substitute(
Expr(
dt << Graph Builder(
Size( 658, 556 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
SendToReport( Dispatch( {}, "Graph Builder", FrameBox, __pin_expr__ ) )
)
),
Expr( __pin_expr__ ), Name Expr( pin_expr )
)
);

回复:[图表构建器] 批量固定所选行的悬停标签谢谢回复!使用“设置形状列”功能效果很好,但如果也能显示点就更好了。这确实是一个很方便的方法!
回复:[图表构建器] 批量固定所选行的悬停标签
For Each( {v, i}, row_selection,
local_x = Column( dt, col_x )[v];
local_y = Column( dt, col_y )[v];
Insert Into(
pin_expr,
Eval(
Eval Expr(
{Add Pin Annotation(
Seg( Marker Seg( 1 ) ),
Index( Expr( v - 1 ) ),
Origin( {Expr( local_x ), Expr( local_y )} ),
Index Row( Expr( v - 1 ) ),
UniqueID( Expr( v - 1 ) ),
Offset( {-50, -45} ),
Replace Text( " " ),
Filled( 0 ),
Tag Line( 1 )
)}
)
)
);
);
太好了!它确实有效,但是所有注释都被固定在同一个位置,没有设置原点。为了解决这个问题,我读取了 x/y 轴的值并将它们赋值给原点。虽然这在数值轴上完美运行,但传递字符列值会导致应用程序崩溃。有没有针对字符列的解决方法?谢谢!
回复:[图表构建器] 批量固定所选行的悬停标签对于名义/序数列,坐标轴从 0 开始,每个值递增 1。您可以在坐标轴设置中验证这一点。

您可以根据数据表编写逻辑来处理这个问题;或者,如果您绘制的是点图,则可以从标记点获取值。
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(Variables(X(:age), Y(:height)), Elements(Points(X, Y, Legend(3))));
ms = report(gb)[framebox(1)] << find seg(markerseg(1));
Show(ms << Get X Values, ms << Get Y Values);
回复:[图表构建器] 批量固定所选行的悬停标签谢谢!它似乎返回了所有 X/Y 值,但我该如何读取选定行的 X/Y 值呢?我尝试了下面的代码,但返回的 X/Y 值与我选择的位置不符。
r = dt << Get Selected Rows();
ms = Report(gb)[framebox(1)] << Find Seg( Marker Seg( 1 ) );
For Each( {v, i}, r,
t = ms << Get Point( v );
x = t[1];
y = t[2];
show(x,y);
);
回复:[图表构建器] 批量固定所选行的悬停标签对我来说,这似乎返回了正确的值。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(Variables(X(:age), Y(:height)), Elements(Points(X, Y, Legend(3))));
dt << Select Rows([1, 10, 16, 20, 30]);
ms = Report(gb)[framebox(1)] << Find Seg(Marker Seg(1));
selrows = dt << Get Selected Rows();
For Each({currow}, selrows,
coord = ms << Get Point(currow);
Show(coord);
);

coord = {0, 59};
coord = {1, 61};
coord = {1, 65};
coord = {1, 63};
coord = {2, 61};
coord = {2, 62};
coord = {3, 67};
回复:[图表构建器] 批量固定所选行的悬停标签哦,我现在明白问题所在了:隐藏或排除行会导致剩余数据的索引不匹配。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(Variables(X(:age), Y(:height)), Elements(Points(X, Y, Legend(3))));
dt << Select Rows([1, 10, 16, 20, 30]);
ms = Report(gb)[framebox(1)] << Find Seg(Marker Seg(1));
selrows = dt << Get Selected Rows();
pin_expr = {};
For Each({v}, selrows,
coord = ms << Get Point(v);
Show(coord);
Insert Into(
pin_expr,
Eval(
Eval Expr(
{Add Pin Annotation(
Seg( Marker Seg( 1 ) ),
Index Row( Expr( v - 1 ) ),
Origin( Expr(coord)),
UniqueID( Expr( v - 1 ) )
)}
)
)
)
);
Eval(
Substitute(
Expr( Report(gb)[framebox(1)] << __pin_expr__ ),
Expr( __pin_expr__ ), Name Expr( pin_expr )
)
);
使用此代码,当第 17 行被隐藏/排除时,会导致第 20/30 行的注释移到错误的位置。
有什么办法可以避免这种情况发生吗?我的意思是,我肯定有一些数据点需要排除在外。
回复:[图表构建器] 批量固定所选行的悬停标签成功了,谢谢各位!
ex = dt << Get Excluded Rows;
pin_expr = {};
For Each( {v}, dt << Get Selected Rows,
offset = N Rows(Loc(ex < v));
coord = ms << Get Point(v - offset);
回复:[图表构建器] 批量固定所选行的悬停标签我会从 selrows 中删除已排除的行。
selrows = dt << Get Rows Where(Selected() & !Excluded())
回复:[图表构建器] 批量固定所选行的悬停标签如果图表构建器具有本地数据过滤器,则索引不匹配,这是个坏消息。
有没有办法处理启用了局部过滤器的图?
回复:[图表构建器] 批量固定所选行的悬停标签您可以通过发送消息来获取本地数据筛选器将显示的行。
<< Get Filtered Rows;
本地数据过滤器
回复:[图表构建器] 批量固定所选行的悬停标签谢谢你的帮助!我快完成了!
顺便问一下,有没有办法批量删除脚本添加的注释?
gb << SendToReport( Dispatch( {}, "Graph Builder", FrameBox(__which__), __pin_expr__ ) )
回复:[图表构建器] 批量固定所选行的悬停标签如果你能获取到所有这些引用,我认为你可以设置“关闭”或“删除”消息到列表中,以便同时删除它们。你可能还需要在删除前使用“无效”消息,并在删除后使用“更新窗口”消息。
回复:[图表构建器] 批量固定所选行的悬停标签我的代码是为通过 gb = (Current Report() << Find( "Graph Builder" )) << Get Scriptable Object 获取的现有图形构建器设计的;
然后我按照 mmarchandFSLR 的方法创建了一个 Eval 循环:
我似乎只能访问到 GB 本身,但无法从下面的代码中定义“添加引脚注释”列表:
有没有办法读取每个对象的唯一 ID 或其他信息,然后将其赋值为 << 删除?
pin_expr = {};
For Each( {v, i}, dt << Get Selected Rows,
Insert Into(
pin_expr,
Eval(
Eval Expr(
{Add Pin Annotation(
Seg( Marker Seg( 1 ) ),
Index( Expr( v - 1 ) ),
Index Row( Expr( v - 1 ) ),
UniqueID( Expr( v - 1 ) )
)}
)
)
)
);
.....
If( N Items( pin_expr ) > 0,
Eval(
Substitute(
Expr(
gb << SendToReport( Dispatch( {}, "Graph Builder", FrameBox(__which__), __pin_expr__ ) )
),
Expr( __pin_expr__ ), Name Expr( pin_expr ),
)
)
);
回复:[图表构建器] 批量固定所选行的悬停标签Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
dt << select rows([1, 10, 21, 30, 40]);
gb = dt << Graph Builder(
Size(658, 556),
Show Control Panel(0),
Variables(X(:age), Y(:height)),
Elements(Points(X, Y, Legend(3)))
);
pins = {};
gb << inval;
frame = Report(gb)[FrameBox(1)];
For Each({currow}, dt << Get Selected Rows,
Eval(EvalExpr(
Insert Into(pins, frame << Add Pin Annotation(
Seg(Marker Seg(1)),
Index(Expr(currow - 1)),
Index Row(Expr(currow - 1)),
UniqueID(Expr(currow - 1))
));
));
);
gb << update window;
wait(1); // demo purposes
pins << Delete;
回复:[图表构建器] 批量固定所选行的悬停标签哦,我现在明白问题所在了:隐藏或排除行会导致剩余数据的索引不匹配。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(Variables(X(:age), Y(:height)), Elements(Points(X, Y, Legend(3))));
dt << Select Rows([1, 10, 16, 20, 30]);
ms = Report(gb)[framebox(1)] << Find Seg(Marker Seg(1));
selrows = dt << Get Selected Rows();
pin_expr = {};
For Each({v}, selrows,
coord = ms << Get Point(v);
Show(coord);
Insert Into(
pin_expr,
Eval(
Eval Expr(
{Add Pin Annotation(
Seg( Marker Seg( 1 ) ),
Index Row( Expr( v - 1 ) ),
Origin( Expr(coord)),
UniqueID( Expr( v - 1 ) )
)}
)
)
)
);
Eval(
Substitute(
Expr( Report(gb)[framebox(1)] << __pin_expr__ ),
Expr( __pin_expr__ ), Name Expr( pin_expr )
)
);
使用此代码,当第 17 行被隐藏/排除时,会导致第 20/30 行的注释移到错误的位置。
有什么办法可以避免这种情况发生吗?我的意思是,我肯定有一些数据点需要排除在外。
回复:[图表构建器] 批量固定所选行的悬停标签谢谢jthi!非常感谢!
回复:[图表构建器] 批量固定所选行的悬停标签@jthi不好意思,请问有没有类似当前报告/当前数据表之类的示例方法来获取用户当前选择的帧?
我仅在图表添加了脚本的情况下才使用此方法。
For Each( {f, n}, frames,
Eval( Eval Expr( f << AddGraphicsScript( Handle( ::currentFrame = Expr( f ) ) ) ) )
);
回复:[图表构建器] 批量固定所选行的悬停标签您可以使用 XPath 查找选定的属性(值为 true)。
Names Default To Here(1);
//This message applies to all display box objects
dt = Open("$SAMPLE_DATA/Big Class.jmp");
biv = dt << Run Script("Bivariate");
Report(biv)[FrameBox(1)] << Select(1);
report(biv) << XPath("//FrameBox[@selected='true']");
回复:[图表构建器] 批量固定所选行的悬停标签谢谢!我需要将图框显示在鼠标光标下方(无论是悬停还是点击)。我考虑过使用 S + 单击进行选择,但有没有更简单的方法呢?
回复:[图表构建器] 批量固定所选行的悬停标签在 JMP 中实现这些操作要困难得多,因为(大多数情况下)很难获取光标位置,即使可以获取,也仍然需要计算哪个帧位于坐标下方。虽然可以获取点击事件,但必须先为每个帧框添加图形脚本(图形脚本会在鼠标点击/悬停/按住并拖动等情况下触发)。根据脚本的具体功能,可能还有其他方法,例如,您可以向用户提供帧框列表,让他们选择要添加图形脚本的帧框,然后提示用户点击“确定”。