Modifier dynamiquement la latitude et la longitude dans Graph Builder avec le menu déroulant ComboBoxRemarque : données et script téléchargés ci-dessous...
J'ai développé le script suivant qui trace d'abord une large zone indiquant un itinéraire emprunté. Une fenêtre modale s'ouvre et permet à l'utilisateur de saisir un code pour un lieu précis – dans cet exemple, 1 ou 2. Grâce à ces informations, le graphique zoome sur ce lieu. Tout cela fonctionne bien, mais ce n'est pas exactement ce dont j'ai besoin. Plus important encore, la boîte de dialogue disparaît une fois la sélection effectuée et le script terminé. Ensuite, j'ai essayé de faire fonctionner ce script avec un menu déroulant de type ComboBox. J'arrive à faire fonctionner le menu lui-même, mais pour une raison inconnue, je n'arrive pas à obtenir la possibilité d'effectuer une modification sur le graphique.
Voici ce que j'ai avec la zone de texte modale...
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 )} );
La carte initiale ressemble à ceci...

Et la vue agrandie ressemble à ceci...

Mes dilemmes sont donc les suivants : 1) comment puis-je faire fonctionner la ComboBox avec cela, et 2) comment puis-je empêcher le script de se terminer afin que l'utilisateur puisse continuer à sélectionner différents éléments dans le menu déroulant.
J'ai le sentiment que cela a quelque chose à voir avec la commande Définir la fonction, mais mes multiples tentatives pour que cela fonctionne ont été infructueuses.
Toute orientation à ce sujet serait grandement appréciée.
Merci.
Automatisation et scriptsRé : Modifier dynamiquement la latitude et la longitude dans Graph Builder avec le menu déroulant ComboBoxJe n'utiliserais pas de fenêtre modale pour quelque chose comme ça
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()
)
);
Vous pouvez également déplacer vos options dans un tableau associatif afin de faciliter l'ajout ultérieur d'options supplémentaires.
Ré : Modifier dynamiquement la latitude et la longitude dans Graph Builder avec le menu déroulant ComboBoxMerci, @jthi . C'est parfait.
L'idée est donc d'encapsuler les actions de la ComboBox dans un bloc Eval(), puis d'exécuter ce bloc comme un script lors de l'exécution de la ComboBox. Je pense que j'interprète correctement.
Ré : Modifier dynamiquement la latitude et la longitude dans Graph Builder avec le menu déroulant ComboBoxVous pouvez déplacer l'expression à l'intérieur de la zone de liste déroulante MAIS il est généralement beaucoup plus facile de la modifier si vous la séparez, surtout si vous utilisez la même action à plusieurs endroits
Voir plus...
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()
)
);
Vous pouvez également utiliser << Définir la fonction au lieu de < argument que vous pouvez utiliser, Zone de liste déroulante )
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;
))
)
);