707228_zh-CN
根据变量建模类型动态更改图形生成器图表类型

本节介绍如何动态更改图形生成器中的元素类型,具体取决于用户在列切换器中选择连续还是分类 x 轴变量。元素是在图形生成器选项板顶部显示为图标的图形类型。对于连续输入,添加了一个单选按钮,让用户可以在拟合线和轮廓之间进行选择。当为非 JMP 专家并且只需要有限数量的选项的人创建交互式图表时,此秘诀非常有用。
脚步- Start with 名称默认为此处(1) and open 大班.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
- Create a function which sends a message to the 图形生成器 platform that removes the existing element then adds a new one. It assumes that the 积分 element is already displayed and is element number 1, therefore the element to be removed is number 2.
// This function changes the type of chart being displayed.
// It takes a reference to a Graph Builder report (gbr) and the chart type required (gr)
// At the moment it assumes the Points element will always be included
changeElement = function( {gbr, gr},
{default local},
Eval(
Substitute(
Expr(
gbr << remove element( 1, 1, 2 ) << add element( 1, 1, {Type( __aa__ ), X, Y} )
), Expr( __aa__ ), gr
)
)
);
- Create the new window which contains the column switcher (CS) to change the x-axis, a radio box (RB) to control the element type for continuous variables, and the Graph Builder (国标).
rb_out = "Line of Fit";
win1 = New Window( "Demo",
Text Box(
"Column switching between continuous and nominal variables will change line of fit to box plots",
<<SET wrap=""></SET>
<P>列切换器是特意在图形生成器外部创建的,因此我们可以稍后创建一个函数,以便在切换器更改时采取操作。</P>
<OL start="6">
<LI>Link the column switcher <FONT face="courier new,courier">CS</FONT> to the Graph Builder <FONT face="courier new,courier">国标</FONT>
<PRE><CODE class=" language-jsl">cs << link platform( gb );
Create a Column Switch Handler. The function post is called by the handler once the change has been completed. The format comes directly from the Scripting Index.
post = Function( {previousColumn, currentColumn, switcher},
gbr = Report( gb )[GraphBuilderBox( 1 )];
If( Column( dt, cs << get current ) << get modeling type == "Continuous",
changeElement( gbr, rb_out ),
changeElement( gbr, "Box Plot" )
);
);
cs << Make Column Switch Handler( 1, post );
请注意,在切换完成之前不需要发生任何事情,因此Make Column Switch Handler的第一个参数不执行任何操作。
Finally, start the column switcher running for demo purposes.
cs << run();
潜在的变化:
- 创建一个“预”更改函数,该函数迭代图形生成器中的现有元素(使用<< Get Elements ),找到需要删除的元素并以编程方式设置<< remove element 中的第三个参数(而不是依赖它)是第二个元素)。
<LINGO-LABS id="lingo-labs-707228" slang="en-US" mode="UPDATE"><LINGO-LABEL>自动化和脚本编写</LINGO-LABEL><LINGO-LABEL>甜点</LINGO-LABEL></LINGO-LABS>
Comments
There are no comments yet