Ich habe ein Skript, das Daten aus Excel abruft und daraus Kontrolldiagramme erstellt. Die Daten entsprechen Messwerten von verschiedenen Standorten und ich möchte die Messwerte von RM 16 und RM 25 im selben Fenster anzeigen, ein JPG des Fensters mit beiden Diagrammen speichern und die einzelnen Diagramme für jeden Standort schließen können. Ich habe herausgefunden, wie man die Kontrolldiagramme kombiniert, kann aber das neue Fenster anscheinend nicht als JPG speichern oder die einzelnen Kontrolldiagramme schließen, da ich diese Dateien nach dem Zusammenführen nicht mehr benötige. Gibt es eine Möglichkeit, dies zu tun? Ich habe das bisherige Skript angehängt. Ich versuche, das Skript so flexibel wie möglich zu halten, für den Fall, dass wir jemals weitere Standorte hinzufügen müssen, von denen Daten verarbeitet werden sollen.
RM = {RM 16, RM 25, Rm.119, Rm.124, Rm 152 153 155};
For(r=1, r<=N Items(RM), r++,
CY = Open("FILEPATH HERE".xlsx",
Worksheets( RM[r] ),
Use for all sheets( 1 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 2 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 3 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
);
//what if CY has no data yet? script will stop unless you delete room from RM
CY << Set Name(char(RM[r]) || " " ||char(Year(Today())));
CY << Select Where(Is Missing(:Date))<<Delete Rows;
CB = Open("FILEPATH HERE".xlsx",
Worksheets( RM[r] ),
Use for all sheets( 1 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 2 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 3 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
);
column(1) << Data Type(Numeric) << Model Type(Continuous) <<Format( "ddMonyyyy", 12 )<<Input Format( "ddMonyyyy" );
CB << Set Name(char(RM[r]) || " " ||char(Year(Today())-1));
CB << Select Where(Is Missing(:Date))<<Delete Rows;
CB << Concatenate(CY, Append to first table);
Close(CY);
CB << Set Name(char(RM[r]) || " " || char(Year(Today())-1)||"-"||char(Year(Today())));
:Room Location # << Data Type(Numeric);
:Room Location # << Set Property ("Row Order Levels", 1);
CB << Sort(Replace table, By(Room Location#), Order(Ascending));
CB << Save("C:\Users\rfeick\Desktop\Air Particle Data\JMP Control Chart Generated Files\"|| char(RM[r]) || " " || char(Year(Today())-1)||"-"||char(Year(Today()))|| ".jmp");
CB << Select Where(:Date >= As Date(Today()-365*86400))<<Invert Row Selection<<Hide and Exclude;
IF(r==1,
C1 = Control Chart Builder(
Size( 1200, 550 ),
Show Two Shewhart Charts( 0 ),
Show Control Panel( 0 ),
Show Capability( 0 ),
Variables(
Y( :Name( "0.5 Micron Particulate (part/m3)" ) ),
Phase(:Room Location #)
),
Chart( Points( Statistic( "Individual" ) ), Limits( Sigma ) ),
SendToReport(
Dispatch(
{},
"Control Chart Builder",
OutlineBox,
{Set Title( "IR Control Chart" )}
),
Dispatch(
{},
"0.5 Micron Particulate (part",
ScaleBox,
{Min( 0 ), Max( 80000 ), Inc( 5000 ), Minor Ticks( 0 ),
Add Ref Line( 62500, "Dashed", "Purple", "125000", 1 ),
Add Ref Line( 352000, "DashDotDot", "Cyan", "352000", 1 )}
),
Dispatch(
{},
"graph display 1 title",
TextEditBox,
{Set Text(
char(RM[r]) ||" 0.5 Micron Particulate (part/m3) "|| char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()]))
)}
)
)
);
Report(C1)[AxisBox(1)] <<Delete;
Report(C1) << Save Picture("FILEPATH HERE\Air Particulate CC " ||char(RM[r]) || " " ||char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()]))|| ".jpg");
);
IF(r==2,
C2 = Control Chart Builder(
Size( 1200, 550 ),
Show Two Shewhart Charts( 0 ),
Show Control Panel( 0 ),
Show Capability( 0 ),
Variables(
Y( :Name( "0.5 Micron Particulate (part/m3)" ) ),
Phase(:Room Location #)
),
Chart( Points( Statistic( "Individual" ) ), Limits( Sigma ) ),
SendToReport(
Dispatch(
{},
"Control Chart Builder",
OutlineBox,
{Set Title( "IR Control Chart" )}
),
Dispatch(
{},
"0.5 Micron Particulate (part",
ScaleBox,
{Min( 0 ), Max( 400000 ), Inc( 50000 ), Minor Ticks( 0 ),
Add Ref Line( 125000, "Dashed", "Purple", "125000", 1 ),
Add Ref Line( 352000, "DashDotDot", "Cyan", "352000", 1 )}
),
Dispatch(
{},
"graph display 1 title",
TextEditBox,
{Set Text(
char(RM[r]) ||" 0.5 Micron Particulate (part/m3) "|| char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()]))
)}
)
)
);
Report(C2)[AxisBox(1)] <<Delete;
Report(C2) << Save Picture("FILEPATH HERE\Air Particulate CC " ||char(RM[r]) || " " ||char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()]))|| ".jpg");
);
If(r==3 | r==4,
C3 = Control Chart Builder(
Size( 1200, 550 ),
Show Two Shewhart Charts( 0 ),
Show Control Panel( 0 ),
Show Capability( 0 ),
Variables(
Y( :Name( "0.5 Micron Particulate (part/m3)" ) ),
Phase(:Room Location #)
),
Chart( Points( Statistic( "Individual" ) ), Limits( Sigma ) ),
SendToReport(
Dispatch(
{},
"Control Chart Builder",
OutlineBox,
{Set Title( "IR Control Chart" )}
),
Dispatch(
{},
"0.5 Micron Particulate (part",
ScaleBox,
{Min( 0 ), Max( 80000 ), Inc( 5000 ), Minor Ticks( 0 ),
Add Ref Line( 62500, "Dashed", "Purple", "125000", 1 ),
Add Ref Line( 352000, "DashDotDot", "Cyan", "352000", 1 )}
),
Dispatch(
{},
"graph display 1 title",
TextEditBox,
{Set Text(
char(RM[r]) ||" 0.5 Micron Particulate (part/m3) "|| char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()]))
)}
)
)
);
Report(C3)[AxisBox(1)] <<Delete;
Report(C3) << Save Picture("FILEPATH HERE\Air Particulate CC " ||char(RM[r]) || " " ||char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()]))|| ".jpg");
);
IF(r==5,
C4 = Control Chart Builder(
Size( 1200, 550 ),
Show Two Shewhart Charts( 0 ),
Show Control Panel( 0 ),
Show Capability( 0 ),
Variables(
Y( :Name( "0.5 Micron Particulate (part/m3)" ) ),
Phase(:Room Location #)
),
Chart( Points( Statistic( "Individual" ) ), Limits( Sigma ) ),
SendToReport(
Dispatch(
{},
"Control Chart Builder",
OutlineBox,
{Set Title( "IR Control Chart" )}
),
Dispatch(
{},
"0.5 Micron Particulate (part",
ScaleBox,
{Min( 0 ), Max( 400000 ), Inc( 50000 ), Minor Ticks( 0 ),
Add Ref Line( 125000, "Dashed", "Purple", "125000", 1 ),
Add Ref Line( 352000, "DashDotDot", "Cyan", "352000", 1 )}
),
Dispatch(
{},
"graph display 1 title",
TextEditBox,
{Set Text(
char(RM[r]) ||" 0.5 Micron Particulate (part/m3) "|| char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()]))
)}
)
)
);
Report(C4)[AxisBox(1)] <<Delete;
Report(C4) << Save Picture("FILEPATH HERE\Air Particulate CC " ||char(RM[r]) || " " ||char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()]))|| ".jpg");
);
);
Together = New Window("RM 16 & RM 25 0.5 Micron Particulate (part/m3) "|| char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()])), V List Box(Report(C1),Report(C2)));
Together << Save Picture("FILEPATH HERE\Air Particulate CC RM 16 & RM 25 0.5 Micron Particulate (part/m3) "||char(As Date(:Date[1]))|| " - " || char(As Date(:Date[NRows()]))|| ".jpg");
C1 <<Close Window;
C2 << Close Window;
Ich habe mir nicht den gesamten Code angesehen, aber es sieht so aus, als könnten Sie die Dinge einfacher machen, indem Sie beim Einlesen der Daten die Option „Arbeitsblätter verketten“ mit „Verkettungsspalte erstellen“ verwenden (um nur eine einzige Tabelle zu erstellen). Dann können Sie die Tatsache ausnutzen, dass Control Chart Builder eine „By“-Variable verwendet. Der folgende Code zeigt die Idee:
dt = Open("$SAMPLE_DATA/Big Class.jmp");
win = NewWindow("Combined Charts",
dt << Control Chart Builder(
Show Control Panel( 0 ),
Show Capability( 0 ),
Variables( Y( :height ) ),
Chart( Position( 1 ), Limits( Sigma( Moving Range ) ) ),
Chart( Position( 2 ), Limits( Sigma( Moving Range ) ) ),
By( :sex )
)
);
win << savePicture("$DESKTOP/My Charts.jpg", JPG);
win << closeWindow;