Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Break up a Journal into individual graphs?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 9, 2012 8:34 AM
(5851 views)

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

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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" )*

);

6 REPLIES 6

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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" )*

);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Break up a Journal into individual graphs?

There is a <<parent message, but you may have to apply it several times to get to the OutlineBox if there are intervening boxes like ListBox or BorderBox. You can use <<classname to see what type of box you're at.

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)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Break up a Journal into individual graphs?

Great work again Xan, worked like a charm.

The timely response was extremely helpful as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Break up a Journal into individual graphs?