Loop-Funktion im Slider-FeldHallo,
Ich möchte eine Referenzlinie zu mehreren Achsenfeldern hinzufügen und die Referenzlinie mit dem Schiebereglerfeld variieren.Ich frage mich, ob eine Schleife verwendet werden kann?
Hier ist mein Code: – Ich konnte jedem Diagramm eine Referenzlinie hinzufügen, aber das Problem, das ich habe, ist, dass die Schleifenfunktionen eine Weile brauchen, um eine Referenzlinie hinzuzufügen, wenn ich das Schiebereglerfeld ändere, und es ist fehlerhaft. Gibt es eine andere alternative Möglichkeit zur Implementierung? Ich würde mich freuen, wenn Sie mir einen Rat geben könnten. Danke
Ich habe beide Datentabellen unten angehängt
dtNames = {};
For( t = 1, t <= N Table(), t++,
Insert Into( dtNames, Data Table( t ) << getName )
);
sliderValue = 1;
dothisonchange = Function( {val},
tb << Set Text( "Cpk : " || Substr( Char( val ), 1, 4 ) )
);<BR />//// Select Measurement data table
nw = New Window( "Select Data Table",
modal,
Panel Box( "Pick a table", dtlb = List Box( dtNames, MaxItems( 1 ) ) ),
Button Box( "OK",
dtl = dtlb << getSelected;
dt = Data Table( dtl[1] );
dt2 = Data Table( "Limits table" );
col = dt2:Analysis Columns << get values;
colist = {};
dt3 = dt2;
cpktab = Data Table( "Limits table" );
Try(
cpktab << delete columns( "LSL" );
cpktab << delete columns( "USL" );
cpktab << Delete Table Variable( "cpk" );
);
cpktab << New Table Variable( "cpk", 1.33 );
cpktab << New Column( "LSL", "Numberic", "Continous", Format( "Best", 12, 2 ), Formula( :Mean - cpk * 3 * :Std Dev ) );
cpktab << New Column( "USL", "Numberic", "Continous", Format( "Best", 12, 2 ), Formula( :Mean + cpk * 3 * :Std Dev ) );
Caption( "Processing...Please Wait" );
Wait( 0 );
New Window( "",
H List Box(
V List Box(
Spacer Box( size( 10, 10 ) ),
Panel Box( "",
Spacer Box( size( 0, 30 ) ),
tb = Text Box( "Cpk: " || Char( sliderValue ), <<SET font="" style=""></SET>//////////////////////////////////// This function lags////////////////////////////////////
For( i = 1, i <= N Items( col ), i++,
If( Contains( lsl, col[i] ),
Report( vc2[i] )[AxisBox( 1 )] << remove ref line( lsl[col[i]] );
Report( vc2[i] )[AxisBox( 1 )] << remove ref line( usl[col[i]] );
Report( vc2[i] )[AxisBox( 1 )] << {Add Ref Line(
lsl[col[i]], "Solid", "Red", "LSL=" || Substr( Char( lsl[col[i]] ), 1, 5 ), 2
)};
Report( vc2[i] )[AxisBox( 1 )] << {Add Ref Line(
usl[col[i]], "Solid", "Red", "New USL=" || Substr( Char( usl[col[i]] ), 1, 5 ), 2
)};
)
);
)
)
)
)
),
vc2 = dt << Variability Chart(
Y( Eval( col ) ),
X( :site ),
Show Range Bars( 0 ),
Show Grand Mean( 1 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Show Box Plots( 1 ),
SendToReport(
Dispatch(
{""},
"Variability Chart",
FrameBox,
{Frame Size( 846, 318 ), Row Legend(
Split,
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
);
aa_refs = Associative Array( dt3:Analysis Columns << get values, dt3:LL << get values );
aa_refs1 = Associative Array( dt3:Analysis Columns << get values, dt3:UL << get values );
For( i = 1, i <= N Items( col ), i++,
If( Contains( aa_refs, col[i] ),
Report( vc2[i] )[Framebox( 1 )] << DispatchSeg( CustomStreamSeg( 3 ), {Line Width( 2 )} );
Report( vc2[i] )[AxisBox( 1 )] << {Add Ref Line(
aa_refs[col[i]], "Solid", "Dark Green", "New LL=" || Substr( Char( aa_refs[col[i]] ), 1, 5 ), 2
)};
Report( vc2[i] )[AxisBox( 1 )] << {Add Ref Line(
aa_refs1[col[i]], "Solid", "Dark Green", "New UL=" || Substr( Char( aa_refs1[col[i]] ), 1, 5 ), 2
)};
)
);
Try( vcidd = vc2 << report );
For( i = 1, i <= N Items( col ), i++,
If( Contains( aa_refs, col[i] ),
vcidd[i][AxisBox( 1 )] << Min( aa_refs[col[i]] - 1 ) << Max( aa_refs1[col[i]] + 1 )
)
);
Caption( remove );
Wait( 0 );
)
);
)
);
Erweiterte statistische ModellierungMassenanpassungQualitäts- und VerfahrenstechnikBetreff: Loop-Funktion im Slider-FeldVielen Dank. Du warst wirklich hilfreich.
Betreff: Loop-Funktion im Slider-FeldIch würde ein Skript wie dieses ganz anders schreiben als das, was Sie getan haben – dies hilft dabei, die Logik (die funktionierenden Funktionen) vom Anzeigebaum zu trennen und das Skript zu verflachen.Es hat außerdem den zusätzlichen Vorteil, dass alle Funktionen leicht aufrufbar und gemeinsam nutzbar sind und nicht direkt an Tastenrückrufe gebunden sind.
Aber um Ihre Hauptfrage zur Verzögerung zu beantworten, bin ich mir ehrlich gesagt nicht sicher.Es war für mich schwierig, dem Ausführungspfad in Ihrem Skript zu folgen, weshalb ich es neu geschrieben habe und beim Neuschreiben kein Verzögerungsproblem auftritt.
Names Default to Here( 1 );
/*
Here I use an anonymous namespace to scope all the variable and functions -- use Eval( Eval Expr( ... Expr( self << Get Name ) ... ) ) where needed to put the reference inside funcitons and other scopes
*/
self = New Namespace();
self:dt Names = {};
For( t = 1, t <= N Table(), t++,
Insert Into( self:dtNames, Data Table( t ) << Get Name )
);
self:slider value = 1;
self:validated = 0;
self:_tables = {};
/*
The Eval( Eval Expr( ... Expr( self << Get Name ) ... ) ) part needs to encompass any functions and windows that the script will have.
This is a bit unfortunate becuase it makes using this block inside rather tricky
*/
Eval( Eval Expr(
/****************************************
Define the functions the script will use
****************************************/
self:add table = Function( {_table},
Insert Into( self:_tables, _table );
_table
);
self:update reference lines = Function( {},
{Default Local},
self = Namespace( Expr( self << Get Name ) );
self:slider value = self:sb << Get;
self:tb << Set Text( "Cpk: " || Char( self:slider value ) );
Try(
old lsl = self:lsl;
old usl = self:usl;
);
self:limits table << Rerun Formulas;
self:lsl = Associative Array( self:limits table:Analysis Columns, self:limits table:LSL );
self:usl = Associative Array( self:limits table:Analysis Columns, self:limits table:USL );
Summation( i = 1, N Items( self:col ),
If( Contains( self:lsl, self:col[i] ),
Try( self:variability report[i][Axis Box( 1 )] << Remove Ref Line( old lsl[self:col[i]] ) << Remove Ref Line( old usl[self:col[i]] ) );
/*
Here I've done a bit of trickery because we're inside an Eval( Eval Expr( ... Expr( self << Get Name ) ... ) ) block.
*/
dispatch = {};
Insert Into( dispatch, Substitute( Eval List( {self:lsl[self:col[i]], "Solid", "Red", "LSL=" || Substr( Char( self:lsl[self:col[i]] ), 1, 5 ), 2} ), As Name( "List" ), As Name( "Add Ref Line" ) ) );
Insert Into( dispatch, Substitute( Eval List( {self:usl[self:col[i]], "Solid", "Red", "New USL=" || Substr( Char( self:usl[self:col[i]] ), 1, 5 ), 2} ), As Name( "List" ), As Name( "Add Ref Line" ) ) );
Eval List( Substitute( {Send( self:variability report[i][Axis Box( 1 )], _dispatch_ )}, As Name( "_dispatch_" ), dispatch ) );
);
0
)
);
self:set limits = Function( {},
{Default Local},
self = Namespace( Expr( self << Get Name ) );
Summation( i = 1, N Items( self:col ),
If( Contains( self:aa_refs, self:col[i] ),
self:variability report[i][Axis Box( 1 )] << Min( self:aa_refs[self:col[i]] - 1 ) << Max( self:aa_refs1[self:col[i]] + 1 );
self:variability report[i][Frame Box( 1 )] << DispatchSeg( CustomStreamSeg( 3 ), {Line Width( 2 )} );
/*
Here I've done a bit of trickery because we're inside an Eval( Eval Expr( ... Expr( self << Get Name ) ... ) ) block
*/
dispatch = {};
Insert Into( dispatch, Substitute( Eval List( {self:aa_refs[self:col[i]], "Solid", "Dark Green", "New LL=" || Substr( Char( self:aa_refs[self:col[i]] ), 1, 5 ), 2} ), As Name( "List" ), As Name( "Add Ref Line" ) ) );
Insert Into( dispatch, Substitute( Eval List( {self:aa_refs1[self:col[i]], "Solid", "Dark Green", "New UL=" || Substr( Char( self:aa_Refs1[self:col[i]] ), 1, 5 ), 2} ), As Name( "List" ), As Name( "Add Ref Line" ) ) );
Eval List( Substitute( {Send( self:variability report[i][Axis Box( 1 )], _dispatch_ )}, As Name( "_dispatch_" ), dispatch ) );
);
0
)
);
/****************************************
Modal input window
****************************************/
New Window( "Select Data Table",
<< Modal
,
<< On Validate(
Local( {self = Namespace( Expr( self ) )},
If( N Items( self:dt list box << Get Selected ),
self:validated = 1;
self:dt = Data Table( (Insert( {}, self:dt list box << Get Selected ))[1] );
1
,
0
)
)
)
,
Panel Box( "Pick a Table", self:dt list box = List Box( self:dt names, Max Selected( 1 ) ) )
);
/****************************************
Quit and delete namespace if not validated
****************************************/
If( Not( self:validated ),
s = Char( "Delete Namespaces( \!"" || (self << Get Name) || "\!", Force( 1 ) )" );
self = .;
Eval( Parse( s ) );
Stop()
);
/****************************************
Some initial setup
****************************************/
self:limits table = self:add table( Data Table( "Limits table" ) << Subset( All Rows, All Columns, Not Linked, Private ) );
self:col = self:limits table:Analysis Columns << Get Values;
self:col as name = {};
Summation( i = 1, N Items( self:col ),
self:col as name[i] = As Name( self:col[i] );
0
);
Try( self:limits table << Delete Columns( "LSL" ) );
Try( self:limits table << Delete Columns( "USL" ) );
Try( self:limits table << Delete Table Variable( "cpk" ) );
self:limits table << New Table Variable( "cpk", 1.33 )
<< New Column( "LSL", "Numeric", "Continuous", Format( "Best", 12, 2 ), <<FORMULA></FORMULA>Betreff: Loop-Funktion im Slider-Feld@gzmorgan0 @jthi irgendein Rat?