- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
JSL - get open graphs X and Y values
Hello
I have a script that lets me pick in a combo box any data table that is open
If I have a data table that has graphs under it
how can I select this graphs?
the reason is that I want to get their X and Y columns names
for example in the first graph that is marked in the picture above I want to get test and test2
this graphs are already open in JMP and I don't have control over them (in terms of editing the script that creates them)
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL - get open graphs X and Y values
Given that you didn't have control of the JMP session before you run the code that you want to write, you could try this kind of approach:
NamesDefaultToHere(1);
tableOfInterest = "Big Class";
allWindows = GetWindowList();
tableWindows = {};
for (w = 1, w <= NItems(allWindows), w++,
winTitle = allWindows[w] << GetWindowTitle;
if (StartsWith(winTitle,tableOfInterest) & (allWindows[w] << WindowClassName) == "Report", InsertInto(tableWindows, allWindows[w]));
);
for (w = 1, w <= NItems(tableWindows), w++,
Print(tableWindows[w] << GetWindowTitle);
);
Use 'Help > Scripting Index' to see how the various commands work.
Once you have the list of child reports, you can inspect each to pull out whatever you want. But bear in mind that the report trees can be complex, so this might take some work to make it sufficiently robust.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL - get open graphs X and Y values
Given that you didn't have control of the JMP session before you run the code that you want to write, you could try this kind of approach:
NamesDefaultToHere(1);
tableOfInterest = "Big Class";
allWindows = GetWindowList();
tableWindows = {};
for (w = 1, w <= NItems(allWindows), w++,
winTitle = allWindows[w] << GetWindowTitle;
if (StartsWith(winTitle,tableOfInterest) & (allWindows[w] << WindowClassName) == "Report", InsertInto(tableWindows, allWindows[w]));
);
for (w = 1, w <= NItems(tableWindows), w++,
Print(tableWindows[w] << GetWindowTitle);
);
Use 'Help > Scripting Index' to see how the various commands work.
Once you have the list of child reports, you can inspect each to pull out whatever you want. But bear in mind that the report trees can be complex, so this might take some work to make it sufficiently robust.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL - get open graphs X and Y values
Thanks for the help
I now want to get the X Y values (what's marked in red) but I'm not sure how to access that value
all I'm able to do is get the title (what's marked in yellow).
I found that with "get XML" instead of "get Text" does give me also the names, but there is ALOT of data there and I hope there is an easier way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JSL - get open graphs X and Y values
Here is an approach that uses the JSL written by the platform (in this case, Graph Builder) to find the elements.I include it to illustrate the following:
- expr ( )
- name expr ( )
- arg ( )
- head ( )
- << get scriptable object (this returns the Graph Builder object from which you obtain the script)
You'll want to read up on these in the scripting guide if you've not used them before. They're powerful but require some practice.
Since I have not put any conditionals in (you'd want to do that... check window names, etc.), do the following to make sure the script works as written below.
1) Close current reports and graphs.
2) Create a Graph Builder graph.
3) Run the script below in a script window. (You could also wrap this in an external loop to cycle through more than one graph window. Again, this is just a skeletal script meant to illustrate the overall idea.)
Cheers,
Brady
Names Default To Here( 1 );
winList = Get Window List( Type( "reports" ) );
obj = winlist[1][Outline Box( 1 )] << Get Scriptable Object;
script = obj << get script;
i = 1;
//move through the script's arguments until you get to the Variables ( ) argument.
While( Head( exp = Arg( Name Expr( script ), i ) ) != Expr( Variables ), i++ );
xList = ylist = {};
nexp = name expr ( exp ); //optional; this allows us to type nexp instead of name expr ( exp ) in the code below.
//cycle through the arguments in the Variables ( ) section. If X ( ) or Y ( ) is
//encountered, insert into the appropriate list.
For( i = 1, i <= N Arg( nexp ), i++,
If( Head( var = Arg( nexp, i ) ) == Expr( X ), Insert Into( xList, Arg( Name Expr( var ), 1 ) ));
If( Head( var = Arg( nexp, i ) ) == Expr( Y ), Insert Into( yList, Arg( Name Expr( var ), 1 ) ));
);
Show( xList, yList );