如何在数据更新时冻结控制图显示你好,
我有一个读取 csv 文件并控制图表的脚本。 我喜欢自动执行此过程,以便更新新数据,控制图不会生成新图表。 我喜欢只在图表上看到更新的数据。
这是我使用的脚本。 我感谢您的帮助。 谢谢
------------------
名字默认到这里( 1个);
dt =打开(
“/Users/adatorab/Documents/JMP/PASS.csv” ,无形的);
对象 = dt <<
控制图生成器(
变量( Y( :A ) ),
图表(
位置( 1个),
积分(
统计(
“个人”
)
),
限制(
西格玛(
“移动范围”
)
)
),
图表(
位置( 2个),
积分(
统计(
“移动范围”
)
),
限制(
西格玛(
“移动范围”
)
)
)
);
对象 <<显示窗口( 0 );
nw =新窗户( “控制图” );
净重 <<附加((( H 列表框( (对象 <<报告) <<克隆盒)));
回复:如何在数据更新时冻结控制图显示非常感谢你的帮助。
回复:如何在数据更新时冻结控制图显示我将 Bryon 的控制图代码复制到你的代码中,添加了一个随机的“最小”时间,这是我所看到的:
//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 轴只有 20 个点。
你能进一步帮助吗? 我很感激。
//打开一个窗口显示一个控制图然后更新
//图表每15秒
//包括一个提前刷新的按钮。
名字默认到这里( 1个);
//在这里定义需要通过后续函数调用保持其值的变量
//这里包括窗口和数据表
//打开一个窗口来保存图表(注意这只会发生一次)
nw =新窗户( “控制图” ,
V 列表框(
按钮盒( “新数据” , 更新数据() ),
持有人 = H 列表框();
)
);
//创建一个变量来保存对数据表的引用
dt = . ;
//更新图表的函数
更新数据 =功能({},
//如果表已经打开就关闭
尝试( dt <<关闭窗口);
//打开数据表
dt =打开( "$SAMPLE_DATA/Abrasion.jmp" , 私人的 );
//制作控制图
对象 = dt <<控制图生成器(
显示两个休哈特图表( 0 ),
显示控制面板( 0 ),
显示能力( 0 ),
变量( Y( :Abrasion ) ),
图表(
点(统计( “个人” ) ),
限制(西格玛(移动范围)),
//警告(测试1(1))
发送报告(
派遣(
{ “磨损的单独测量” },
“1” ,
比例尺,
{最小值(行()- 20 ),最大限度(行()+ 2个), 公司( 5个),
小滴答声( 1个)}
)
)
)
);
//隐藏临时控制图窗口
对象 <<显示窗口( 0 );
//从窗口中删除现有/旧图形(如果有的话)
尝试( (持有人<<孩子) <<删除);
//稍等片刻以显示图表何时更新
等待( 0.2 );
//添加新图
持有人<<附加( ( H 列表框( (对象 <<报告) <<克隆盒)));
//关闭临时控制图
对象 <<关闭窗口;
);
//脚本更新图表,然后在 15 秒后调用自身
quickieScript =表达式(
//在窗口中加载图表(在函数中运行脚本)
更新数据();
// 在 15 秒内运行相同的脚本
日程( 15 , quickieScript );
);
//开始:
快速脚本;
回复:如何在数据更新时冻结控制图显示这是针对 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() 中的数字替换为n行()+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个);
quickieScript =表达式(
日程( 15 , quickieScript );
//打开样本数据
dt =打开( "$SAMPLE_DATA/Abrasion.jmp" );
//更新图表的函数
更新数据 =功能({},
//制作控制图
对象 = dt <<控制图生成器(
变量( Y( :Abrasion ) ),
图表(
位置( 1个),
点(统计( “个人” ) ),
极限(西格玛( “移动范围” ) )
),
图表(
位置( 2个),
点(统计( “移动范围” ) ),
极限(西格玛( “移动范围” ) )
)
);
//隐藏临时控制图窗口
对象 <<显示窗口( 0 );
//从窗口中删除现有/旧图形(如果有的话)
尝试( (持有人<<孩子) <<删除);
//添加新图
持有人<<附加((( H 列表框( (对象 <<报告) <<克隆盒)));
//关闭临时控制图
对象 <<关闭窗口;
);
//打开一个窗口来显示新的控制图和一个按钮来刷新图表
//包括一个按钮来运行上面的脚本。
nw =新窗户( “控制图” ,
V 列表框(
按钮盒( “新数据” , 更新数据() ),
持有人 = H 列表框();
)
);
//加载窗口中的第一个图表(运行函数中的脚本)
更新数据();
);
快速脚本;
回复:如何在数据更新时冻结控制图显示谢谢。 我使用窗口调度程序来运行此脚本,并希望在读取数据后(比如 15 秒左右)看到一个图表。 我得到很多“控制图”)。 我试过你的例子,我把它放在窗口任务(也是 Schedule 函数),我得到很多“控制图”1、2、3,.. 无论如何,您只能在图表上获得吗?
下面是我用的。 谢谢
//更新图表的函数
更新数据 =功能({},
//制作控制图
对象 = dt <<控制图生成器(
变量( Y( :Abrasion ) ),
图表(
位置( 1个),
点(统计( “个人” ) ),
极限(西格玛( “移动范围” ) )
),
图表(
位置( 2个),
点(统计( “移动范围” ) ),
极限(西格玛( “移动范围” ) )
)
);
//隐藏临时控制图窗口
对象 <<显示窗口( 0 );
//从窗口中删除现有/旧图形(如果有的话)
尝试( (持有人<<孩子) <<删除);
//添加新图
持有人<<附加((( H 列表框( (对象 <<报告) <<克隆盒)));
//关闭临时控制图
对象 <<关闭窗口;
);
//打开一个窗口来显示新的控制图和一个按钮来刷新图表
//包括一个按钮来运行上面的脚本。
nw =新窗户( “控制图” ,
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();