707228_es-ES
Cambie dinámicamente el tipo de gráfico del Generador de gráficos según el tipo de modelado variable

Esta receta muestra cómo cambiar dinámicamente el tipo de elemento en Graph Builder, dependiendo de si el usuario selecciona una variable de eje x continua o categórica en el conmutador de columnas. Los elementos son los tipos de gráficos que aparecen como iconos en la parte superior de la paleta Graph Builder. Para entradas continuas, se agrega un botón de opción que permite al usuario seleccionar entre Línea de ajuste y Contorno. Esta receta es útil al crear gráficos interactivos para personas que no son expertos en JMP y solo necesitan un número limitado de opciones.
Ingredientes:- Generador de gráficos
- Manejo de expresiones
Tabla de datos de muestra – Clase grande
Dificultad – Difícil
Pasos- Start with Nombres predeterminados aquí (1) and open gran clase.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
- Create a function which sends a message to the Generador de gráficos platform that removes the existing element then adds a new one. It assumes that the Puntos 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 (gb).
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>El conmutador de columnas se crea deliberadamente fuera de Graph Builder para que luego podamos crear una función que actúe cuando cambie el conmutador.</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">gb</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 );
Tenga en cuenta que no es necesario que suceda nada antes de que se complete el cambio, por lo que el primer argumento de Make Column Switch Handler no hace nada.
Finally, start the column switcher running for demo purposes.
cs << run();
Variación potencial:
- Cree una función de cambio "previa" que itere sobre los elementos existentes en Graph Builder (usando << Get Elements ), encuentre el que debe eliminarse y establezca mediante programación el tercer argumento en << remove element (en lugar de depender de él). siendo el segundo elemento).
<LINGO-LABS id="lingo-labs-707228" slang="en-US" mode="UPDATE"><LINGO-LABEL>Automatización y secuencias de comandos</LINGO-LABEL><LINGO-LABEL>Postres</LINGO-LABEL></LINGO-LABS>
Comments
There are no comments yet