Mise à jour dynamique de 'Color( )' dans Graph Builder avec sélection dans le menu sur le même tableau de bord que les graphiquesBonjour la communauté JMP,
Je travaille avec un complément JMP qui génère une application. Cette application n'a qu'un seul module et crée un tableau de bord avec plusieurs graphiques. Il crée également une zone d'affichage qui est intégrée dans le même tableau de bord et contient la liste des colonnes de la table de données utilisée pour générer les graphiques. Lorsqu'une colonne est sélectionnée dans la liste, l'état de la ligne (la couleur de la ligne, pour être précis) est mis à jour en fonction de cette sélection. Cela se reflète ensuite dans les graphiques qui sont colorés en fonction de l'état de la ligne. Cependant, comme la variable 'Color( )' dans le Graph Builder est toujours vide, la légende des graphiques ne se met pas à jour en fonction des couleurs affichées. Si je fais apparaître la zone d'affichage avec la liste des colonnes comme une fenêtre modale, je peux remplir le champ 'Couleur ( )' en fonction de la sélection avant les graphiques sont générés. Le problème avec cette approche, cependant, est que la fenêtre modale ne peut pas être intégrée au tableau de bord (ou, du moins, je ne sais pas comment), et, plus important encore, elle n'est pas dynamique - vous ne pouvez faire la sélection qu'une seule fois. au début avant que les graphiques ne soient générés, mais ne peut ensuite pas effectuer une autre sélection sans avoir à exécuter à nouveau le complément. J'ai inclus un extrait de mon code. L'objet 'win' est la zone d'affichage qui contient la liste des colonnes et est intégré dans le tableau de bord.
JMP App(
Set Name( "Application" ),
Set Description(
"An empty workspace for creating custom applications with one or more windows and scripts"
),
Auto Launch( 1 ),
Snap To Grid( 1 ),
Show Grid( 1 ),
Show Properties( 1 ),
Show Sources( 1 ),
Group By Category( 1 ),
Dashboard Mode( 0 ),
Parameters,
Tables,/*(
DataTable1 = GuiTable(
Set Path(
"/S:/17 - Contacts - Confidential material/Siemens/2018-08 - Bangkok test/05 - Analysis/All component compilation v6 (with Row column).jmp"
),
Set Label( "All component compilation v5" ),
Set Location( "Current Data Table" ),
Set Invisible( 0 )
)
),*/
Script(JSL Quote(// This script is executed when the application is run.
// Named objects have been created for the application modules
// (for example, "Module1") and the pre-defined object
// "thisApplication" refers to the application object itself.
// Variables and functions declared here are scoped to the
// Application namespace.
)),
Allocate(
Module1 = Plan(
PreAllocate,
Script(JSL Quote(// This script is executed when a new module instance is
// created. The pre-defined object "thisModuleInstance" refers
// to the instance object, but other objects such as boxes and
// scripts have not yet been created. Variables declared here are
// scoped to the ModuleInstance namespace.
// This special function will receive parameters passed to CreateInstance()
OnModuleLoad({});
dt = current data table(); //note that dt has to be defined before the thisModuleInstance' object is created. When defined after and the new "Row" column is added, the code does not recognise the new column and so outputs empty plots. This may be due to the namespaces: maybe the dt has to be in the application namespace and the after thisModuleInstance is created, it is in the module namespace.
If( Is Missing (Is Scriptable( Try ( Column( "Row" )))),
dt << New Column( "Row", Numeric, Values( 1 :: N Row() ), Format( "Best", 12 )));
colnames = dt << get column names;
thisModuleInstance << Create Objects;
// After this point your module instance objects have been created
// and can be referred to by name (for example, "Button1").
show(chosen);
)),
Allocate(
Outline1 = Outline Box();
DataFilterContext1 = Data Filter Context Box();
List1 = H List Box();
List2 = V List Box();
DataFilter1 = dt << Data Filter( Local );
win = Platform(
dt,
H List Box(
Panel Box( "Colour by:",
collist = List Box(
colnames,
max selected( 1 ),
chosen = collist << get selected;
col = column(chosen);
dt << Color or Mark by Column( col ),
)
)
)
);
List3 = V List Box();
List4 = H List Box();
Report1 = Platform(
dt,
Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window( "Maintain Aspect Ratio" ),
Variables( X( :Row ), Y( :Friction ) ),
Elements(
Points( X, Y, Legend( 9 ) ),
Smoother( X, Y, Legend( 10 ) )
),
)
);
Report2 = Platform(
dt,
Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window( "Maintain Aspect Ratio" ),
Variables( X( :Row ), Y( :Velocity ) ),
Elements(
Points( X, Y, Legend( 6 ) ),
Smoother( X, Y, Legend( 7 ) )
)
)
);
J'ai hâte d'entendre vos suggestions.
Merci d'avance à tous!
GraphiqueAutreScriptRe : Mise à jour dynamique de 'Color ( )' dans Graph Builder avec sélection dans le menu sur le même tableau de bord que les graphiques@gzmorgan0 , merci beaucoup pour la réponse rapide.
Votre solution a fonctionné, alors merci pour cela aussi. Je montre dans le code ci-dessous comment j'ai adapté votre solution à mes besoins pour le bénéfice des autres.
JMP App(
Set Name( "Application" ),
Set Description(
"An empty workspace for creating custom applications with one or more windows and scripts"
),
Auto Launch( 1 ),
Snap To Grid( 1 ),
Show Grid( 1 ),
Show Properties( 1 ),
Show Sources( 1 ),
Group By Category( 1 ),
Dashboard Mode( 0 ),
Parameters,
Tables,/*(
DataTable1 = GuiTable(
Set Path(
"/S:/17 - Contacts - Confidential material/Siemens/2018-08 - Bangkok test/05 - Analysis/All component compilation v6 (with Row column).jmp"
),
Set Label( "All component compilation v5" ),
Set Location( "Current Data Table" ),
Set Invisible( 0 )
)
),*/
Script(JSL Quote(// This script is executed when the application is run.
// Named objects have been created for the application modules
// (for example, "Module1") and the pre-defined object
// "thisApplication" refers to the application object itself.
// Variables and functions declared here are scoped to the
// Application namespace.
)),
Allocate(
Module1 = Plan(
PreAllocate,
Script(JSL Quote(// This script is executed when a new module instance is
// created. The pre-defined object "thisModuleInstance" refers
// to the instance object, but other objects such as boxes and
// scripts have not yet been created. Variables declared here are
// scoped to the ModuleInstance namespace.
// This special function will receive parameters passed to CreateInstance()
OnModuleLoad({});
dt = current data table(); //note that dt has to be defined before the thisModuleInstance' object is created. When defined after and the new "Row" column is added, the code does not recognise the new column and so outputs empty plots. This may be due to the namespaces: maybe the dt has to be in the application namespace and the after thisModuleInstance is created, it is in the module namespace.
If( Is Missing (Is Scriptable( Try ( Column( "Row" )))),
dt << New Column( "Row", Numeric, Values( 1 :: N Row() ), Format( "Best", 12 )));
colnames = dt << get column names;
thisModuleInstance << Create Objects;
// After this point your module instance objects have been created
// and can be referred to by name (for example, "Button1").
)),
Allocate(
Outline1 = Outline Box();
DataFilterContext1 = Data Filter Context Box();
List1 = H List Box();
List2 = V List Box();
DataFilter1 = dt << Data Filter( Local );
win = Platform(
dt,
H List Box(
Panel Box( "Colour by:",
collist = List Box(
colnames,
max selected( 1 ),
if( chosen != "",
gbb1 << Remove Variable( {col, Role( "Color" )} );
gbb2 << Remove Variable( {col, Role( "Color" )} );
);
chosen = collist << get selected;
col = column(chosen);
dt << Color or Mark by Column( col );
gbb1 = Report( gb1 )[Graph Builder Box( 1 )];
gbb1 << Add Variable( {col, Role( "Color" )} );
gbb2 = Report( gb2 )[Graph Builder Box( 1 )];
gbb2 << Add Variable( {col, Role( "Color" )} );
)
)
)
);
List3 = V List Box();
List4 = H List Box();
Report1 = Platform(
dt,
gb1 = Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window( "Maintain Aspect Ratio" ),
Variables( X( :Row ), Y( :Friction ) ),
Elements(
Points( X, Y, Legend( 9 ) ),
Smoother( X, Y, Legend( 10 ) )
)
)
);
Report2 = Platform(
dt,
gb2 = Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window( "Maintain Aspect Ratio" ),
Variables( X( :Row ), Y( :Velocity ) ),
Elements(
Points( X, Y, Legend( 6 ) ),
Smoother( X, Y, Legend( 7 ) )
)
)
);Encore une fois, ce qui précède n'est qu'un extrait du code complet. Comme vous pouvez le voir ci-dessus, je dois définir gbb1 et gbb2 à l'intérieur de la plate-forme 'win', qui est exécutée à chaque fois qu'une nouvelle sélection est effectuée. Ce n'est peut-être pas optimal en termes de vitesse, mais il semble que ce soit le seul endroit où ils peuvent être définis si le code doit fonctionner (je ne sais pas pourquoi).
Merci une fois de plus @gzmorgan0 .
Re : Mise à jour dynamique de 'Color ( )' dans Graph Builder avec sélection dans le menu sur le même tableau de bord que les graphiques@A_Zaid ,
Vous avez déclaré
" vous ne pouvez effectuer la sélection qu'une seule fois au début avant la génération des graphiques, mais vous ne pouvez pas effectuer une autre sélection sans avoir à exécuter à nouveau le complément. "
En fait, c'était un errata dans notre livre. Vous pouvez ajouter ou supprimer une variable en envoyant des messages à GraphBuilderBox(). Voir le script ci-dessous.
Vous devrez peut-être ajouter l'interface pour ajouter ou supprimer une variable.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y ), Smoother( X, Y ) )
);
gbb = Report( gb )[Graph Builder Box( 1 )];
Wait( 0.5 );
gbb << Add Variable( {:sex, Role( "Wrap" )} );
wait( 0.5 );
gbb << Add Variable( {:sex, Role( "Color" )} );
wait( 0.5 );
gbb << Remove Variable( {:sex, Role( "Color" )} );
wait( 0.5 );
gbb << Add Variable( {:age, Role( "Color" )} );