如何在数据更新时冻结控制图显示你好,
我有一个读取 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();