I have a BorderBox filled with Graph Builder, that I want to save as picture.
I have an "Add Graphics Script" on a FrameBox in it. This script uses 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}
);
)}
)
),
If I open a new window with the BorderBox called "imageForReport" that has this GraphBuilder in it:
window = New Window( "My Report", imageForReport );
and then save the report in the image:
imageForReport << save picture( imgPath, "png" );
everything is fine and everything is working.
But I only need that window to debug on the fly, the final product is the PNG image file.
So for the production version that runs thousands of reports I save on resources and do not open that window.
But in this case the graphic script doesn't work because the first variable (and I guess the rest of them) is not resolved. I get this:
Name Unresolved: marginXmin in access or evaluation of 'marginXmin' , marginXmin/*###*/
in the Log window. How do I fix that without unnecessary opening and closing thousands of windows?
UPDATE:
Here's a sample script to test this behavior:
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" );
If ran as it is - it will open window with the plot and shape in it and it will save PNG image with plot and shape.
If you comment the new window line - it will save plot to PNG image without opening a new window, but the shape will be missing in it.
Can anybody explain it and how to solve it? How to get shape in the saved image without having to open\close new window with the plot?