Break up a Journal into individual graphs?<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I am looking to break a journal up into the individual graphs that make up the journal.
The idea is that I am prompting a user to save graphs, and I would like to be able to save individual graphs from within a journal, rather than the journal as a whole.
Any help is greatly appreciated.
-Matt
Re: Break up a Journal into individual graphs?One approach would be to collect two lists: one of picture boxes and one of titles. Then, if they select the nth title, then output the nth picture box. To get the nth picture box on demand, I think xpath //PictureBoxwould do it.Or use the regular Display Box subscripting: jrn[PictureBox(n)].
Re: Break up a Journal into individual graphs?I have one more question Xan. I am not too familiar with the ancestor/descendant part of the trees.
I now have the user selecting a graph name from the list that was created using
print((jrn << xpath(EvalInsert("descendant::PictureBox[^i^]/ancestor::OutlineBox[1]")))[1] << get title)
From the title they choose, I would like to find the corresponding picture box and save that to a file, instead of all of the picture boxes.
I was thinking of replacing ancestor::OutlineBox[1] with the title of the graph, and the descendant would be PictureBox[1], correct? From that would I be able to save the picture?
Once again, any help is greatly appreciated.
-Matt
Re: Break up a Journal into individual graphs?Great work again Xan, worked like a charm.
The timely response was extremely helpful as well.
Re: Break up a Journal into individual graphs?There is a <
Doing the same with xpath gets a little trickier, but this works in the loop:
print((jrn << xpath(EvalInsert("descendant::PictureBox[^i^]/ancestor::OutlineBox[1]")))[1] << get title)
Re: Break up a Journal into individual graphs?That worked great Xan, thank you very much.
The next hurdle I need to get over is grabbing the title for each graph in the journal. Each graph is wrapped in an outline box, with its title in that. Is there anyway I could call the parent to the PictureBox and grab the text from it?
Thanks again,
Matt
Re: Break up a Journal into individual graphs?Each graph is wrapped in something called a PictureBox, which is how the HTML export knows when to make an image file. You can cycle through the PictureBoxes with display box subscripting, or use XPath:
jrn = Current Journal();
graphs = jrn << xpath( "//PictureBox" );
n = N Items( graphs );
For( i = 1, i <= n, i++,
graphs << Save Picture( "$DOCUMENTS/pic" || Char( i ) || ".png", "png" )
);