指示器上的顏色大家好,
我正在嘗試在 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"
);
)
);