こんにちは、
時間の塊が異なる「サイクル」に分割されている時系列データがあり、各サイクルの開始を示す参照線を作成する方法を探しています。試行間でローカル データ フィルターを変更するときに、これらの参照線を更新する必要があります (試行ごとにサイクルが異なる時間に開始するため)。
最初は、ローカル データ フィルターを使用して、 Make Row State Handlerを使用してローカル データ フィルターの変更を検出していました。しかし、ローカル データ フィルターから必要な情報 (つまり、フィルター処理されているトライアル。ただし、ローカル データ フィルターでGet Where Clauseを使用して近づいた可能性があります) を取得する方法がわからず、フィルター処理されているトライアルを把握できず、参照線の作成に使用するサイクル タイムを決定できませんでした。(ただし、この方法の方が優れていると思われる場合は、お知らせください)。
そこで、ユーザーにローカル データ フィルターを操作させてフィルターを読み取ってフィルター対象のトライアルを取得させるのではなく、トライアルのリストをユーザーに提供し、ユーザーが選択したトライアルに基づいてフィルターを追加し、同時に選択内容を使用して参照線の作成に使用するサイクル時間を指定することにしました。
ただし、ユーザーが別の試験番号を選択したときに変化する参照線を追加することはできません。
私のコードは下記をご覧ください。
//Reference Lines that Update With Change in Local Data Filter
// Example Data
dt = New Table( "Example",
Add Rows( 3 ),
New Column( "Trial",
character,
"Ordinal",
Set Values( {"A","A","A","A","A","A","A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","B","B","B","B","B","B"} )
),
New Column( "Cycle",
Character,
"Ordinal",
Set Values( {"Rinse","Rinse","Rinse","Wash","Wash","Wash","Wash","FinalRinse","FinalRinse","FinalRinse","FinalRinse","Dry","Dry","Dry","Rinse","Rinse","Rinse","Wash","Wash","Wash","Wash","FinalRinse","FinalRinse","FinalRinse","FinalRinse","Dry","Dry","Dry
"} )
),
New Column( "%Clean",
Numeric,
"Continuous",
Set Values( {10,20,25,50,60,70,80,85,90,95,99,99,99,99,10,25,30,60,75,85,90,95,99,99.9,99.99,99.99,99.99,99.99} )
),
New Column( "Time",
Numeric,
"Continuous",
Set Values( {1,2,3,4,5,6,7,8,9,10,11,12,13,14,2,4,6,8,10,12,14,16,18,20,22,24,26,28} )
),
);
dt = current data table();
//Function to pull cycle start times (where reference lines will be drawn)
genRefLineValue = function({trialNum = "A", cycleNum = "Rinse"},{myrows,myvalues,min_value},
myrows = dt << get rows where(and(:Trial == trialNum,:Cycle == cycleNum));
myvalues = :Time[myrows];
min_value = min(myvalues);
Return(min_value);
);
//Function to pull unique cycles (I want the start time for EACH of the cycles)
findUniqueCycles = function({trialNum},{myrows,cycles,uniqueCycles},
myrows = dt << get rows where(:Trial == trialNum);
cycles = :Cycle[myrows];
uniqueCycles = associative array(cycles) << get keys;
return(uniqueCycles);
);
//Get unique trials (A, B, etc.)
summarize(unique_values=by(:Trial));
//Create window with radio buttons and graph
New Window( "Example",
HListBox(
PanelBox("Trial", //Adding radio buttons
rb = radio box(
unique_values, <<SET></SET>
At the bottom is where I add the reference lines. If you run the script and select between Trial A and B, you can see that while the filter's working and the data changes accordingly, the reference lines don't change (it might look like they change, but if you observe the actual values, they aren't changing). I've tried using <EM>私の選択</EM> in place of "A" so that the arguments in the loop that is creating the reference lines should update when the user selects Trial B:
<CODE class=" language-jsl">For(i=1,i<= (n items (findUniqueCycles(myChoice))),i++,
cycleName = findUniqueCycles(myChoice)[i];
cycleStart = genRefLineValue(myChoice,findUniqueCycles(myChoice)[i]);
report(biv)[axisbox(2)] << add ref line(cycleStart,"solid",,cycleName ||"(t="||char(cycleStart)||" min)",1.5);
);
But JMP complains by saying:
Name Unresolved: myChoice{3} in access or evaluation of 'myChoice' , myChoice/*###*/How do I make reference lines that update when the user changes their selection among trials?
Thanks in advance!
私はあなたがほとんどそこにいると思います。
コードの後半部分をこれに置き換えてみてください
rb << Set Function(
Function( {this},{myChoice},
myChoice = Char( this << get selected );
(this << sib) << Set Text( myChoice );
//print(myChoice);
biv << remove local data filter;
biv << Local Data Filter(invisible, //updating (by removing then re-adding) the local data filter according to user's selection
Add Filter(
columns( :Trial ),
Where( :Trial == myChoice ),
));
if (myChoice == "A",
For(i=1,i<= (n items (findUniqueCycles("B"))),i++,
cycleStart = genRefLineValue("B",findUniqueCycles("B")[i]);
report(biv)[axisbox(2)] << remove ref line(cycleStart);
)
);
if (myChoice == "B",
For(i=1,i<= (n items (findUniqueCycles("A"))),i++,
cycleStart = genRefLineValue("A",findUniqueCycles("A")[i]);
report(biv)[axisbox(2)] << remove ref line(cycleStart);
)
);
For(i=1,i<= (n items (findUniqueCycles(myChoice))),i++,
cycleName = findUniqueCycles(myChoice)[i];
cycleStart = genRefLineValue(myChoice,findUniqueCycles(myChoice)[i]);
report(biv)[axisbox(2)] << add ref line(cycleStart,"solid",,cycleName ||"(t="||char(cycleStart)||" min)",1.5);
);
)
);
report(biv)[framebox(1)] << Frame Size( 1000, 400 );
//you need this to initialize somehow
For(i=1,i<= (n items (findUniqueCycles("A"))),i++,
cycleName = findUniqueCycles("A")[i];
cycleStart = genRefLineValue("A",findUniqueCycles("A")[i]);
report(biv)[axisbox(2)] << add ref line(cycleStart,"solid",,cycleName ||"(t="||char(cycleStart)||" min)",1.5);
);
さらに、このエラーは、myChoice が見つからないか未定義であることを意味します。これは、myChoice が使用可能な場所の外 (コールバック内) で使用されたためです。