指示器上的颜色大家好,
我正在尝试在 JMP 中创建一个报告,以便我可以看到某些流程中的偏差。
例如,我在流程中研究了 6 个项目,我想要一个带有颜色的指示器:
- 如果 5 个连续点(或更多)大于 3sigma:红色
- 如果连续 3 个点(或更多)大于 3sigma:黄色
- 否则为绿色
然后我希望能够根据指示器的颜色在报告中显示每个项目的类似内容:

我怎样才能在 JMP 上获得类似的东西?
感谢您的回复。
自动化和脚本回复:指示器上的颜色每个“项目”是否都在单独的列中?
您的数据是否按顺序排列”
有多少种不同的“物品”?
报告的每一行是否应该只有 3 个不同的项目?
回复:指示器上的颜色如果您想要一个表格,请使用数据表并为单元格着色。在图形生成器中,您可能能够使用热图。如果您想要编写脚本,则可以使用多种不同的选项来设置背景颜色。
回复:指示器上的颜色每个“项目”是否都在单独的列中?是的,逐列逐项
您的数据是按顺序排列的吗?是的,可以按顺序排序
有多少种不同的“物品”?很多……
报告的每一行是否应该只有 3 个不同的项目?是的
回复:指示器上的颜色一个简单的选择是这样的
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(6),
Compress File When Saved(1),
New Column("item",
Character,
"Nominal",
Set Values({"ITEM1", "ITEM2", "ITEM3", "ITEM4", "ITEM5", "ITEM6"})
),
New Column("status",
Character,
"Nominal",
Set Values({"Green", "Green", "Red", "Yellow", "Green", "Red"})
)
);
lub = Lineup Box(N Col(3));
For Each Row(dt,
Eval(EvalExpr(
lub << Append(
Text Box(:item, << Background Color(Expr(:status)))
)
));
);
nw = New Window("",
lub
);

回复:指示器上的颜色感谢您的回答,我正在尝试创建一个带有红色、黄色和绿色指示器的类似表格。
我的目标是创建:
- 如果连续 5 个点(或更多)为红色(高于 3 sigma),则最后一个点的颜色为红色
- 如果连续 3 个点(或更多)为红色(高于 3 sigma),则最后一个点的颜色为黄色
- 否则为绿色
在附件中,您可以找到一个作为示例的表,我创建了以下脚本但没有成功:
dt = current data table();
// Créez une nouvelle colonne pour l'indicateur
dt << New Column("Indicateur", Character, Nominal);
// Boucle pour calculer l'indicateur ligne par ligne
For(i = 1, i <= N Rows(5), i++,
// Récupérer les 5 dernières valeurs de l'indicateur
last_five = dt:status[i,5]; //
// Comptez le nombre de "rouge"
count_rouge = N Items( last_five == "rouge");
// Attribuer une couleur en fonction des règles
If(count_rouge == 5,
dt:Indicateur Global[i] = "rouge"; // 5 rouges
,
If(count_rouge >= 3,
dt:Indicateur Global[i] = "jaune"; // 3 ou plus rouges
,
dt:Indicateur Global[i] = "vert"; // Sinon vert
);
);
);回复:指示器上的颜色我认为这段代码可以实现你想要的功能:
dt = New Table( "testcolors", Add Rows( 15 ),
New Column( "Article", Character, "Nominal",
Set Values( {"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A"}
) ),
New Column( "Item", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] )
),
New Column( "status", Character, "Nominal",
Set Values(
{"red", "red", "red", "green", "green", "red", "red", "red", "red",
"red", "red", "green", "red", "red", "red"}
)
),
// Créez une nouvelle colonne pour l'indicateur
New Column("Indicateur", Character, Nominal)
);
one_color = "xyz";
icolor = 0;
for (i = 1, i <= nrows(dt), i++,
one_color = dt:status[i];
if (one_color == "red",
icolor++;
// else
,
if (icolor >= 5,
dt:Indicateur << Color Cells( "Red", i-1 );
icolor = 0;
// else
,
icolor >= 3,
dt:Indicateur << Color Cells( "Yellow", i-1 );
icolor = 0;
);
);
);
// Handle the last row
if (icolor >= 5,
dt:Indicateur << Color Cells( "Red", i-1 );
// else
,
icolor >= 3,
dt:Indicateur << Color Cells( "Yellow", i-1 );
);

回复:指示器上的颜色我仍然感到困惑。但是,鉴于您提供的数据表(该表似乎包含您尝试计算的结果),人们可以轻松地为 Indicateur 列的单元格着色

