cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
newbie_alex
Level III

Graph Builder, how to change the color of an element, and information about SendToReport syntax

Hello,

 

I create a graph with dynamic content (number of variables is determined at run time).

 

I would like to change to change several things after setting up the graph builder, e.g. assign a new color. The reason for doing it afterwards is because, I do not know the changes before executing other parts of my script that I cannot run earlier.

 

I have simplified my basic problem to this example:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

gb = Graph Builder(
	Automatic Recalc( 0 ),
	Variables( X( :age ), Y( :height ) ),
	Elements( Points( X, Y ), Smoother( X, Y ) )
);

// do some other stuff incl. addition or removal of variables to gb

// how do I *MODIFY* the color of Points, Smoother here or add a Line Plot?

I know the position of the variables in the graph if that helps (1,1 in the example above).

 

Cheers,

Alex

 

 

11 REPLIES 11

Re: how to change the color of a line

Hi Alex,

Sorry for the delayed response. 

Say you have the following Legend Model message being sent.

Legend Model( 2, Properties( 1, {Line Color( 4 )} ) )
  • The first argument (2) is a unique ID refering to a specific Legend Model within the ScaleBox. In the above example, a value of 1 would refer to the Legend Model containing the points, while a value of 2 points to the smoother lines.
  • The second argument (Properties( 1, {Line Color( 4 )} )) contains information about which element within the Legend Model to apply a given set of properties.
    • The first argument within Properties (1) is a zero-based item number to identify which item to apply the new property.
    • The second argument within Properties ({Line Color( 4 )}) is a list of properties to apply to a given Legend Model item. In this case, we are changing the line color to green.

Here are a few examples:

The following script sets the first item in the first legend model (points) to be green. In this case, the first item is "F."

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
gb = dt << Graph Builder(
	Show Control Panel( 0 ),
	Grid Transparency( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model( 1, Properties( 0, {Line Color( 4 )} ) )}
		)
	)
);

(From here on out, I will just give the Legend Model portion to replace in the above script)

 

The following Legend Model snippet will change the color of the second item ("M") within the points legend model.

Legend Model( 1, Properties( 1, {Line Color( 4 )} ) )

The following Legend Model snippet will change the color of the first item ("F") within the smoother line legend model.

Legend Model( 2, Properties( 0, {Line Color( 4 )} ) )

The following Legend Model snippet will change the color of the second item ("M") within the smoother line legend model.

Legend Model( 2, Properties( 1, {Line Color( 4 )} ) )

NOTE:  changing the line color of the smoother line also will change the color of the corresponding points, but changint the point color of the points does not affect the color of the associated smoother line.

 

Justin
hogi
Level XII

Re: how to change the color of a line

Hi @Justin_Chilton , which additional identifiers are used for the Element Names besides helpKey and charID?

 

When I change an axis label, the JSL code reads

gb << SendToReport( Dispatch( {}, "X Title", TextEditBox, {Set Text( "new" )} ))

... but X title doesn't show up in the XML code of the Display tree. Which identifier is it?

 

Talking to Display boxes