J'ai une BorderBox remplie de Graph Builder, que je souhaite enregistrer en tant qu'image.
J'ai un script "Add Graphics Script" sur une FrameBox. Ce script utilise des variables :
dt << Graph Builder(
Size( 600, 400 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Title Alignment( "Right" ),
Variables( X( :X ), Y( :Y ), Overlay( :Overlay ) ),
Elements(
Contour( X, Y, Legend( 5 ), Number of Levels( 18 ), Smoothness( -0.8899 ) ),
Points( X, Y, Legend( 4 ) )
),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Marker Size( 1 ), Add Graphics Script(
Transparency( 0.5 );
Fill Color( "Green" );
Pen Color( "Dark Green" );
Line(
{marginXmin, marginYmin},
{marginXmin, marginYmax},
{marginXmax, marginYmax},
{marginXmax, marginYmin}
{marginXmin, marginYmin}
);
)}
)
),Si j'ouvre une nouvelle fenêtre avec la BorderBox appelée « imageForReport » qui contient ce GraphBuilder :
window = New Window( "My Report", imageForReport );
et puis enregistrez le rapport dans l'image :
imageForReport << save picture( imgPath, "png" );
tout va bien et tout fonctionne.
Mais je n'ai besoin que de cette fenêtre pour déboguer à la volée, le produit final est le fichier image PNG.
Donc, pour la version de production qui exécute des milliers de rapports, j'économise des ressources et n'ouvre pas cette fenêtre.
Mais dans ce cas, le script graphique ne fonctionne pas car la première variable (et je suppose que les autres) n'est pas résolue. J'obtiens ceci :
Name Unresolved: marginXmin in access or evaluation of 'marginXmin' , marginXmin/*###*/
dans la fenêtre Journal. Comment puis-je résoudre ce problème sans ouvrir et fermer inutilement des milliers de fenêtres ?
MISE À JOUR:
Voici un exemple de script pour tester ce comportement :
Clear Log();
Clear Symbols();
Clear Globals();
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
cutOutX = 20;
cutOutY = 3;
marginXmin = 70;
marginXmax = 160;
marginYmin = 55;
marginYmax = 65;
imageForReport = Border Box(
VLBox = V List Box(
//Zero row
headerTB = Text Box( "Test savingimage" ),
gb = Graph Builder(
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 6 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Marker Size( 1 ), Add Graphics Script(
Transparency( 0.5 );
Fill Color( "Green" );
Pen Color( "Dark Green" );
Line(
{marginXmin, marginYmin},
{marginXmin, (marginYmax - cutOutY)},
{(marginXmin + cutOutX), (marginYmax - cutOutY)},
{(marginXmin + cutOutX), marginYmax},
{(marginXmax - cutOutX), marginYmax},
{(marginXmax - cutOutX), (marginYmax - cutOutY)},
{marginXmax, (marginYmax - cutOutY)},
{marginXmax, marginYmin},
{marginXmin, marginYmin}
);
)}
)
)
)
)
);
window = New Window( "My Report", imageForReport );
imageForReport << save picture( "C:\temp\testImage.png", "png" );S'il est exécuté tel quel, il ouvrira une fenêtre contenant le tracé et la forme et enregistrera l'image PNG avec le tracé et la forme.
Si vous commentez la nouvelle ligne de fenêtre, le tracé sera enregistré dans l'image PNG sans ouvrir une nouvelle fenêtre, mais la forme y sera manquante.
Quelqu'un peut-il l'expliquer et comment le résoudre ? Comment obtenir une forme dans l'image enregistrée sans avoir à ouvrir/fermer une nouvelle fenêtre avec le tracé ?