文本注释大小和文本位置控制:需要帮助全部,
我需要在图表上添加几个文本注释。
它们都是单行文本,但长度不同。所以我需要使用固定大小(0)来调整标签长度以匹配文本。
但是这样做之后,它还会调整垂直方向的文字大小,把文字放得太高,这让我非常困扰(左图)。如果我设置“固定大小(1)”,就可以直接控制标签的大小,文字位置看起来也还可以(右图),但是我的文字长度不一致,要么标签太长,要么文字超出标签大小时,就会自动调整为“固定大小(0)”,看起来非常难看。


有没有办法调整标签内文本的位置并使用固定大小(0)?
<< Vertical Alignment("bottom") 不起作用。
以下是代码:
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
taHeight = 20;
ta1 = rbiv << Add Text Annotation();
ta2 = rbiv << Add Text Annotation();
ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, 350, 80+taHeight} );
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, 350, 120+taHeight} );
{ta1, ta2} << Background Color( "Light Yellow" ) << Text Color( "red" )/*<
<SET wrap=""></SET>
<BR /> <BR />
<LINGO-LABS id="lingo-labs-913210" slang="en-US" mode="CREATE">
<LINGO-LABEL>自动化和脚本编写</LINGO-LABEL>
</LINGO-LABS>
回复:文本注释大小和文本位置控制:需要帮助我不确定在文本注释中是否可以控制这一点,除非你自己计算文本框的大小。
您能否考虑使用图形脚本?
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
biv = dt << bivariate(y(:weight), x(:height));
rbiv = biv << report;
fb = rbiv[FrameBox(1)];
fb << Add Graphics Script(
Back Color("Light Yellow");
Text Color("Red");
Text(Erased, {50, 150}, "We need to discuss this at the next meeting.");
Text(Erased, {50, 135}, "We need to discuss this at the next");
);
回复:文本注释大小和文本位置控制:需要帮助添加图形脚本的问题在于,文本位置是以图表上的实际坐标指定的。在我的情况下,这个坐标可以是任意值,从 1e-07 到超过 9000 不等 
我可能对编写一个函数来计算我想要的位置值感兴趣,但前提是我能像第一个例子那样给文本添加边框。图表可能比较复杂,我需要将其在视觉上分隔开来,以便快速阅读和处理。
回复:文本注释大小和文本位置控制:需要帮助我有个主意。
如果我先用固定大小(0)绘制文本注释,测量长度,然后将其更改为固定大小(1),并手动设置测量的宽度和所需的高度,会怎么样?
问题是,<< Get Size() 返回了一些错误值:
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
taHeight = 40;
ta1 = rbiv << Add Text Annotation();
ta2 = rbiv << Add Text Annotation();
ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, 350, 80+taHeight} );
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, 350, 120+taHeight} );
{ta1, ta2} << Background Color( "Light Yellow" ) << Text Color( "red" )/*<
<SET wrap=""></SET>
<P>它产生:</P> //:*/
Show(ta1_x, ta2_x);
/*:
ta1_x = 328;
ta2_x = 328;
尽管图表上的标签长度明显不同,但我是不是漏掉了什么?
回复:文本注释大小和文本位置控制:需要帮助尝试使用 < <>
回复:文本注释大小和文本位置控制:需要帮助您也可以尝试在新窗口中使用文本框进行尺寸检查。
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
taHeight = 20;
ta1 = rbiv << Add Text Annotation();
ta2 = rbiv << Add Text Annotation();
nw = new window("", << Window View("Invisible"),
tb1 = Text Box("We need to discuss this at the next meeting."),
tb2 = Text Box("We need to discuss this at the next ")
);
w1 = tb1 << Get Size;
w2 = tb2 << Get Size;
nw << close window;
ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, w1[1]+20+70, 80+taHeight});
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, w2[1]+20+70, 120+taHeight});
{ta1, ta2} << Background Color( "Light Yellow" ) << Text Color( "red" )/*<
<SET wrap=""></SET>
回复:文本注释大小和文本位置控制:需要帮助谢谢你的提示,是的,我现在可以获取和设置标签的大小了。
问题在于 JSL 不是逐行执行,而是分别计算不同属性的最终状态……然后再应用。
喜欢:
...
...
ta1<
<FIXED size=""></FIXED>
<P>所以宽度仍然保持我最初设置的值:</P> <CODE class=" language-jsl">ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, 350, 80+taHeight} );
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, 350, 120+taHeight} );
添加 Wait(0.5) 有助于克服这个问题。
所以最终的剧本是:
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
taHeight = 40;
ta1 = rbiv << Add Text Annotation();
ta2 = rbiv << Add Text Annotation();
ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, 350, 80+taHeight} );
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, 350, 120+taHeight} );
{ta1, ta2} << Background Color( "Light Yellow" ) << Text Color( "red" )<
<FIXED size=""></FIXED> <BR />
回复:文本注释大小和文本位置控制:需要帮助这个方法也行。主观感觉比我的方案还快。我正在尝试用调试工具来测量它的速度。
回复:文本注释大小和文本位置控制:需要帮助设置 Wait(0) 可以加快速度 - 现在不会有实际的等待,但屏幕会重新绘制。
回复:文本注释大小和文本位置控制:需要帮助没关系,它能用。
循环之前:
taList = {};
循环内部:
Insert Into(taList, ta);
循环结束后:
Wait(0);
taList << Fixed Size(1);
For Each({height, index}, taList << Get Height(),
taList[index] << Set Height(height*0.93)
);
现在的问题是,当在实际场景中实现这一点时,当我有多个图表和多个文本注释时,对每个注释执行两级循环的技巧太慢了。
我尝试创建一个文本注释列表:
taList={};
然后在循环内部将当前 ta 添加到列表中:
Insert Into(taList, ta);
循环结束时,我得到:
taList
/*:
{DisplayBox[gtext], DisplayBox[gtext],......}
但是,对该列表或单个成员进行操作不起作用。
有什么想法吗?我的想法是:
1. 尝试使用上下文框来分隔不同任务之间的变量。
2. 想办法从报告中提取这些注释——但是当我提取 XML 时(<