Affichage d'un graphique lors de l'exécution d'un scriptSalut. J'ai créé un script pour ma table et j'espère que lorsque je clique avec le bouton droit sur "Exécuter le script", il exécutera mon script et affichera des graphiques. Cependant, lorsque j'exécute mon code principal, les graphiques s'affichent automatiquement et lorsque je clique avec le bouton droit de la souris sur "Exécuter le script", cela ne fait rien. J'aurais besoin de votre aide pour signaler l'erreur sur mon code. Merci.
Vous trouverez ci-dessous une section du code long.
aGraph = Graph Builder(
Size( xSize, ySize ),
Show Control Panel( 0 ),
Variables( X( :V ), Y( :I ), Overlay( :PID ) ),
Elements( Points( X, Y, Legend( 4 ), Jitter( 1 ) ), Line( X, Y, Legend( 6 ), Row order( 0 ), Summary Statistic( "Mean" ) ) ),
SendToReport(
Dispatch( {}, "ID", ScaleBox, {Scale( "Log" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )} ),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 ), Line Width Scale( 0.1 )} )
)
);
bGraph = Graph Builder(
Size( xSize, ySize ),
Show Control Panel( 0 ),
Variables( X( :V ), Y( :I ), Overlay( :PID ) ),
Elements( Points( X, Y, Legend( 3 ), Jitter( 1 ) ), Line( X, Y, Legend( 5 ), Row order( 0 ), Summary Statistic( "Mean" ) ) ),
SendToReport(
Dispatch( {}, "IG", ScaleBox, {Scale( "Linear" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )} ),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 ), Line Width Scale( 0.1 )} )
)
);
// Create new script
dt << New Script(
"Plot Graph",
graphWindow = New Window( "Graphs",
Panel Box( "Graphs",
V List Box(
H List Box(
If( !Is Empty( aColumns ),
aGraph
),
If( !Is Empty( bColumns ),
bGraph
)
)
)
)
)
);Re : Affichage d'un graphique lors de l'exécution d'un scriptLe problème est celui de l'espace de noms.Votre script qui a été intégré dans la table de données stocke et obtient des variables de mémoire dans un emplacement de mémoire (espace de noms) différent de celui du script exécuté à partir de votre fenêtre de script.Cependant, vous pouvez créer un espace de noms global que les deux scripts peuvent utiliser.
Donc, si vous avez le code dans votre script intégré pour définir la taille pointant vers l'espace mémoire global ... disons que nous appelons cet espace "gspace", le code de votre script intégré serait
size(gspace:xSize,gspace:ySize),
et vous exécuteriez dans votre fenêtre de script ouverte
gspace = new namespace("GSpace");
gspace:xSize = 800;
gspace:ySize = 600;
Ensuite, lorsque vous exécutez le code intégré, il trouvera les variables gSpace
Re : Affichage d'un graphique lors de l'exécution d'un script@txnelson ,
Merci cela a fonctionné. Cependant, j'ai une question de suivi... les variables de mon script : xSize, ySize, aColumns et bColumns contiennent des valeurs en dehors du nouveau script. Cependant, lorsque le nouveau script est exécuté, les valeurs ne sont pas transmises à l'intérieur de l'expression. J'ai toujours du mal avec Eval et Expr. Pouvez-vous également m'aider à indiquer comment résoudre ce problème ?
Re : Affichage d'un graphique lors de l'exécution d'un scriptLe code agraph et bgraph doit faire partie du script.Vous trouverez ci-dessous une version qui génère un script qui exécutera ce dont vous avez besoin.
Names Default To Here( 1 );
dt = Current Data Table();
// Create new script
dt << New Script(
"Plot Graph",
aGraph = Expr(
Graph Builder(
Size( xSize, ySize ),
Show Control Panel( 0 ),
Variables( X( :V ), Y( :I ), Overlay( :PID ) ),
Elements(
Points( X, Y, Legend( 4 ), Jitter( 1 ) ),
Line( X, Y, Legend( 6 ), Row order( 0 ), Summary Statistic( "Mean" ) )
),
SendToReport(
Dispatch(
{},
"ID",
ScaleBox,
{Scale( "Log" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )}
),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 ), Line Width Scale( 0.1 )} )
)
)
);
bGraph = Expr(
Graph Builder(
Size( xSize, ySize ),
Show Control Panel( 0 ),
Variables( X( :V ), Y( :I ), Overlay( :PID ) ),
Elements(
Points( X, Y, Legend( 3 ), Jitter( 1 ) ),
Line( X, Y, Legend( 5 ), Row order( 0 ), Summary Statistic( "Mean" ) )
),
SendToReport(
Dispatch(
{},
"IG",
ScaleBox,
{Scale( "Linear" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )}
),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 1 ), Line Width Scale( 0.1 )} )
)
)
);
graphWindow = New Window( "Graphs",
Panel Box( "Graphs",
V List Box(
H List Box(
If( !Is Empty( aColumns ),
aGraph
),
If( !Is Empty( bColumns ),
bGraph
)
)
)
)
);
);