cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
tom_abramov
Level V

Graph Builder JSL commands on Elements

Hello,

I can't find the syntax of editing (add element/remove element/add labels to element) graph builder elements after the graph is ready.

 

Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Size( 465, 278 ),
	Show Control Panel( 0 ),
	Fit to Window( "Off" ),
	Variables( X( :age ), Y( :height ), Y( :weight ) ),
	Elements( Position( 1, 1 ), Line( X, Y, Legend( 1 ) ) ),
	Elements( Position( 1, 2 ), Bar( X, Y, Legend( 2 ) ) )
);

//gb[Elements(2)] << Label( "Label by Value" );// ?? // What is the sytax fo this?

//gb << Add Element(Position( 1, 3 ), Line( X, Y, Legend( 3 ) ));// ?? //Y have to be weight

 

Thanks

 

7 REPLIES 7
txnelson
Super User

Re: Graph Builder JSL commands on Elements

I don't think it can be done.  What you would have to be able to do, is to pass to the FrameBox() in the output, a Segment, such as a Bar Seg, or a Line Seg.  

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
obj = Graph Builder( Variables( X( :age ), Y( :weight ) ), Elements( Bar( X, Y ) ) );
frame = Report( obj )[FrameBox( 1 )];
seg = (frame << Find Seg( "Bar Seg" ));
seg << Get Width Proportion();
seg << Set Fill Color( "Green" );

You can interactively change the segments, in the Customize selection when you right click on the graph, and there is no label segment.

cum2.PNG

Jim
tom_abramov
Level V

Re: Graph Builder JSL commands on Elements

Bad for me...

Thank you Jim.

txnelson
Super User

Re: Graph Builder JSL commands on Elements

@tom_abramov 

A thought just popped into my head, and there is one way around this......This is a solution I have used many times for different reasons.  What I suggest you do, is to write your code, so that what you do, is when you need to add the elements that you are referencing, you simply delete the entire graph and recreate it in it's place.  The way JMP handles refresh, it will probably not show the change when the graph is deleted.  It will probably just see that the graph has changed.

The code below illustrates my idea.

names default to here(1);
Open( "$SAMPLE_DATA/Big Class.jmp" );
new window("Test", vlb=vlistbox());
vlb<< append(gb = Graph Builder(
	Size( 465, 278 ),
	Show Control Panel( 0 ),
	Fit to Window( "Off" ),
	Variables( X( :age ), Y( :height ), Y( :weight ) ),
	Elements( Position( 1, 1 ), Line( X, Y, Legend( 1 ) ) ),
	Elements( Position( 1, 2 ), Bar( X, Y, Legend( 2 ) ) )
));

wait(5);
gb << delete;
vlb << append(gb = Graph Builder(
	Size( 465, 278 ),
	Show Control Panel( 0 ),
	Fit to Window( "Off" ),
	Variables( X( :age ), Y( :height ), Y( :weight ) ),
	Elements( Position( 1, 1 ), Line( X, Y, Legend( 1 ) ) ),
	Elements(
		Position( 1, 2 ),
		Bar( X, Y, Legend( 2 ), Label( "Label by Value" ) )
	)
));
Jim
gzmorgan0
Super User (Alumni)

Re: Graph Builder JSL commands on Elements

@tom_abramov ,

 

I tooka a different long path, like Jim, @txnelson .  Then I had to laugh, because JMP has a simple solution with the message 

Update Element() sent to the GraphBuilderBox()

Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Size( 465, 278 ),
	Show Control Panel( 0 ),
	Fit to Window( "Off" ),
	Variables( X( :age ), Y( :height ), Y( :weight ) ),
	Elements( Position( 1, 1 ), Line( X, Y(1), Legend( 1 ) ) ),
	Elements( Position( 1, 2 ), Bar( X, Y(2), Legend( 2 ) ) )
);


gbb = report(gb)[GraphBuilderBox(1)];
gbb<< Update Element(1,2,1, {Label("Label by Value")});


/* //hard way not recommended

//must be done while No Labels is specified

gb<< show Control Panel(1);
so_bar = report(gb)[OutlineBox("Bar[weight]")];

cb_label = so_bar << xpath("//ComboBox/ComboBoxItem[text()='No Labels']/..");

cb_label << set(2);

gb << show Control panel(0);

*/

However, I am running into an issue by adding variable :weight which is easy to do, but by default, GraphBuilder make another bar chart element.  and I get into some screwy issues, several JMP  exceptions.

 

I will add a wish list item that JMP allows a Change To() message for elemnets, not just Add Element and Remove Element.

 

I'll add to the post when/if I figure it out.

gzmorgan0
Super User (Alumni)

Re: Graph Builder JSL commands on Elements

@tom_abramov ,

 

It was me, a user syntax error.  Her you go.

Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Size( 465, 278 ),
	Show Control Panel( 0 ),
	Fit to Window( "Off" ),
	Variables( X( :age ), Y( :height ), Y( :weight ) ),
	Elements( Position( 1, 1 ), Line( X, Y(1), Legend( 1 ) ) ),
	Elements( Position( 1, 2 ), Bar( X, Y(2), Legend( 2 ) ) )
);


gbb = report(gb)[GraphBuilderBox(1)];
gbb<< Update Element(1,2,1, {Label("Label by Value")});


report(gb)[GraphBuilderBox(1)] << Add Variable({:weight, Role("Y"), Method("insert")}); //creates a bar chart
gbb = report(gb)[GraphBuilderBox(1)];
gbb << Add Element( 1, 3 , {Type("Line"), X, Y}, Legend( 3 ) ); 
gbb << Remove Element( 1, 3 , 1 );  //remove bar chart
tom_abramov
Level V

Re: Graph Builder JSL commands on Elements

Thank you very much both of you.

"GraphBuilderBox" is the keyword...

hogi
Level XI

Re: Graph Builder JSL commands on Elements

Since Jmp17 :)

Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Size( 465, 278 ),
	Show Control Panel( 0 ),
	Fit to Window( "Off" ),
	Variables( X( :age ), Y( :height ), Y( :weight ) ),
	Elements( Position( 1, 1 ), Line( X, Y(1), Legend( 1 ) ) ),
	Elements( Position( 1, 2 ), Bar( X, Y(2), Legend( 2 ) ) )
);

gb << Update Element(1,2,1, {Label("Label by Value")});

gb << Add Variable({:weight, Role("Y"), Method("insert")}); //creates a bar chart

gb << Add Element( 1, 3 , {Type("Line"), X, Y}, Legend( 3 ) ); 
gb << Remove Element( 1, 3 , 1 );  //remove bar chart