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
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();
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 )
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 )
)
)
);
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 )
)
)
);
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();
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.
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:
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
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