グラフビルダーのコンボボックスプルダウンメニューを使用して緯度と経度を動的に変更する注: データとスクリプトは以下にアップロードされています...
以下のようなスクリプトを開発しました。まず、経路を示す広い範囲をプロットします。モーダルウィンドウがポップアップ表示され、ユーザーは特定の場所のコード(この例では1または2)を入力できます。この情報を入力すると、グラフがその場所にズームインされます。これらはすべて正常に動作しますが、私が求めているものとは少し異なります。最も重要なのは、選択が行われてスクリプトが終了するとダイアログボックスが消えてしまうことです。次に、コンボボックスのプルダウンメニューでこれを動作させようと試みました。メニュー自体は動作するのですが、何らかの理由でグラフを変更する選択肢が表示されないようです。
モーダル テキスト ボックスは次のようになります...
Names Default To Here( 1 );
dt = Data Table( "Test Data" );
gb = Graph Builder(
Graph Spacing( 10 ),
Spacing Borders( 1 ),
Variables( X( :Longitude ), Y( :Latitude ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch( {}, "Longitude", ScaleBox, {Min( -104 ), Max( -98.47 )} ),
Dispatch( {}, "Latitude", ScaleBox, {Min( 29.21 ), Max( 33.30 )} ),
Dispatch( {}, "Graph Builder", FrameBox,
{Background Map( Images( "Street Map Service", "Mapbox Satellite", "" ) )}
)
)
);
// Build the modal input window
New Window( "Pick a spot",
Modal,
H List Box(
V List Box( Text Box( "Location Number:" ), ),
V List Box( box = Number Edit Box( "Enter location number..." ), )
),
Button Box( "OK",
// Script to run when "OK" is clicked
locNum = box << Get;
Print( "Location Number: " || Char( locNum ) );
),
Button Box( "Cancel",
// Script to run when "Cancel" is clicked
Throw()
)
);
If(
locNum == 1,
minLat = 30.99;
maxLat = 31.06;
minLong = -101.21;
maxLong = -101.11;
run = "1|1";,
locNum == 2,
minLat = 31.34;
maxLat = 31.41;
minLong = -101.81;
maxLong = -101.71;
run = "2|1";
);
gb << Dispatch( {}, "Longitude", ScaleBox, {Min( minLong ), Max( maxLong )} );
gb << Dispatch( {}, "Latitude", ScaleBox, {Min( minLat ), Max( maxLat )} );
初期マップはこんな感じです…

拡大表示は次のようになります...

私のジレンマは、1) ComboBox をこれと連携させるにはどうすればよいか、2) ユーザーがプルダウン メニューから引き続き別の項目を選択できるように、スクリプトの完了を防ぐにはどうすればよいか、という点です。
これは Set Function コマンドと関係があるような気がしますが、これを機能させようと何度も試みましたが、成果はありませんでした。
これに関してご指導いただければ幸いです。
ありがとう。
自動化とスクリプトRe: グラフビルダーでコンボボックスのプルダウンメニューを使用して緯度と経度を動的に変更するこのような場合にはモーダルウィンドウは使用しません
Names Default To Here(1);
dt = Data Table("Test Data");
gb = dt << Graph Builder(
Graph Spacing(10),
Spacing Borders(1),
Variables(X(:Longitude), Y(:Latitude)),
Elements(Points(X, Y, Legend(3))),
SendToReport(
Dispatch({}, "Longitude", ScaleBox, {Min(-104), Max(-98.47)}),
Dispatch({}, "Latitude", ScaleBox, {Min(29.21), Max(33.30)}),
Dispatch({}, "Graph Builder", FrameBox,
{Background Map(Images("Street Map Service", "Mapbox Satellite", ""))}
)
)
);
wait(0);
cb_expr = Expr(
locNum = cb_option << get;
show(locNum);
If(
locNum == 1,
minLat = 30.99;
maxLat = 31.06;
minLong = -101.21;
maxLong = -101.11;
run = "1|1";,
locNum == 2,
minLat = 31.34;
maxLat = 31.41;
minLong = -101.81;
maxLong = -101.71;
run = "2|1";
);
gb << Dispatch({}, "Longitude", ScaleBox, {Min(minLong), Max(maxLong)});
gb << Dispatch({}, "Latitude", ScaleBox, {Min(minLat), Max(maxLat)});
);
// Build the modal input window
nw = New Window("Pick a spot",
Lineup Box(N Col(2),
Text Box("Location Number:"),
cb_option = Combo Box({"1", "2"},
cb_expr
),
),
Button Box("OK",
cb_expr; // not necessary if you wish to run when combo box is changed
Print("Location Number: " || Char(locNum));
),
Button Box("Cancel",
// Script to run when "Cancel" is clicked
Throw()
)
);
オプションを連想配列に移動して、後でオプションを追加するのを容易にすることもできます。
Re: グラフビルダーでコンボボックスのプルダウンメニューを使用して緯度と経度を動的に変更するありがとう、 @jthi 。完璧です。
つまり、ComboBoxのアクションをEval()ブロックで囲み、ComboBoxの実行時にそのブロックをスクリプトとして実行するというわけです。私の解釈は正しいと思います。
Re: グラフビルダーでコンボボックスのプルダウンメニューを使用して緯度と経度を動的に変更するコンボボックス内で式を移動できますが、特に複数の場所で同じアクションを使用している場合は、分離すると変更がはるかに簡単になります。
もっと見る...
Names Default To Here(1);
dt = Data Table("Test Data");
gb = dt << Graph Builder(
Graph Spacing(10),
Spacing Borders(1),
Variables(X(:Longitude), Y(:Latitude)),
Elements(Points(X, Y, Legend(3))),
SendToReport(
Dispatch({}, "Longitude", ScaleBox, {Min(-104), Max(-98.47)}),
Dispatch({}, "Latitude", ScaleBox, {Min(29.21), Max(33.30)}),
Dispatch({}, "Graph Builder", FrameBox,
{Background Map(Images("Street Map Service", "Mapbox Satellite", ""))}
)
)
);
wait(0);
// Build the modal input window
nw = New Window("Pick a spot",
Lineup Box(N Col(2),
Text Box("Location Number:"),
cb_option = Combo Box({"1", "2"},
locNum = cb_option << get;
show(locNum);
If(
locNum == 1,
minLat = 30.99;
maxLat = 31.06;
minLong = -101.21;
maxLong = -101.11;
run = "1|1";,
locNum == 2,
minLat = 31.34;
maxLat = 31.41;
minLong = -101.81;
maxLong = -101.71;
run = "2|1";
);
gb << Dispatch({}, "Longitude", ScaleBox, {Min(minLong), Max(maxLong)});
gb << Dispatch({}, "Latitude", ScaleBox, {Min(minLat), Max(maxLat)});
),
),
Button Box("OK",
locNum = cb_option << get;
show(locNum);
If(
locNum == 1,
minLat = 30.99;
maxLat = 31.06;
minLong = -101.21;
maxLong = -101.11;
run = "1|1";,
locNum == 2,
minLat = 31.34;
maxLat = 31.41;
minLong = -101.81;
maxLong = -101.71;
run = "2|1";
);
gb << Dispatch({}, "Longitude", ScaleBox, {Min(minLong), Max(maxLong)});
gb << Dispatch({}, "Latitude", ScaleBox, {Min(minLat), Max(maxLat)});
Print("Location Number: " || Char(locNum));
),
Button Box("Cancel",
// Script to run when "Cancel" is clicked
Throw()
)
);
< の代わりに << Set Function を使用することもできます。 使用できる引数、 コンボボックス)
Names Default To Here(1);
aa_options = Associative Array();
aa_options[1] = [
"minLat" => 30.99,
"maxLat" => 31.06,
"minLong" => -101.21,
"maxLong" => -101.11,
"run" => "1|1"
];
aa_options[2] = [
"minLat" => 31.34,
"maxLat" => 31.41,
"minLong" => -101.81,
"maxLong" => -101.71,
"run" => "2|1"
];
update_graph = Function({cb_ref, idx}, {Default Local},
s = aa_options[idx];
show(s);
gb << Dispatch({}, "Longitude", ScaleBox, {Min(s["minLong"]), Max(s["maxLong"])});
gb << Dispatch({}, "Latitude", ScaleBox, {Min(s["minLat"]), Max(s["maxLat"])});
);
dt = Data Table("Test Data");
gb = dt << Graph Builder(
Graph Spacing(10),
Spacing Borders(1),
Variables(X(:Longitude), Y(:Latitude)),
Elements(Points(X, Y, Legend(3))),
SendToReport(
Dispatch({}, "Longitude", ScaleBox, {Min(-104), Max(-98.47)}),
Dispatch({}, "Latitude", ScaleBox, {Min(29.21), Max(33.30)}),
Dispatch({}, "Graph Builder", FrameBox,
{Background Map(Images("Street Map Service", "Mapbox Satellite", ""))}
)
)
);
wait(0);
options = Transform Each({item}, aa_options << get keys, Char(item)); // combo box requires strings
nw = New Window("Pick a spot",
Lineup Box(N Col(2),
Text Box("Location Number:"),
cb_option = Combo Box(options,
<< Set Function(Function({this, idx},
update_graph(this, idx);
))
)
),
Button Box("Cancel",
<< Set Function(function({this},
this << close window;
))
)
);