Names Default To Here(1);
dt = Open("$sample_data/big class.jmp", invisible);
workdir = "$temp/deleteme/";// careful! this dir is deleted ...
If(!Directory Exists(workdir),
Create Directory(workdir);
);
nw = New Window("Report Window",
H List Box(
dt << Bivariate(Y(:weight), X(:height), Fit Line),
dt << Oneway(Y(:height), X(:sex), Means(1), Mean Diamonds(1)),
dt << Graph Builder(
Show Control Panel(0),
Variables(X(:Sex), Y(:Height), Group X(:Age)),
Elements(Box Plot(X, Y))
),
dt << get as report
)
);
// For some reason Oneway does create distribution plot twice. Using journal avoids this...
// New Window("", H List Box(pic_boxes[4], pic_boxes[5]));
// using journal conversion will partially break some interactivity, so save them before
nw << Save Interactive HTML(workdir || "test_interactive.html");
nw << Save Interactive HTML(workdir || "test_interactive_static.html", 1); // isStatic
nw << Journal Window;
nw << Close Window;
nw = Current Journal();
nw << Set Window Title("Journaled New Window");
Main Menu("Edit:Lock Journal", nw << Get Window Title);
// get html string from journal
html_str = nw << Get html;
// use xpath to get references to all pictureboxes
pic_boxes = nw << XPath("//PictureBox"); // for some reason in this case, last picturebox is found twice
// in basic html pictureboxes will be replaced by Picture Ignored string
pic_ignored_count = N Items(Words(Substitute(html_str, "Picture ignored", "¤"), "¤")) - 1; // only works if there are no ¤ in string
pics = pic_boxes << get picture;
For Each({cur_pic, idx}, pics,
{w, h} = cur_pic << get size;
base64compressed_str = Arg(Arg(parse(Char(cur_pic)), 1), 1);
base64_str = Encode64 Blob(Gzip Uncompress(Char To Blob(base64compressed_str, "base64compressed")));
// clean some <BR /> to make nicer looking html
html_str = Munger(html_str, idx, "<BR />\!NPicture ignored<BR />\!N<BR />", Eval Insert("<IMG src="\!" image="" />"));
);
// change background color to something a bit less blinding than white
// some grayish ones with names: gainsboro, whitesmoke, oldlace, silver, darkgray. https://www.w3.org/wiki/CSS/Properties/color/keywords
// for JMP's WHITE THEME color use rgb(248,248,248)
// for JMP's GRAY THEME color use rgb(219,224,227), most likely not the best idea, as some fonts and other backgrounds should also be changed
Substitute Into(html_str, "body { ", "body { background-color:whitesmoke;,");
nw << Save Interactive HTML(workdir || "test_interactive_journal.html");
nw << Save Interactive HTML(workdir || "test_interactive_static_journal.html", 1); // isStatic
filename = Save Text File(workdir || "test_embedded.html", html_str); // save the embedded version
nw << Close Window;
Close(dt, nosave);
Open(workdir);