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

本节介绍如何动态更改图形生成器中的元素类型,具体取决于用户在列切换器中选择连续还是分类 x 轴变量。 元素是在图形生成器选项板顶部显示为图标的图形类型。 对于连续输入,添加了一个单选按钮,让用户可以在拟合线和轮廓之间进行选择。 当为非 JMP 专家并且只需要有限数量的选项的人创建交互式图表时,此秘诀非常有用。
脚步- 从...开始名称默认为此处(1)并打开大班。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
- 创建一个函数,将消息发送到图形生成器删除现有元素然后添加新元素的平台。 它假设积分元素已显示,并且元素编号为 1,因此要删除的元素为编号 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
)
)
);
- 创建包含列切换器的新窗口( CS ) 更改 x 轴,单选框 ( RB )控制连续变量的元素类型,图形生成器(国标)。
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>
列切换器是特意在图形生成器外部创建的,因此我们可以稍后创建一个函数,以便在切换器更改时采取操作。
- 链接列切换器CS到图形生成器国标
cs << link platform( gb );
- 创建列开关处理程序。 一旦更改完成,处理程序就会调用 post 函数。 该格式直接来自脚本索引。
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 );
请注意,在切换完成之前不需要发生任何事情,因此第一个参数制作列开关处理程序什么也没做。
- 最后,启动列切换器运行以进行演示。
cs << run();
潜在的变化:
- 创建一个“预”更改函数,该函数迭代图形生成器中的现有元素(使用<< 获取元素),找到需要删除的参数并以编程方式设置第三个参数<<删除元素(而不是依赖它作为第二个元素)。
Comments
There are no comments yet