cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
hhggzz
Level I

Custom Annotation Based on Framebox content

I would like to add an annotation to each individual frame of a graph builder report.  Here is a (trivial) example...

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder( Variables( X( :height ), Y( :weight ), Group X( :sex ), Group Y( :age ) ) );
gb << SendToReport( Dispatch( {}, "Graph Builder", FrameBox, Add Text Annotation( Text( "Female-12" ), Filled( 0 ) ) ) );

 

 

2022-07-13_11-48-56.jpg

 

 

 

 

 

 

 

 

 

In this example above, the top left Framebox has an annotation "Female-12" in it.    This was done in a hard coded way.  I would like to add an annotation to each Frame based on the grouping of data in that frame.  

 

Ideally, I'd like to know what the X-group and Y-group is for each framebox and compose an annotation based on that and add it to each Framebox.

 

Ideally, I'd like to also redo these annotations after a change has been made to the local data filter in case the assignment of Framebox # to grouping changes as someone clicks through the local data filter.

 

So - how do I figure out which data is in each framebox?

 

4 REPLIES 4
jthi
Super User

Re: Custom Annotation Based on Framebox content

Groupings in graph builder are a bit annoying to work with, but... you should know the order based on the datatable and you also know the grouping columns you have. With that information you might be able to create the annotations

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(Variables(X(:height), Y(:weight), Group X(:sex), Group Y(:age)));

Summarize(dt, uniq = By(:sex, :age));
For Each({{a, b}, idx}, Across(uniq[1], uniq[2]),
	frame = (gb << report)[FrameBox(idx)];
	frame << Add Text Annotation(Text(Eval Insert("^a^ - ^b^")));
);

jthi_0-1657739938628.png

With Local Data Filter you might have to parse the Where statement and use that information to get correct groups.

This topic might have some additional ideas Identifying Titles of Graph Builder Page Titles 

-Jarmo
txnelson
Super User

Re: Custom Annotation Based on Framebox content

Here is how I would handle it

Names Default To Here( 1 );
//This message applies to all display box objects
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

gb = Graph Builder(
	Size( 567, 496 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ), Group X( :sex ), Group Y( :age ) ),
	Elements( Points( X, Y, Legend( 11 ) ), Smoother( X, Y, Legend( 12 ) ) )
);
rgb = Report( gb );

rgb[FrameBox( 1 )] << Add Text Annotation(
	Text( "Text for FrameBox(1)" ),
	Fixed Size( 0 ),
	Text Box( {-1, 5, 138, 32} ),
	Filled( 0 )
);
rgb[FrameBox( 7 )] << Add Text Annotation(
	Text( "Text for FrameBox(7)" ),
	Fixed Size( 0 ),
	Text Box( {-1, 0, 138, 27} ),
	Filled( 0 )
);

txnelson_0-1657741352017.png

 

Jim
hhggzz
Level I

Re: Custom Annotation Based on Framebox content

While your example shows how to add an annotation to each framebox,  the question I am asking is how to find out Y-grouping and X-grouping is in that framebox.

 

txnelson
Super User

Re: Custom Annotation Based on Framebox content

I do not know the answer to that.  I always have worked it by knowing what the X and Y groupings are and then going from there.  I suspect you could retrieve the script from the object, and then strip out the Group X and Group Y columns, and go from there.

Jim