グラフと同じダッシュボードのメニューから選択して、グラフ ビルダーで「Color( )」を動的に更新JMP コミュニティの皆様、こんにちは。
アプリケーションを生成する JMP アドインを使用しています。 このアプリケーションにはモジュールが 1 つしかなく、複数のグラフを含むダッシュボードを作成します。 また、同じダッシュボードに埋め込まれ、グラフの生成に使用されるデータ テーブルの列のリストを含む表示ボックスも作成します。 リストから列が選択されると、その選択に従って行の状態 (具体的には行の色) が更新されます。 これは、行の状態に応じて色分けされたグラフに反映されます。 ただし、グラフ ビルダの 'Color( )' 変数はまだ空であるため、グラフの凡例は表示される色に従って更新されません。 列リストをモーダルウィンドウとして表示するディスプレイボックスを作成すると、選択に基づいて「Color()」フィールドに入力できます前グラフが生成されます。 ただし、このアプローチの問題点は、モーダル ウィンドウをダッシュボードに埋め込むことができない (または、少なくともその方法がわからない) ことです。さらに重要なことは、モーダル ウィンドウが動的ではないことです。選択できるのは 1 回だけです。グラフが生成される前の開始時に、アドインを再度実行しなければ別の選択を行うことはできません。 コードからの抜粋を含めました。 'win' オブジェクトは、列のリストを持ち、ダッシュボードに埋め込まれている表示ボックスです。
JMP App(
Set Name( "Application" ),
Set Description(
"An empty workspace for creating custom applications with one or more windows and scripts"
),
Auto Launch( 1 ),
Snap To Grid( 1 ),
Show Grid( 1 ),
Show Properties( 1 ),
Show Sources( 1 ),
Group By Category( 1 ),
Dashboard Mode( 0 ),
Parameters,
Tables,/*(
DataTable1 = GuiTable(
Set Path(
"/S:/17 - Contacts - Confidential material/Siemens/2018-08 - Bangkok test/05 - Analysis/All component compilation v6 (with Row column).jmp"
),
Set Label( "All component compilation v5" ),
Set Location( "Current Data Table" ),
Set Invisible( 0 )
)
),*/
Script(JSL Quote(// This script is executed when the application is run.
// Named objects have been created for the application modules
// (for example, "Module1") and the pre-defined object
// "thisApplication" refers to the application object itself.
// Variables and functions declared here are scoped to the
// Application namespace.
)),
Allocate(
Module1 = Plan(
PreAllocate,
Script(JSL Quote(// This script is executed when a new module instance is
// created. The pre-defined object "thisModuleInstance" refers
// to the instance object, but other objects such as boxes and
// scripts have not yet been created. Variables declared here are
// scoped to the ModuleInstance namespace.
// This special function will receive parameters passed to CreateInstance()
OnModuleLoad({});
dt = current data table(); //note that dt has to be defined before the thisModuleInstance' object is created. When defined after and the new "Row" column is added, the code does not recognise the new column and so outputs empty plots. This may be due to the namespaces: maybe the dt has to be in the application namespace and the after thisModuleInstance is created, it is in the module namespace.
If( Is Missing (Is Scriptable( Try ( Column( "Row" )))),
dt << New Column( "Row", Numeric, Values( 1 :: N Row() ), Format( "Best", 12 )));
colnames = dt << get column names;
thisModuleInstance << Create Objects;
// After this point your module instance objects have been created
// and can be referred to by name (for example, "Button1").
show(chosen);
)),
Allocate(
Outline1 = Outline Box();
DataFilterContext1 = Data Filter Context Box();
List1 = H List Box();
List2 = V List Box();
DataFilter1 = dt << Data Filter( Local );
win = Platform(
dt,
H List Box(
Panel Box( "Colour by:",
collist = List Box(
colnames,
max selected( 1 ),
chosen = collist << get selected;
col = column(chosen);
dt << Color or Mark by Column( col ),
)
)
)
);
List3 = V List Box();
List4 = H List Box();
Report1 = Platform(
dt,
Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window( "Maintain Aspect Ratio" ),
Variables( X( :Row ), Y( :Friction ) ),
Elements(
Points( X, Y, Legend( 9 ) ),
Smoother( X, Y, Legend( 10 ) )
),
)
);
Report2 = Platform(
dt,
Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window( "Maintain Aspect Ratio" ),
Variables( X( :Row ), Y( :Velocity ) ),
Elements(
Points( X, Y, Legend( 6 ) ),
Smoother( X, Y, Legend( 7 ) )
)
)
);
ご提案をお待ちしております。
よろしくお願いします!
グラフィック他のスクリプティングRe: グラフと同じダッシュボードのメニューから選択して、グラフ ビルダーで「Color( )」を動的に更新する@gzmorgan0さん、早速の返信ありがとうございます。
あなたのソリューションはうまくいきました。 以下のコードで、他の人の利益のためにあなたのソリューションを私のニーズにどのように適合させたかを示します.
JMP App(
Set Name( "Application" ),
Set Description(
"An empty workspace for creating custom applications with one or more windows and scripts"
),
Auto Launch( 1 ),
Snap To Grid( 1 ),
Show Grid( 1 ),
Show Properties( 1 ),
Show Sources( 1 ),
Group By Category( 1 ),
Dashboard Mode( 0 ),
Parameters,
Tables,/*(
DataTable1 = GuiTable(
Set Path(
"/S:/17 - Contacts - Confidential material/Siemens/2018-08 - Bangkok test/05 - Analysis/All component compilation v6 (with Row column).jmp"
),
Set Label( "All component compilation v5" ),
Set Location( "Current Data Table" ),
Set Invisible( 0 )
)
),*/
Script(JSL Quote(// This script is executed when the application is run.
// Named objects have been created for the application modules
// (for example, "Module1") and the pre-defined object
// "thisApplication" refers to the application object itself.
// Variables and functions declared here are scoped to the
// Application namespace.
)),
Allocate(
Module1 = Plan(
PreAllocate,
Script(JSL Quote(// This script is executed when a new module instance is
// created. The pre-defined object "thisModuleInstance" refers
// to the instance object, but other objects such as boxes and
// scripts have not yet been created. Variables declared here are
// scoped to the ModuleInstance namespace.
// This special function will receive parameters passed to CreateInstance()
OnModuleLoad({});
dt = current data table(); //note that dt has to be defined before the thisModuleInstance' object is created. When defined after and the new "Row" column is added, the code does not recognise the new column and so outputs empty plots. This may be due to the namespaces: maybe the dt has to be in the application namespace and the after thisModuleInstance is created, it is in the module namespace.
If( Is Missing (Is Scriptable( Try ( Column( "Row" )))),
dt << New Column( "Row", Numeric, Values( 1 :: N Row() ), Format( "Best", 12 )));
colnames = dt << get column names;
thisModuleInstance << Create Objects;
// After this point your module instance objects have been created
// and can be referred to by name (for example, "Button1").
)),
Allocate(
Outline1 = Outline Box();
DataFilterContext1 = Data Filter Context Box();
List1 = H List Box();
List2 = V List Box();
DataFilter1 = dt << Data Filter( Local );
win = Platform(
dt,
H List Box(
Panel Box( "Colour by:",
collist = List Box(
colnames,
max selected( 1 ),
if( chosen != "",
gbb1 << Remove Variable( {col, Role( "Color" )} );
gbb2 << Remove Variable( {col, Role( "Color" )} );
);
chosen = collist << get selected;
col = column(chosen);
dt << Color or Mark by Column( col );
gbb1 = Report( gb1 )[Graph Builder Box( 1 )];
gbb1 << Add Variable( {col, Role( "Color" )} );
gbb2 = Report( gb2 )[Graph Builder Box( 1 )];
gbb2 << Add Variable( {col, Role( "Color" )} );
)
)
)
);
List3 = V List Box();
List4 = H List Box();
Report1 = Platform(
dt,
gb1 = Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window( "Maintain Aspect Ratio" ),
Variables( X( :Row ), Y( :Friction ) ),
Elements(
Points( X, Y, Legend( 9 ) ),
Smoother( X, Y, Legend( 10 ) )
)
)
);
Report2 = Platform(
dt,
gb2 = Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Fit to Window( "Maintain Aspect Ratio" ),
Variables( X( :Row ), Y( :Velocity ) ),
Elements(
Points( X, Y, Legend( 6 ) ),
Smoother( X, Y, Legend( 7 ) )
)
)
);繰り返しますが、上記は完全なコードからの抜粋です。 上記のように、新しい選択が行われるたびに実行される「win」プラットフォーム内で gbb1 と gbb2 を定義する必要があります。 これは速度の点で最適ではないかもしれませんが、コードが機能する場合に定義できる唯一の場所のようです (理由はわかりません)。
もう一度ありがとう@gzmorgan0 .
Re: グラフと同じダッシュボードのメニューから選択して、グラフ ビルダーで「Color( )」を動的に更新する@A_Zaid 、
あなたが述べた
"グラフが生成される前に開始時に一度だけ選択を行うことができますが、アドインを再度実行することなく別の選択を行うことはできません。 "
実際、それは私たちの本の正誤表でした。 GraphBuilderBox() にメッセージを送信することで、変数を追加または削除できます。 以下のスクリプトを参照してください。
変数を追加または削除するには、インターフェイスを追加する必要がある場合があります。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y ), Smoother( X, Y ) )
);
gbb = Report( gb )[Graph Builder Box( 1 )];
Wait( 0.5 );
gbb << Add Variable( {:sex, Role( "Wrap" )} );
wait( 0.5 );
gbb << Add Variable( {:sex, Role( "Color" )} );
wait( 0.5 );
gbb << Remove Variable( {:sex, Role( "Color" )} );
wait( 0.5 );
gbb << Add Variable( {:age, Role( "Color" )} );