Choose Language Hide Translation Bar
Highlighted
vishwasanj
Level V

To copy graphs from journal

Hi All,

 

I have a script that creates a bunch of graphs in journal. I want to put a small box at the bottom of each graph so that I can copy that easily.

 

 

nw = New Window( "Plots",
V List Box(
vc= dt<<Variability Chart(
Y( :Name( "variable" ) ),
X( :WAFER_ID ),
Std Dev Chart( 0 ),
Show Box Plots( 1 ),
SendToReport(
Dispatch(
{"Variable"},
"2",
ScaleBox,
{Min( 48 ), Max( 60 ), Inc( 2 ), Minor Ticks( 1 )}
)
)
),
H List Box(
Button box("Copy Distribution",
vc << copy picture;
)


)
)
);
path= get default directory();
(nw<<parent) << Save Journal(path  || "check.jrn", "jrn" );

 

 

For some reason, it is saving the graph, but when I try to open the journal and click on the button to copy, it says vc not found?

 

Any help is appreciated.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
gzmorgan0
Super User

Re: To copy graphs from journal

I think the request is to create a journal with a button to copy the graph if so desired. My assumption is that clicking the button would allow the user to then use paste to paste the copied picture to a powerpoint doc or some doc.

 

When you create the journal and save it, there no longer is a link to vc nor nw. You need to use a relative reference command. If this is what you want, your script needs to change to <<Set Function(); see below. "this" refers to the button box, Parent is the HListBox and Child is the variability plot.  As Jim mentioned, if this isn't what you want, please add more details.

 

The script below shows one method to manage By variables. 

names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");

nw = New Window( "Plots", <<journal);

vc = dt << Variability Chart(
	Y( :Name( "weight" ) ),
	X( :age ),
	By(:sex),
	Std Dev Chart( 0 ),
	Show Box Plots( 1 )
);
for(i=1,i<=nitems(vc), i++,
  nw << append (HListBox(
  vc[i]<<clone box, 
  ButtonBox("Copy Picture",
    <<Set Function(Function( {this},
	   ((this << Parent) << child) << Copy Picture
      )) /* SetFunction: 'this display box' is first arg */
    ) //Button Box
   ) // HlistBox
 )   //append
);  //for i

vc << close window();

 

View solution in original post

9 REPLIES 9
Highlighted
txnelson
Super User

Re: To copy graphs from journal

The issue is that "vc" points to the Platform, not to the report for the platform.  It is the report that you want to make a copy of.  Change the script for the button to:

Button Box( "Copy Distribution", report(vc) << copy picture )
Jim
Highlighted
vishwasanj
Level V

Re: To copy graphs from journal

Hi Txnelson,

I still get the error "Name Unresolved: vc in access or evaluation of 'vc' , vc/*###*/" after changing it to report(vc).
Highlighted
txnelson
Super User

Re: To copy graphs from journal

This code copies the graph to the clipboard without issue.  When I run this, click on the "Copy Distribution" button and then open a new journal, and do a CNTL/v, the graph is pasted very nicely into the new journal.

names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");
nw = New Window( "Plots",
	V List Box(
		vc = dt << Variability Chart(
			Y( :Name( "weight" ) ),
			X( :age ),
			Std Dev Chart( 0 ),
			Show Box Plots( 1 )
		),
		H List Box(
			Button Box( "Copy Distribution", report(vc) << copy picture )


		)
	)
);
Jim
Highlighted
vishwasanj
Level V

Re: To copy graphs from journal

Thank txnelson for the suggestion.

However, I have a lot of graphs like that and the idea of having that copy distribution is to have a flexible x and y axis, the way you can go up and down in a journal. If I like the graph, I can click on the copy distribution and paste it in the presentation.

Any other idea? I really appreciate all your comments, time and effort. :-)
Highlighted
txnelson
Super User

Re: To copy graphs from journal

I am a bit confused......If you want the button to automatically save the chart to a journal.....the code below will do that....but I am not sure that is what you are actually asking for.

names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");
nw = New Window( "Plots",
	V List Box(
		vc = dt << Variability Chart(
			Y( :Name( "weight" ) ),
			X( :age ),
			Std Dev Chart( 0 ),
			Show Box Plots( 1 )
		),
		H List Box(
			Button Box( "Copy Distribution", jj = current journal();report(vc) << journal )


		)
	)
);
Jim
Highlighted
gzmorgan0
Super User

Re: To copy graphs from journal

I think the request is to create a journal with a button to copy the graph if so desired. My assumption is that clicking the button would allow the user to then use paste to paste the copied picture to a powerpoint doc or some doc.

 

When you create the journal and save it, there no longer is a link to vc nor nw. You need to use a relative reference command. If this is what you want, your script needs to change to <<Set Function(); see below. "this" refers to the button box, Parent is the HListBox and Child is the variability plot.  As Jim mentioned, if this isn't what you want, please add more details.

 

The script below shows one method to manage By variables. 

names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");

nw = New Window( "Plots", <<journal);

vc = dt << Variability Chart(
	Y( :Name( "weight" ) ),
	X( :age ),
	By(:sex),
	Std Dev Chart( 0 ),
	Show Box Plots( 1 )
);
for(i=1,i<=nitems(vc), i++,
  nw << append (HListBox(
  vc[i]<<clone box, 
  ButtonBox("Copy Picture",
    <<Set Function(Function( {this},
	   ((this << Parent) << child) << Copy Picture
      )) /* SetFunction: 'this display box' is first arg */
    ) //Button Box
   ) // HlistBox
 )   //append
);  //for i

vc << close window();

 

View solution in original post

Highlighted
vishwasanj
Level V

Re: To copy graphs from journal

Thank you gzmorgan0 for the reply. This is exactly I want. If I have multiple graphs like vc1, vc2... vc12 in a window put together. Any idea how to loop everything to attach the copy picture icon next to each graph using your idea? Thanks.
Highlighted
gzmorgan0
Super User

Re: To copy graphs from journal

vishwasanj,

 

The script I provided used by variables, since you stated you had multiple graphs. This is not a conducive forum to explain options. My co-authors and I spend 3 chapters on our JSL book* to explain describing, the report structure, how to build interactive displays and the difference between top down  vs. bottom up methods.

  • top down - build the report, then insert controls
  • bottom up - build each graph and control and add it to the report one display at a time

The previously provided script builds the report with one By statement (top down), but builds the journal one graph at a time (bottom up).  The method to use depends upon the status of your report. I like the bottom up method, because you have complete control on where to place the button. The script places it to the right of grpah, but it could be to the left, top or bottom. What is your usage/scenario? Do you have:

  1. a "batch" script that creates a journal of graphs and now you are opening the journal and want to add buttons?
  2. a live window, where each variability chart has its own reference vc1, vc2, ... vc12? Does each vck have one variability plot or multiple plots, due to using By()?
  3. ??

Note when you journal a window (scenario #1), each result is either an OutlineBox() or a ListBox(). So getting the current journal and button placement is trickier than building the button bottoms up.  If you could provide more details of how you are creating your window, then someone on the blog could give you some hints. 

  

*JSL Companion, Applications of the JMP scripting Language, Second Edition, chapters 6, 7, 8

Highlighted
Ilan
Level I

Re: To copy graphs from journal

Hi

 

Is there a way to create a graph, variability chart for exapmle, to add this button to every graph at the varibilty chart(not to journal)? 

 

I am asking that because i need to edit the graph before coping it. 

 

Thanks

Ilan 

Article Labels

    There are no labels assigned to this post.