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
HansD
Level I

JSL: add reference lines to Graph Builder Report depending on value of local data filter

GObj = Graph Builder(
	Size(1221, 652),
	Show Control Panel(0),
	Variables(X(:Date), Y(:Close_s)),
	Elements(Box Plot(X, Y, Legend(5))),
	Local Data Filter(Add Filter(columns(:Date, :Name), Where(:Date >= 01Jun2022), Where(:Name == "Anglo American"))),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			OutlineBox,
			{Set Title("Variability Plot Low Close and High values for the day"), Image Export Display(Normal)}
		),
		Dispatch(
			{}, "Close_s",
			ScaleBox// {Min( 100000 ), Max( 200000 ), Inc( 50000 ), Minor Ticks( 4 )
			// Add Ref Line( 130000, "Solid", "Dark Red", "bought", 1 )}
		),
		Dispatch({}, "graph title", TextEditBox, {Set Text("Low, Close & High against date")})
	)
);

I would like to add a reference line depending on the :name value in the data filter. 

I can programmatically add a reference line and remove the line when needed.  But the reference line must depends on the :name value of the data filter.

I will have a Reference line table with a :Name column and reference line values that I can use to match :Name value in data filter

 

DateValue = Date MDY(07, 12, 2022);
Report(GObj)[AxisBox(1)] << {Add Ref Line(DateValue, "Solid", "Blue", "Date Bought", 1)};
Report(GObj)[AxisBox(2)] << {Add Ref Line(130000, "Solid", "Green", "Value Bought", 1)};
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: JSL: add reference lines to Graph Builder Report depending on value of local data filter

If you have reference line table, you could add the reference line column from that to graph builder as Line plot (join or use virtual join to combine data tables).

jthi_0-1663941809499.png

 

Example as script:

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("RefLine", Numeric, Continuous, << Set Each Value(
	If(:sex == "F",
		50
	,
		60
	);
));

gb = dt << Graph Builder(
	Size(542, 587),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height), Y(:RefLine, Position(1)), Group X(:sex)),
	Elements(Points(X, Y(1), Legend(3)), Line(Y(2), Legend(7))),
	Local Data Filter(Add Filter(columns(:sex), Where(:sex == "F"))),
	SendToReport(
		Dispatch({"Points"}, "", OutlineBox, {Close(0)}),
		Dispatch({"Line"}, "", OutlineBox, {Close(0)})
	)
);

If this won't work other (there are more than two) would be to use Filter Change Handler to trigger the plotting. See Scripting Index for examples

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: JSL: add reference lines to Graph Builder Report depending on value of local data filter

If you have reference line table, you could add the reference line column from that to graph builder as Line plot (join or use virtual join to combine data tables).

jthi_0-1663941809499.png

 

Example as script:

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("RefLine", Numeric, Continuous, << Set Each Value(
	If(:sex == "F",
		50
	,
		60
	);
));

gb = dt << Graph Builder(
	Size(542, 587),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height), Y(:RefLine, Position(1)), Group X(:sex)),
	Elements(Points(X, Y(1), Legend(3)), Line(Y(2), Legend(7))),
	Local Data Filter(Add Filter(columns(:sex), Where(:sex == "F"))),
	SendToReport(
		Dispatch({"Points"}, "", OutlineBox, {Close(0)}),
		Dispatch({"Line"}, "", OutlineBox, {Close(0)})
	)
);

If this won't work other (there are more than two) would be to use Filter Change Handler to trigger the plotting. See Scripting Index for examples

-Jarmo
HansD
Level I

Re: JSL: add reference lines to Graph Builder Report depending on value of local data filter

Hi Jthi, thanks for your fast response and solution - I tried your solutions and it works fine.  I will accept this as a solution.  I will investigate your suggested Filter Change Handler further.  I want to a increase the number of reference lines under certain circumstances.  Regards Hans