Ciao,
(NOTA sul contesto: sto lavorando su un modello di grafico che automatizza la creazione di grafici per ciascuna etichetta (A, B, C, D ed E) nel set di dati (vedi lo script allegato), quindi per aggiungerlo alla stessa finestra di output per una facile esportazione e condivisione. Qui, sto usando un singolo grafico per l'etichetta "A" come esempio per dimostrare cosa c'è che non va nel mio script. )
Ho riscontrato un problema con il mio script JMP che non leggeva la variabile Group-by selezionata dalla selezione dell'utente nella finestra modale. Voglio che l'utente selezioni un nome di colonna "raggruppa per" dai dati che potrebbero essere qualsiasi variabile di gruppo e abbia una legenda e uno schema di colori come nell'esempio seguente.

Nella tabella dei dati JMP allegata, i dati del mio giocattolo hanno la colonna generica "gruppo". Tuttavia, un utente dovrebbe essere in grado di selezionare qualsiasi variabile di carattere (come sito mfg, batch, processo, formulazione) dalla tabella e avere la legenda di raggruppamento e lo schema di colorazione.
Ecco il mio script JMP:
//select the data in the original data table
Names Default To Here( 1 );
dt = Current Data Table();
/*
2/28/2022 Edit
get column names to
1. get x-axis variable
2. get grouping variable for coloring the dots
- needs to be a none option for when there is no group
- logic statement later if set_groupby is "none", then no
-
Also, ask user what coloring scheme should be used.
JMP auto color (blue and red) or none (if manually coloring by, for example, batch ID)
see source: https://www.jmp.com/support/help/zh-cn/15.2/index.shtml#page/jmp/get-column-names.shtml
*/
column_names = dt << Get Column Names( Numeric, character, String );
//TO DO:
//names_for_groupby_select =
//group by should be a character variable only, so
<FONT color="#FF0000">groupby_col_names = dt << Get Column names(character, String);</FONT>
nw1 = New Window("Set X-axis and group by variable",
<<MODAL>groupby_col = Radio Box(groupby_col_names),
H List Box(
Button Box("OK",
answers = Eval List({set_xlabel = xaxisselect << get selected,
<FONT color="#FF0000">set_groupby = groupby_col << get selected</FONT>
});
nw1 << close window;
),
Button Box("Cancel")),
//change popup window size
<<SIZE window=""> 9, 5);
// generic chart (can be control chart or process chart)
Oneway(
SendToByGroup( {:Name("Label (y-axis)") == label_val},
Y( :Result ),
X( char(set_xlabel) ), //:Name("x axis") ),
Connect Means( 1 ),
Grand Mean( 0 ),
SendToReport(
Dispatch(
{},
"Result",
TextEditBox,
{Set Text( label_val || units_formatted )}
),
//font size:
Dispatch(
{},
"2",
ScaleBox,
{Label Row( Set Font Size( font_size ) )}
),
//graph stuff:
Dispatch(
{},
"Oneway Plot",
FrameBox,
{Frame Size( 1000, 300 ), DispatchSeg(
CustomStreamSeg( 6 ),
{Line Color( "Gray" )}
),
<FONT color="#FF0000">Row Legend(
//group by this
//:Name("Group"), //or just Group works too
char(set_groupby), // << need to be specified by user.
//set_groupby, // TO DO: fix this bug!</FONT>
Color( 1 ),
Color Theme( "JMP default" ), // TO DO: << needs to be specified by user.
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
)
);
);
container << Append(content)
);</SIZE></MODAL>
In questo script JMP, la selezione della colonna dell'asse x funziona (vedi l'esempio della finestra modale e il grafico risultante di seguito), quindi ho ipotizzato che anche il riferimento alla variabile group-by funzioni. Ma l'output produce un grafico che non ha alcuna variabile o legenda raggruppata per. Cosa sta facendo il mio codice in modo errato qui?
Finestra modale:

Grafico di esempio dell'output JMP per l'etichetta "A"

Ho risolto il problema tramite questo post.
Usando Column(listDT,set_groupby) in for char(set_groupby).
Row Legend(
//group by this
Column(listDT,set_groupby),
Color( 1 ),
Color Theme( "JMP default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}Puoi anche usare Eval()
Row Legend(
//group by this
Eval(set_groupby),
Color( 1 ),
Color Theme( "JMP default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}