Schritte- Start with Namen standardmäßig hier(1) and open Große Klasse.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
- Create a function which sends a message to the Graph Builder platform that removes the existing element then adds a new one. It assumes that the Punkte element is already displayed and is element number 1, therefore the element to be removed is number 2.
// This function changes the type of chart being displayed.
// It takes a reference to a Graph Builder report (gbr) and the chart type required (gr)
// At the moment it assumes the Points element will always be included
changeElement = function( {gbr, gr},
{default local},
Eval(
Substitute(
Expr(
gbr << remove element( 1, 1, 2 ) << add element( 1, 1, {Type( __aa__ ), X, Y} )
), Expr( __aa__ ), gr
)
)
);
- Create the new window which contains the column switcher (cs) to change the x-axis, a radio box (rb) to control the element type for continuous variables, and the Graph Builder (GB).
rb_out = "Line of Fit";
win1 = New Window( "Demo",
Text Box(
"Column switching between continuous and nominal variables will change line of fit to box plots",
<<SET wrap=""></SET>
<P>Der Spaltenumschalter wird bewusst außerhalb des Graph Builder erstellt, damit wir später eine Funktion erstellen können, die Maßnahmen ergreift, wenn sich der Umschalter ändert.</P>
<OL start="6">
<LI>Link the column switcher <FONT face="courier new,courier">cs</FONT> to the Graph Builder <FONT face="courier new,courier">GB</FONT>
<PRE><CODE class=" language-jsl">cs << link platform( gb );
Create a Column Switch Handler. The function post is called by the handler once the change has been completed. The format comes directly from the Scripting Index.
post = Function( {previousColumn, currentColumn, switcher},
gbr = Report( gb )[GraphBuilderBox( 1 )];
If( Column( dt, cs << get current ) << get modeling type == "Continuous",
changeElement( gbr, rb_out ),
changeElement( gbr, "Box Plot" )
);
);
cs << Make Column Switch Handler( 1, post );
Beachten Sie, dass nichts passieren muss, bevor der Wechsel abgeschlossen ist, sodass das erste Argument von Make Column Switch Handler nichts bewirkt.
Finally, start the column switcher running for demo purposes.
cs << run();
Mögliche Variation:
- Erstellen Sie eine „Vor“-Änderungsfunktion, die die vorhandenen Elemente im Graph Builder durchläuft (mithilfe von << Get Elements ), das Element findet, das entfernt werden muss, und das dritte Argument programmgesteuert in << Remove Element festlegt (anstatt sich darauf zu verlassen). ist das zweite Element).