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

How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

Hi everyone,

I have reached the limitations of my (rather limited) scripting skills and am looking for help.

 

What I am currently trying to do is to create a legend based on "Color by column" or row legend, which is not appended to a certain plot but could be placed in a seperate Outline Box or such.

Reason I am trying to do this is, that I am working on a JSL script which in the end shall retrieve a whole bunch of data from a database and give out a multitude of visualizations for different process steps with mostly different legends. On top, I want to distribute it as an interactive html file. As there will be a lot of graphs and therefore a lot of scrolling, I would love to generate a Outline Box / Scroll Box alignment, where the legend and maybe some written information should stay visible (in a separate part of the window) when scrolling through the graphs.

 

What i succeeded to do so far is copying the Border Box of a generated legend to the clipboard via (One refers to a generic one way plot with a "row legend" installed)

rOne = One << report;
	Link = rone[Owner Box(1)] << parent;
	
	show (Link);
	
	Link << copy picture
		

which copies the legend Border Box to the clipboard. I can paste it to word for example and get exactly what I was looking for. Unfortunately, I can't find a JSL command to paste graphics from the clipboard into a visualization. I tried it via "Get clipboard" in a picture Box Environment, but this command seems only to be working for Text.

 

Does anyone know, whether it is possible to paste graphics from the clipboard?

Alternatively, does anyone have a code sniplet which allows to create a stand-alone legend (I tried to convert it from the row states but didn't get very far with that)?

 

Any help is greatly appreciated.

 

Greets

Malte

3 ACCEPTED SOLUTIONS

Accepted Solutions

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

I'm not sure what you're trying to do exactly, but Get Picture might be what you need. It gives you a picture object that you can then place into a JMP display tree. Here's an example from the Scripting Index:

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = dt << Bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
New Window( "Example", rbiv << Get Picture );

Is that what you're looking for? This will just be a static picture, not interactive.

View solution in original post

ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

It is possible to paste from clipboard using Main Menu("Paste") but it's not very useful (difiicult to control the timing and target with jsl). 

 

Not sure what you want but I'm sure there are better alternatives than to go via the clipboard here.

 

Here is one example that may be useful:

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/big class.jmp");
ow = Report(dt << Oneway(Y(:Height), X(:Age)));

rl = dt << Color By Column(:Age, Make Window With Legend);

nw = New Window("row legend",
    H List Box(Scroll Box(Size(400, 600), V List Box(ow, ow, ow, ow)), rl)
);

// nw << Save Interactive HTML("path/example.html");

 

View solution in original post

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

There are a few places where JMP uses content from the clipboard - usually paired with a way to copy to the clipboard like axis<<Copy Axis Settings and axis<<Paste Axis Settings.

 

For your use case, I would recommend copying or moving the boxes rather than creating an image.  To copy from a Row Legend you might do something like this:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
framebox = rbiv[Frame Box( 1 )];
framebox << Row Legend( "age", color( 1 ), Marker( 1 ) );
subset = dt<<Get Rows Where(:height > 58 & :weight < 95);
w = New Window("Custom Report",
	H List Box(
	Graph Box(FrameSize(300,300),MarkerSeg(:weight[subset], :height[subset],Row States(dt, subset))),
	(biv<<Report)[OwnerBox(1)] << Clone Box;
	)
);

The legend will still convert to an image when exported to HTML, but this keeps everything as JMP display boxes within JMP.  However, you will note that the cloned legend is not clickable like the original legend.  Using RemoveFrom() and InsertInto(), you can rearrange boxes without having to clone them.  This makes a scrollable report similar to what you suggest:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ), by( :age ) );
rbiv = biv[1] << report;
framebox = rbiv[Frame Box( 1 )];
framebox << Row Legend( "sex", color( 1 ), Marker( 1 ) );
// extract legend and report legend = rbiv[OwnerBox(1)]; legendparent = legend<<parent; legendbox = RemoveFrom(legendparent, 1); toprpt = rbiv << Top Parent; fullrpt = RemoveFrom(toprpt, 1);
// rearrange into a scrolled layout toprpt << Append(hlist = HListBox(scrollbox=VScrollBox(800))); InsertInto(scrollbox, fullrpt, 1); InsertInto(hlist, legendbox, 2);

 

View solution in original post

10 REPLIES 10

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

I'm not sure what you're trying to do exactly, but Get Picture might be what you need. It gives you a picture object that you can then place into a JMP display tree. Here's an example from the Scripting Index:

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = dt << Bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
New Window( "Example", rbiv << Get Picture );

Is that what you're looking for? This will just be a static picture, not interactive.

MJE
MJE
Level III

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

Thank you very much for that quick and easy solution @Melanie_J_Drake, although i decided for the more ambitious solution of danschikore :)
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

It is possible to paste from clipboard using Main Menu("Paste") but it's not very useful (difiicult to control the timing and target with jsl). 

 

Not sure what you want but I'm sure there are better alternatives than to go via the clipboard here.

 

Here is one example that may be useful:

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/big class.jmp");
ow = Report(dt << Oneway(Y(:Height), X(:Age)));

