如何在數據更新時凍結控製圖顯示你好,
我有一個讀取 csv 文件並執行控製圖的腳本。 我喜歡自動化此過程,以便更新新數據,控製圖不會生成新圖表。 我喜歡只在圖表上看到更新的數據。
這是我使用的腳本。 我感謝您的幫助。 謝謝
------------------
名稱默認為此處( 1 );
dt =打開(
“/Users/adatorab/Documents/JMP/PASS.csv” ,無形的);
對象 = dt <<
控製圖生成器(
變量(Y(:A)),
圖表(
位置( 1 ),
積分(
統計(
“個人”
)
),
限制(
西格瑪(
“移動範圍”
)
)
),
圖表(
位置( 2 ),
積分(
統計(
“移動範圍”
)
),
限制(
西格瑪(
“移動範圍”
)
)
)
);
對象<<櫥窗展示( 0 );
西北=新窗戶( 《控製圖》 );
西北 <<附加(( H 列錶框((對象<<報告) <<克隆盒)));
回复:數據更新時如何凍結控製圖顯示非常感謝你的幫助。
回复:數據更新時如何凍結控製圖顯示我將布萊恩的控製圖代碼複製到你的控製圖代碼中,添加了隨機的“分鐘”時間,這是我看到的:
//Open a window to show a control chart and then update
//the chart every 15 seconds
//Includes a button to refresh early.
Names Default To Here( 1 );
//Define variables here that need to keep their values through subsequent function calls
//This includes the window and data table
//Open a window to hold the chart (note this only happens once)
nw = New Window( "Control Chart",
V List Box(
Button Box( "New Data", UpdateData() ),
holder = H List Box();
)
);
//Make a variable to hold a reference to the data table
dt = .;
//A function that will update the chart
UpdateData = Function( {},
//Close the table if it is already open
Try( dt << Close Window );
//Open data table
dt = Open( "$SAMPLE_DATA/Abrasion.jmp", Private );
//Make the control chart
obj = dt << Control Chart(
Group Size( 1 ),
KSigma( 3 ),
Chart Col( :Abrasion, Individual Measurement ),
SendToReport(
Dispatch(
{"Individual Measurement of Abrasion"},
"1",
ScaleBox,
{Min( nrows() - Floor( Random Uniform( 10, 25 ) ) ), Max( nrows() + 2 ), Inc( 5 ),
Minor Ticks( 1 )}
)
)
);
//Hide the temporary control chart window
obj << ShowWindow( 0 );
//Remove existing/old graph from the window (if there is one)
Try( (holder << Child) << Delete );
//Add the new graph
holder << Append( (H List Box( (obj << Report) << Clone Box )) );
//Close the temporary control chart
obj << Close Window;
);
//Script to update then chart and then call itself 15 seconds later
quickieScript = Expr(
//Load the chart in the window (run the script in the function)
UpdateData();
//Run this same script in 5 seconds
Schedule( 5, quickieScript );
);
//Start things off:
quickieScript;回复:數據更新時如何凍結控製圖顯示看起來您已經有了一份控製圖生成器報告。 經典控製圖的工作方式略有不同。 (更輕鬆)
回复:數據更新時如何凍結控製圖顯示謝謝。 我嘗試了這個,沒有收到錯誤,但我沒有看到 x 軸只有二十點。
你能進一步提供幫助嗎? 我非常感激。
//打開一個窗口顯示控製圖然後更新
//圖表每15秒一次
//包括一個提前刷新的按鈕。
名稱默認為此處( 1 );
//這裡定義需要在後續函數調用中保留其值的變量
//這包括窗口和數據表
//打開一個窗口來保存圖表(注意這只發生一次)
西北=新窗戶( 《控製圖》 ,
V 列錶框(
按鈕盒( “新數據” , 更新數據() ),
持有者= H 列錶框();
)
);
//創建一個變量來保存對數據表的引用
dt = 。 ;
//更新圖表的函數
更新數據=功能({},
//如果表已經打開則關閉表
嘗試( dt <<關閉窗口);
//打開數據表
dt =打開( “$SAMPLE_DATA/磨損.jmp” , 私人的 );
//製作控製圖
對象 = dt <<控製圖生成器(
顯示兩個休哈特圖表( 0 ),
顯示控制面板( 0 ),
展示能力( 0 ),
變量(Y(:磨損)),
圖表(
積分( 統計( “個人” ) ),
限制(西格瑪(移動極差)),
//警告(測試1(1))
發送至報告(
派遣(
{ “磨損的單獨測量” },
“1” ,
秤盒,
{最小(行數()- 20 ),最大限度(行數()+ 2 ), 公司( 5 ),
小蜱蟲( 1 )}
)
)
)
);
//隱藏臨時控製圖窗口
對象<<櫥窗展示( 0 );
//從窗口中刪除現有/舊圖表(如果有)
嘗試( (持有者 <<孩子) <<刪除);
//稍等片刻以顯示圖表何時更新
等待( 0.2 );
//添加新圖
持有人<<附加(( H 列錶框((對象<<報告) <<克隆盒)));
//關閉臨時控製圖
對象<<關閉窗口;
);
//更新圖表並在 15 秒後調用自身的腳本
快速腳本 =表達式(
//在窗口中加載圖表(運行函數中的腳本)
更新數據();
//在 15 秒內運行相同的腳本
日程( 15 , 快速腳本 );
);
//開始吧:
快速腳本;
回复:數據更新時如何凍結控製圖顯示這是針對 Abrasion.jmp 運行的控製圖腳本
Control Chart(
Group Size( 1 ),
KSigma( 3 ),
Chart Col( :Abrasion, Individual Measurement ),
SendToReport(
Dispatch(
{"Individual Measurement of Abrasion"},
"1",
ScaleBox,
{Min( nrows()-25 ), Max( nrows()+2 ), Inc( 5 ),
Minor Ticks( 1 )}
)
)
);
它使用經典的控製圖平台
回复:數據更新時如何凍結控製圖顯示感謝您的建議。 我想這是我的第二個問題。 我應該在原始腳本中插入您的腳本(上面)。
回复:數據更新時如何凍結控製圖顯示太感謝了。 這解決了我的問題。
回复:數據更新時如何凍結控製圖顯示問題是您只想在控製圖中看到最新的數據嗎?
我遇到過一些場景,其中數據正在某些表中更新。 每次我抓取表的副本時,我只想查看最後 50 行,無論表中有多少行。
這很容易設置。 只需製作一個控製圖,並調整 x 軸即可。 然後查看控製圖腳本並找到類似於下面腳本的部分。
SendToReport(
Dispatch(
{"Individual Measurement of Metric 1"},
"1",
ScaleBox,
{Min( nrows()-50), Max( nrows()+2 ), Inc( 5 ),
Minor Ticks( 0 )}
),
在顯示 Min( 和 Max( 的地方,編輯原始腳本中的值。 將 min() 中的數字替換為nrows()-50並將 max() 中的數字替換為nrows()+2。
現在,如果您完成所有奇特的操作,刪除和附加內容,您將獲得包含最新數據的控製圖。
回复:數據更新時如何凍結控製圖顯示現在我想我明白了。問題是每次腳本運行時您都會打開一個新窗口。在每次更新開始時,您要么想要關閉最後一個窗口,要么使用新圖表刷新同一窗口。下面是後者的一個例子。
我經常在編寫任何真正的代碼之前在註釋中編寫“偽代碼”,我發現這有助於確保代碼實際上按照我的預期進行。然後,一旦整個工作流程有意義,我就會填寫代碼來實際執行它。
//Open a window
//Every 15 Seconds:
//Make a chart with the latest data
//Update the window with a new chart
//Open a window to show a control chart and then update
//the chart every 15 seconds
//Includes a button to refresh early.
Names Default To Here( 1 );
//Define variables here that need to keep their values through subsequent function calls
//This includes the window and data table
//Open a window to hold the chart (note this only happens once)
nw = New Window( "Control Chart",
V List Box(
Button Box( "New Data", UpdateData() ),
holder = H List Box();
)
);
//Make a variable to hold a reference to the data table
dt = .;
//A function that will update the chart
UpdateData = Function( {},
//Close the table if it is already open
Try( dt << Close Window );
//Open data table
dt = Open( "$SAMPLE_DATA/Abrasion.jmp", Private );
//Make the control chart
obj = dt << Control Chart Builder(
Variables( Y( :Abrasion ) ),
Chart(
Position( 1 ),
Points( Statistic( "Individual" ) ),
Limits( Sigma( "Moving Range" ) )
),
Chart(
Position( 2 ),
Points( Statistic( "Moving Range" ) ),
Limits( Sigma( "Moving Range" ) )
)
);
//Hide the temporary control chart window
obj << ShowWindow( 0 );
//Remove existing/old graph from the window (if there is one)
Try( (holder << Child) << Delete );
//Wait a moment to show when the chart updates
Wait(0.2);
//Add the new graph
holder << Append( (H List Box( (obj << Report) << Clone Box )) );
//Close the temporary control chart
obj << Close Window;
);
//Script to update then chart and then call itself 15 seconds later
quickieScript = Expr(
//Load the chart in the window (run the script in the function)
UpdateData();
//Run this same script in 15 seconds
Schedule( 15, quickieScript );
);
//Start things off:
quickieScript;回复:數據更新時如何凍結控製圖顯示抱歉我錯過了前幾行。 這是正確的。
------------
名稱默認為此處( 1 );
快速腳本 =表達式(
日程( 15 , 快速腳本 );
//打開樣本數據
dt =打開( “$SAMPLE_DATA/磨損.jmp” );
//更新圖表的函數
更新數據=功能({},
//製作控製圖
對象 = dt <<控製圖生成器(
變量(Y(:磨損)),
圖表(
位置( 1 ),
積分( 統計( “個人” ) ),
極限(西格瑪( “移動範圍” ) )
),
圖表(
位置( 2 ),
積分( 統計( “移動範圍” ) ),
極限(西格瑪( “移動範圍” ) )
)
);
//隱藏臨時控製圖窗口
對象<<櫥窗展示( 0 );
//從窗口中刪除現有/舊圖表(如果有)
嘗試( (持有者 <<孩子) <<刪除);
//添加新圖
持有人<<附加(( H 列錶框((對象<<報告) <<克隆盒)));
//關閉臨時控製圖
對象<<關閉窗口;
);
//打開一個窗口來顯示新的控製圖和一個按鈕來刷新圖表
//包括一個運行上面腳本的按鈕。
西北=新窗戶( 《控製圖》 ,
V 列錶框(
按鈕盒( “新數據” , 更新數據() ),
持有者= H 列錶框();
)
);
//加載窗口中的第一個圖表(運行函數中的腳本)
更新數據();
);
快速腳本;
回复:數據更新時如何凍結控製圖顯示謝謝。 我使用窗口調度程序來運行此腳本,並且希望在讀取數據後(例如 15 秒左右)查看一張圖表。 我得到很多“控製圖”)。 我嘗試了你的例子,我把它放在窗口任務(也是計劃功能)中,我得到了許多“控製圖”1、2、3,.. 有沒有一種方法只能在圖表上獲得?
下面是我使用的。 謝謝
//更新圖表的函數
更新數據=功能({},
//製作控製圖
對象 = dt <<控製圖生成器(
變量(Y(:磨損)),
圖表(
位置( 1 ),
積分( 統計( “個人” ) ),
極限(西格瑪( “移動範圍” ) )
),
圖表(
位置( 2 ),
積分( 統計( “移動範圍” ) ),
極限(西格瑪( “移動範圍” ) )
)
);
//隱藏臨時控製圖窗口
對象<<櫥窗展示( 0 );
//從窗口中刪除現有/舊圖表(如果有)
嘗試( (持有者 <<孩子) <<刪除);
//添加新圖
持有人<<附加(( H 列錶框((對象<<報告) <<克隆盒)));
//關閉臨時控製圖
對象<<關閉窗口;
);
//打開一個窗口來顯示新的控製圖和一個按鈕來刷新圖表
//包括一個運行上面腳本的按鈕。
西北=新窗戶( 《控製圖》 ,
V 列錶框(
按鈕盒( “新數據” , 更新數據() ),
持有者= H 列錶框();
)
);
//加載窗口中的第一個圖表(運行函數中的腳本)
更新數據();
);
快速腳本;
回复:數據更新時如何凍結控製圖顯示我在這裡可能走錯了方向,但我認為您希望在新數據出現時替換窗口中的圖表,而不是在其下方/之後添加另一個圖表。為此,請在添加新圖表之前刪除舊圖表。這是一個例子:
names default to here( 1 );
//Open sample data
dt = Open("$SAMPLE_DATA/Abrasion.jmp");
//A variable used to hide part of the data
lastrow = 10;
//Hide data after the last row (simulates a smaller table)
df = dt << Data Filter(
Location( {696, 15} ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) ),
Add Filter(
columns( Transform Column( "Row", Formula( Row() ) ) ),
Where(
Transform Column( "Row", Formula( Row() ) ) <= lastrow
)
)
);
//A function that will update the chart
UpdateData = function( {},
//Add one row to the data table
lastrow++;
//Update the data filter (simulates getting more data)
df << Delete All;
df << Add Filter(
columns( Transform Column( "Row", Formula( Row() ) ) ),
Where(
Transform Column( "Row", Formula( Row() ) ) <= lastrow
)
);
//Make the control chart
obj = dt << Control Chart Builder(
Variables( Y( :Abrasion ) ),
Chart(
Position( 1 ),
Points( Statistic( "Individual" ) ),
Limits( Sigma( "Moving Range" ) )
),
Chart(
Position( 2 ),
Points( Statistic( "Moving Range" ) ),
Limits( Sigma( "Moving Range" ) )
)
);
//Hide the temporary control chart window
obj << ShowWindow(0);
//Remove existing/old graph from the window (if there is one)
Try( (holder << Child) << Delete );
//Add the new graph
holder << Append(( H List Box( (obj << Report) << Clone Box)));
//Close the temporary control chart
obj << Close Window;
);
//Open a window to show the new control chart and a button to refresh the chart
//Includes a button to run the script above.
nw = New Window("Control Chart",
V List Box(
Button Box("New Data", UpdateData() ),
holder = H List Box();
)
);
//Load the first chart in the window (run the script in the function)
UpdateData();