Dynamische Aktualisierung von „Color( )“ im Graph Builder mit Auswahl aus dem Menü auf demselben Dashboard wie die GraphenHallo JMP-Community,
Ich arbeite mit einem JMP-Add-In, das eine Anwendung generiert. Diese Anwendung hat nur ein Modul und erstellt ein Dashboard mit mehreren Grafiken. Außerdem wird ein Anzeigefeld erstellt, das in dasselbe Dashboard eingebettet ist und die Liste der Spalten in der Datentabelle enthält, die zum Generieren der Diagramme verwendet wird. Wenn eine Spalte aus der Liste ausgewählt wird, wird der Zeilenstatus (genauer gesagt die Zeilenfarbe) gemäß dieser Auswahl aktualisiert. Dies spiegelt sich dann in den Diagrammen wider, die entsprechend dem Zeilenstatus eingefärbt sind. Da die Variable 'Color()' im Graph Builder jedoch noch leer ist, wird die Legende der Graphen nicht entsprechend der angezeigten Farben aktualisiert. Wenn ich das Anzeigefeld mit der Spaltenliste als modales Fenster anzeigen lasse, kann ich das Feld „Farbe ()“ basierend auf der Auswahl füllen Vor Die Grafiken werden erstellt. Das Problem bei diesem Ansatz ist jedoch, dass das modale Fenster nicht in das Dashboard eingebettet werden kann (oder zumindest weiß ich nicht wie), und, was noch wichtiger ist, es ist nicht dynamisch – Sie können die Auswahl nur einmal treffen zu Beginn, bevor die Diagramme generiert werden, kann dann aber keine weitere Auswahl treffen, ohne das Add-In erneut ausführen zu müssen. Ich habe einen Auszug aus meinem Code eingefügt. Das „Win“-Objekt ist das Anzeigefeld, das die Spaltenliste enthält und in das Dashboard eingebettet ist.
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 ) )
)
)
);
Ich freue mich auf Ihre Anregungen.
Vielen Dank an alle im Voraus!
GrafikAndereSkripterstellungBetreff: Dynamische Aktualisierung von „Color( )“ im Graph Builder mit Auswahl aus dem Menü auf demselben Dashboard wie die Graphen@gzmorgan0 , vielen Dank für die prompte Antwort.
Ihre Lösung hat funktioniert, also danke auch dafür. Im folgenden Code zeige ich, wie ich Ihre Lösung an meine Bedürfnisse zum Nutzen anderer angepasst habe.
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 ) )
)
)
);Auch hier ist das Obige nur ein Auszug aus dem vollständigen Code. Wie Sie oben sehen können, muss ich gbb1 und gbb2 innerhalb der 'win'-Plattform definieren, die jedes Mal ausgeführt wird, wenn eine neue Auswahl getroffen wird. Dies ist möglicherweise nicht optimal in Bezug auf die Geschwindigkeit, aber es scheint der einzige Ort zu sein, an dem sie definiert werden können, wenn der Code funktionieren soll (ich bin mir nicht sicher, warum).
Vielen Dank noch mal @gzmorgan0 .
Betreff: Dynamische Aktualisierung von „Color( )“ im Graph Builder mit Auswahl aus dem Menü auf demselben Dashboard wie die Graphen@A_Zaid ,
Du hast gesagt
" Sie können die Auswahl nur einmal zu Beginn vornehmen, bevor die Diagramme generiert werden, aber dann keine weitere Auswahl treffen, ohne das Add-In erneut ausführen zu müssen. "
Eigentlich war das eine Errata in unserem Buch. Sie können eine Variable hinzufügen oder entfernen, indem Sie Nachrichten an die GraphBuilderBox() senden. Siehe das Skript unten.
Möglicherweise müssen Sie die Schnittstelle hinzufügen, um eine Variable hinzuzufügen oder zu entfernen.
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" )} );