rl = dt << Color By Column(:Age, Make Window With Legend);

nw = New Window("row legend",
    H List Box(Scroll Box(Size(400, 600), V List Box(ow, ow, ow, ow)), rl)
);

// nw << Save Interactive HTML("path/example.html");

 

MJE
MJE
Level III

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

Thanks for your input @ms.
I really like the idea to create the legend directly from the data table. That might come in very handy, although at the end of the script, there will be a whole bunch of legend windows floating around...

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

There are a few places where JMP uses content from the clipboard - usually paired with a way to copy to the clipboard like axis<<Copy Axis Settings and axis<<Paste Axis Settings.

 

For your use case, I would recommend copying or moving the boxes rather than creating an image.  To copy from a Row Legend you might do something like this:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
framebox = rbiv[Frame Box( 1 )];
framebox << Row Legend( "age", color( 1 ), Marker( 1 ) );
subset = dt<<Get Rows Where(:height > 58 & :weight < 95);
w = New Window("Custom Report",
	H List Box(
	Graph Box(FrameSize(300,300),MarkerSeg(:weight[subset], :height[subset],Row States(dt, subset))),
	(biv<<Report)[OwnerBox(1)] << Clone Box;
	)
);

The legend will still convert to an image when exported to HTML, but this keeps everything as JMP display boxes within JMP.  However, you will note that the cloned legend is not clickable like the original legend.  Using RemoveFrom() and InsertInto(), you can rearrange boxes without having to clone them.  This makes a scrollable report similar to what you suggest:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ), by( :age ) );
rbiv = biv[1] << report;
framebox = rbiv[Frame Box( 1 )];
framebox << Row Legend( "sex", color( 1 ), Marker( 1 ) );
// extract legend and report legend = rbiv[OwnerBox(1)]; legendparent = legend<<parent; legendbox = RemoveFrom(legendparent, 1); toprpt = rbiv << Top Parent; fullrpt = RemoveFrom(toprpt, 1);
// rearrange into a scrolled layout toprpt << Append(hlist = HListBox(scrollbox=VScrollBox(800))); InsertInto(scrollbox, fullrpt, 1); InsertInto(hlist, legendbox, 2);

 

gzmorgan0
Super User (Alumni)

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

@danschikore, that was really cool. 

 

This is another option, to use a Data Filter Context Box. I think it is a little easier to script and allows multiple filters for the interactive HTML. It does not have the JMP legend, but the data filter is powerful.  An example is provided below.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
nw = New Window( "Shared Local Filter",
	Data Filter Context Box(
		H List Box(
			Current Data Table() << Data Filter( Local, Add Filter( columns( :sex ) )  ),
		ScrollBox(	
			Platform(
				Current Data Table(),
				biv = Bivariate(
					X( :height ),
					Y( :weight ),
					By( :age ),
				)
			)
		)
		)
	)
);

_xxx = biv<< Xpath("//FrameBox");
_xxx << {MarkerSize(6)};
_xxx << RowLegend("sex", color(1), Marker(1)); //this will just be a reminder

nw << Save Interactive HTML("C:/temp/SharedLocalFilter.html");

 @MJE if you really have a lot of reports, instead of a scroll, you might want to consider creating your own HTML interface to interactive HTML pages/files created by JMP.  There are many examples of html search UI's on the internet. 

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

All these answers are great! 

I just wanted to add on to gzmorgan0's suggestion about many Interactive HTML files. One way to create an HTML user interface to reference several Interactive HTML files is to use File > Publish from the JMP's main menu. It will create an HTML user interface with thumbnails for your Interactive HTML reports. It can be automated in JSL using New Web Report. Here's an exerpt from the Scripting Index:

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp", Invisible );
webreport =
New Web Report(
	Add Report(
		Distribution(
			Continuous Distribution(
				Column( :weight )
			),
			Nominal Distribution( Column( :age ) )
		),
		Title( "Distribution Web Report" ),
		Description(
			"This report was created with the sample found in the Scripting Index"
		)
	)
);
file = webreport << Save( "$TEMP" );
If( !Is Empty( file ),
	Web( file )
);

The example adds only one report, but you can add as many as you like. It also saves to a a temp location, but you could set this to a shared network drive, then send the location to your colleagues.

MJE
MJE
Level III

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

Thank you very much, @danschikore. Your solution is great. I had to twist your code a little to fit it into my visualization sheme, but it works really fine.

I'm still having some trouble with the scroll box displays but that rather seems to be some bugs within the interactive html visualization (disappearing data for example; in one particular interesting case the Plots didn't show up in the JMP environment, but did show up (although somewhat distorted) when saved as an interactive html).

 

Your work is greatly appreciated

 

Greets

Malte

Re: How to Paste graphics from clipboard via JSL; alternatively: how to create a stand-alone legend?

Malte,

 

Please send more details on the Interactive HTML issues.

If you're not comfortable sharing with the community, please send me a private message or report the issues to tech support. 

 

Thanks, 

~John