Hi,
I'm trying to find a way to take a snapshot of just the populated cells of a data table (i.e. without any side panels, blank rows at the bottom or blank columns to the right).
I've recently discovered the Data Grid Box display box, which almost enables me to do what I want - but I need a way to size it so that the populated grid of cells completely fills it. I can do this manually by trial and error, but I'd like to do it automatically.
Is this possible? I enclose below a sample script which illustrates what I'm trying to do.
Many thanks
// Start of program;
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Popcorn.jmp" );
dt << close side panel; // I only want to see the data grid;
// First I'll color some cells to illustrate something;
// Any yield less than 9 will be painted red;
CellsToPaint = dt << get rows where(as column(:yield) < 9);
:yield << color cells(RGB Color(1, 0, 0), CellsToPaint);
// Any yield more than 15 will be painted green;
CellsToPaint = dt << get rows where(as column(:yield) > 15);
:yield << color cells(RGB Color(0, 1, 0), CellsToPaint);
// Put it into a Data Grid Box so I can copy it as a picture;
dgb = Data Grid Box( ); dgb << Set Data Table(dt);
// If I don't resize it there will be extra blank rows and columns visible;
// I can shrink it manually - but I want to automate this bit if I can;
dgb << set width(325);
dgb << set height(340);
// Let's see what I've got now;
new window("My Data Grid Box", dgb);
Path = "$DESKTOP/snapshot.png";
dgb << save picture(Path, "png");
// Re-open it inside a picture box;
pb = picture box(open(Path, png));
// And display the final image;
new window("My Snapshot", panelbox("My Snapshot", pb));
// End of program;