Ciao a tutti,
Di recente ho iniziato a scrivere JSL che riassume alcune informazioni in una nuova finestra utilizzando la funzionalità Table Box() perché voglio che gli utenti siano in grado di selezionare le righe per eseguire il passaggio successivo di un processo. A volte creare una scatola da tavolo interattiva può essere ingombrante.Di recente ho anche appreso che puoi prendere una tabella di dati e trasformarla in un'interfaccia simile a una tabella interattiva utilizzando il comando Ottieni come report, che rende la creazione dell'interfaccia molto più semplice e veloce.
Vedi ad esempio questo 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();
)
);
L'unico problema che sto riscontrando è come utilizzare l'output nella nuova finestra come posso fare con un Table Box.
Nell'ambiente Table Box, puoi impostare le funzioni in modo che restituiscano le informazioni all'interno che selezioni e che possono essere utilizzate più in basso nel codice. Tuttavia, il comando Ottieni come report non ti consente di farlo. Almeno non ho trovato alcun esempio su come farlo e lo Scripting Index non ha molto sul comando Ottieni come report.
Il codice seguente è un esempio di come ho creato una casella di tabella che ha una singola riga selezionabile alla volta.
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>C'è un modo per ottenere lo stesso tipo di funzionalità quando si utilizza l'output del rapporto Ottieni come?
Grazie per qualsiasi feedback!,
DS
Penso di sì, devi solo scendere di un livello più in basso nel riferimento di riferimento restituito dalla funzione Get are Report() per arrivare alla tabella.Prova questo:
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>Ciao @ih ,
Grazie per la risposta rapida e la soluzione: è esattamente quello che sto cercando. Funziona perfettamente. Ecco il pezzo di codice più grande in cui stavo cercando di implementarlo. So che questo è un argomento separato, ma per caso sai come posso collegare la visualizzazione del generatore di grafici nel codice sottostante con la casella della tabella Ottieni come report in modo che quando l'utente fa clic sulla riga nella casella della tabella si evidenzia il punto dati corrispondente nel generatore di grafici?A proposito, sto solo usando Boston Housing come set di dati di esempio con mvalue come risposta e tutte le altre colonne come predittori nella partizione - e sto usando una porzione di convalida di 0.3.
Grazie!,
DS
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>Scommetti. Il grafico è già legato alla tabella, quindi penso che se aggiungi semplicemente le due righe sottostanti alla funzione Imposta modifica riga dovresti vedere quel comportamento.
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);
)
);Ciao @ih ,
Si perfetto! In realtà ha perfettamente senso, e non so perché non ho pensato di farlo.
Grazie ancora per la rapida soluzione!,
ds