names default to here(1);
dt=current data table();
dt << New Column("Indicateur", Character, Nominal);
:indicateur << color cells("red",dt<<GET rows="" where=""></GET>
<P>或者可以创建单独的报告</P>
<P><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1736426542617.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="txnelson_1-1736426542617.png" style="width: 119px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="txnelson_1-1736426542617.png" style="width: 119px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="txnelson_1-1736426542617.png" style="width: 119px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="txnelson_1-1736426542617.png" style="width: 119px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="txnelson_1-1736426542617.png" style="width: 119px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="txnelson_1-1736426542617.png" style="width: 119px;"><span class="lia-inline-image-display-wrapper" image-alt="txnelson_1-1736426542617.png" style="width: 119px;"><img src="https://us.v-cdn.net/6038925/uploads/images/71760iF5D0EC4B9B8E8098/txnelson_1-1736426542617.png" role="button" title="txnelson_1-1736426542617.png" alt="txnelson_1-1736426542617.png" /></span></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<CODE class=" language-jsl">nw=new window("colors", lub=lineupbox(ncol(3)));
For Each Row(dt,
Eval(EvalExpr(
lub << Append(
Text Box("Item" || char(:item), << Background Color(Expr(:status)))
)
));
);回复:指示器上的颜色您好,谢谢您的回答,在这个测试基地上效果很好!
当我有多篇文章时,我试图概括这个脚本。颜色指示器是按项目创建的。
我使用以下脚本,但没有得到正确的最终结果:
dt = current data table();
// Créez une nouvelle colonne pour l'indicateur
dt << New Column("Indicateur", Character, Nominal)
one_color = "xyz";
icolor = 0;
Summarize(dt, unique_objects = by(:Article));
m_obs = dt[0, "Article"];
For each( {unique_objects}, m_obs,
for (i = 1, i <= nrows(dt), i++,
one_color = dt:status[i];
if (one_color == "red",
icolor++;
// else
,
if (icolor >= 5,
dt:Indicateur << Color Cells( "Red", i-1 );
icolor = 0;
// else
,
icolor >= 3,
dt:Indicateur << Color Cells( "Yellow", i-1 );
icolor = 0;
);
);
);
// Handle the last row
if (icolor >= 5,
dt:Indicateur << Color Cells( "Red", i-1 );
// else
,
icolor >= 3,
dt:Indicateur << Color Cells( "Yellow", i-1 );
);
);得到的结果:

第 18 行应该为黄色,因为文章 B 有 3 个连续的红色点...
回复:指示器上的颜色这是我的方法

names default to here(1);
dt = current data table();
// Créez une nouvelle colonne pour l'indicateur
dt << New Column("Indicateur", Character, Nominal);
one_color = "xyz";
icolor = 0;
For Each Row(
// If the value of Article has changed set icolor to 0
If( Lag( :Article ) != :Article,
icolor = 0
);
// If status is red, increment icolor else set it back to zero
If( :status == "red",
icolor++,
icolor = 0
);
// Check for the number of icolor
// Set the value for the cell to the appropriate color
// When a color is specified remove no longer correct cell colors
// for previous rows
If(
icolor >= 5,
dt:Indicateur << color cells("red",row());
dt:Indicateur << color cells("",row()-1);
If( icolor == 5,
dt:Indicateur << color cells("",row()-2);
);,
icolor >= 3,
dt:Indicateur << color cells("yellow",row());
dt:Indicateur << color cells("",row()-1);
);
);回复:指示器上的颜色感谢您的回复。
它有效,但不完全符合其应有的效果。
我尝试对第二个 if 循环进行更改,但找不到解决方案。
以下是我想要达到的确切结果:

回复:指示器上的颜色我的上一个脚本假设您只希望系列中的最后一行保留计算出的颜色。为了实现您的最新规范,我只是注释掉了当脚本确定它不是系列中的最后一行时重置颜色的行。

names default to here(1);
dt = current data table();
// Créez une nouvelle colonne pour l'indicateur
dt << New Column("Indicateur", Character, Nominal);
one_color = "xyz";
icolor = 0;
For Each Row(
// If the value of Article has changed set icolor to 0
If( Lag( :Article ) != :Article,
icolor = 0
);
// If status is red, increment icolor else set it back to zero
If( :status == "red",
icolor++,
icolor = 0
);
// Check for the number of icolor
// Set the value for the cell to the appropriate color
// When a color is specified remove no longer correct cell colors
// for previous rows
If(
icolor >= 5,
dt:Indicateur << color cells("red",row());
//dt:Indicateur << color cells("",row()-1);
/*If( icolor == 5,
dt:Indicateur << color cells("",row()-2);
);*/,
icolor >= 3,
dt:Indicateur << color cells("yellow",row());
//dt:Indicateur << color cells("",row()-1);
);
);回复:指示器上的颜色我不确定这与最初的问题有什么关系,但是创建指标列的选项有点不同
dt = Current Data Table();
dt << New Column("Color", Character, Nominal,
Set Property(
"Value Colors",
{"Green" = "Green", "Red" = "Red", "Yellow" = "Yellow"}
),
Color Cell By Value,
Formula(
is_red = :status == "red";
If(Row() == 1,
red_count = is_red;
);
If(:Article != Lag(:Article, 1) | is_red == 0,
red_count = is_red;
,
red_count = red_count + is_red;
);
If(red_count >= 5,
"Red";
, red_count >= 3,
"Yellow"
,
"Green"
);
)
);