Hola a todos,
Recientemente comencé a escribir JSL que resume cierta información en una nueva ventana usando la funcionalidad Table Box() porque quiero que los usuarios puedan seleccionar filas para realizar el siguiente paso de un proceso. A veces, hacer una caja de mesa interactiva puede ser engorroso.También aprendí recientemente que puede tomar una tabla de datos y convertirla en una interfaz similar a un cuadro de tabla interactiva usando el comando Obtener como informe, lo que hace que la construcción de la interfaz sea mucho más fácil y rápida.
Ver por ejemplo este JSL:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Boston Housing.jmp" );
RptWin = New Window( "Data Table as report",
Outline Box("Data Table as Report",
dt_Rpt = dt << Get as Report();
)
);
El único problema que tengo es cómo usar la salida en la nueva ventana como puedo hacerlo con un cuadro de tabla.
En el entorno de Table Box, puede configurar funciones para que devuelva la información que seleccione y que pueda usarse más adelante en el código. Sin embargo, el comando Obtener como informe no le permite hacerlo. Al menos no he encontrado ningún ejemplo de cómo hacerlo, y el Índice de secuencias de comandos no tiene mucho sobre el comando Obtener como informe.
El siguiente código es un ejemplo de cómo construí un cuadro de tabla que tiene una sola fila seleccionable a la vez.
tb = Table Box(
Number Col Box( "PC Number", Eval List( PC_n ) ),
Number Col Box( "Eigenvalue", Eval List( PC_eigv ), <<SET format=""> 1, Throw( "Too many items selected!\!rOnly one selection possible." ),
N Items( SelRows ) == 1,
SelRows = this << Get Selected Rows;
N_PCs = SelRows[1];
);
)
)
)</SET>¿Hay alguna manera de obtener el mismo tipo de funcionalidad cuando se usa la salida Obtener como informe?
¡Gracias por cualquier comentario!,
SD
Hola @ih ,
¡Si perfecto! Eso en realidad tiene mucho sentido, y no sé por qué no pensé en hacer eso.
¡Gracias de nuevo por la rápida solución!,
SD
tu apuesta El gráfico ya está vinculado a la tabla, por lo que creo que si solo agrega las dos filas a continuación a su Función de cambio de fila establecida, debería ver ese comportamiento.
tb << Set Row Change Function(
Function( {this},
{SelRows},
SelRows = this << Get Selected Rows;
If(
N Items( SelRows ) > 1, Throw( "Too many items selected!\!rOnly one selection possible." ),
N Items( SelRows ) == 1,
SelRows = this << Get Selected Rows;
NPCs = SelRows[1];
);
// ** Added next two lines **
dt_results << Clear Select;
dt_results << Select rows(SelRows);
)
);Hola @ih ,
Gracias por la respuesta rápida y la solución, eso es exactamente lo que estoy buscando. Funciona perfectamente. Aquí está el código más grande donde estaba tratando de implementarlo. Sé que este es un tema separado, pero ¿por casualidad sabe cómo puedo vincular la visualización del generador de gráficos en el código a continuación con el cuadro de la tabla Obtener como informe para que cuando el usuario haga clic en la fila del cuadro de la tabla se resalte? el punto de datos correspondiente en el generador de gráficos?Por cierto, solo estoy usando Boston Housing como un conjunto de datos de muestra con mvalue como respuesta y todas las demás columnas como predictores en la partición, y estoy usando una porción de validación de 0.3.
¡Gracias!,
SD
Names Default To Here( 1 );
lbWidth = 168;
dt = Open( "$SAMPLE_DATA/Boston Housing.jmp" );
// Expression to store the current settings in global variables
recallRolesS1 = Expr(
::dtchosenRecall = dtchosen
);
// Expression to clear all current settings. KW: Clear
clearRoles = Expr(
Try(
colListY << RemoveAll;
ColListX << RemoveAll;
ColListW << RemoveAll;
ColListF << RemoveAll;
colListV << RemoveAll;
)
);
// Expression to store the current settings in global variables
recallRoles = Expr(
::ycolRecall = colListY << GetItems;
::xcolRecall = colListX << GetItems;
::WcolRecall = colListW << GetItems;
::FcolRecall = colListF << GetItems;
::vcolRecall = colListV << GetItems;
::max_spRecall = max_sp_input << get;
::partVPRecall = partVP_input << Get;
);
//Function to choose the data table to model. KW: choose_data
choose_data_table = Function( {},
list = {};
For( i = 1, i <= N Table(), i++,
list[i] = Data Table( i ) << get name
);
win = New Window( "Select a data table",
<<MODAL> 1, Throw( "Too many items selected!\!rOnly one selection possible." ),
N Items( SelRows ) == 1,
SelRows = this << Get Selected Rows;
NPCs = SelRows[1];
);
)
);
);
Part = Expr(
If(
N Items( vcols ) == 1,
dt_results = New Table( "Partition_Results",
Add Rows( max_sp ),
New Column( "Splits", Numeric, Continuous ),
New Column( "Training RSquare", Numeric, Continuous ),
New Column( "Validation RSquare", Numeric, Continuous ),
New Column( "Training RASE", Numeric, Continuous ),
New Column( "Validation RASE", Numeric, Continuous ),
New Column( "Training N", Numeric, Continuous ),
New Column( "Validation N", Numeric, Continuous ),
New Column( "RSquare Diff", Numeric, Continuous, Formula( "Training RSquare"n - "Validation RSquare"n ) ),
New Column( "Penalized Valid RSquare", Numeric, Continuous, Formula( "Training RSquare"n - 0.05 * "Splits"n ) )
),
N Items( vcols ) == 0 & Is Missing( partVP ) == 0,
dt_results = New Table( "Partition_Results",
Add Rows( max_sp ),
New Column( "Splits", Numeric, Continuous ),
New Column( "Training RSquare", Numeric, Continuous ),
New Column( "Validation RSquare", Numeric, Continuous ),
New Column( "Training RASE", Numeric, Continuous ),
New Column( "Validation RASE", Numeric, Continuous ),
New Column( "Training N", Numeric, Continuous ),
New Column( "Validation N", Numeric, Continuous ),
New Column( "RSquare Diff", Numeric, Continuous, Formula( "Training RSquare"n - "Validation RSquare"n ) ),
New Column( "Penalized Valid RSquare", Numeric, Continuous, Formula( "Validation RSquare"n - 0.05 * "Splits"n ) )
),
N Items( vcols ) == 0,
dt_results = New Table( "Partition_Results",
Add Rows( max_sp ),
New Column( "Splits", Numeric, Continuous ),
New Column( "Training RSquare", Numeric, Continuous ),
New Column( "Training RASE", Numeric, Continuous ),
New Column( "Training N", Numeric, Continuous ),
New Column( "Penalized Train RSquare", Numeric, Continuous, Formula( "Training RSquare"n - 0.05 * "Splits"n ) )
)
);
For( i = 1, i <= max_sp, i++,
dt_results:"Splits"n[i] = i
);
dt_name = dtchosen << Get Name;
For( i = 1, i <= N Rows( dt_results ), i++,
Psplit = dt_results:"Splits"n[i];
str = Eval Insert(
"report = (dtchosen<<PARTITION></PARTITION></MODAL>Creo que sí, solo necesita ir un nivel más abajo en la referencia de referencia devuelta por la función Obtener informe () para llegar a la tabla.Prueba esto:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Boston Housing.jmp" );
RptWin = New Window( "Data Table as report",
Outline Box("Data Table as Report",
dt_Rpt = dt << Get as Report();
)
);
tb = dt_Rpt[Table Box( 1 )];
tb << Set Shade Headings( 1 );
tb << Append(
Plot Col Box( "",
:mvalue << get values,
<<SET scale=""> 1, Throw( "Too many items selected!\!rOnly one selection possible." ),
N Items( SelRows ) == 1,
SelRows = this << Get Selected Rows;
N_PCs = SelRows[1];
);
)
);</SET>