Vertical reference line based off of axis label instead of value<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I am attempting to write a script that will auto populate a run chart from a SQL database. The one issue that I am having is automatically adding in a vertical reference line based on the x-axis label. I can make this work with the value but I do not believe this to be suitable for my application. I am hoping to base this off of the label instead of the value as I am anticipating the initial and ending values of my x-axis to change. Since my axis will be a time stamp it will always be a unique identifier. This is the first script I am trying to write so I may have missed something obvious.
Any advice or help is greatly appreciated.
Re: Vertical reference line based off of axis label instead of valueThanks MS! This looks like it will work out well. I will try to modify it this weekend to fit an input field and point it to the selection box.
Thanks to everyone for all of your suggestions!
Re: Vertical reference line based off of axis label instead of valueI have to admit that when I wrote my first response, I was forgetting that the control charts don't use a 'proportional' time axis, so that points are spaced uniformly whatever the actual datetime values in the table. This has implications for how you actually add the reference lines to the 'AxisBox()'. But, as the other responses show, it's still possible to do what you want.
Re: Vertical reference line based off of axis label instead of valueHere are two examples using a date translated into its label for 1) adding a ref line and 2) plotting a subset of data based on user input.
dt = Open("$SAMPLE_DATA/Quality Control/Diameter.jmp");
// get list of unique levels
Summarize(g = by(dt:Day));
//User selects a date
New Window("Select date",
<<modal,
Scroll Box(lb = List Box(g, max selected(1))),
Button Box("OK", mydate = lb << get selected),
Button Box("Cancel")
);
//Translate into label nr
x = Loc(g, mydate[1])[1];
// 1. Control chart with ref line at mydate
cc = Control Chart(
Sample Label(:Day),
KSigma(3),
Chart Col(:DIAMETER, Run Chart())
);
Report(cc)[Axisbox(2)] << add ref line(x);
// 2. Control chart for the two weeks before mydate
dt = In Weeks(2);
cc = Control Chart(
Sample Label(:Day),
Where(Num(g[x]) - dt <= :Day <= Num(g[x])),
KSigma(3),
Chart Col(:DIAMETER, Run Chart())
);
Re: Vertical reference line based off of axis label instead of valueIs your goal to show the location of a process change using a vertical line? If so I would use the a numeric continuous time axis and add vertical lines using the Add Ref Line method, as shown below.


Re: Vertical reference line based off of axis label instead of valueHi Stephen,
I have tried to set the date column to numeric continuous. However, the way that I am attempting to script it does not seem to function this way as the reference line is still based solely off of the value field. How are you specifying a reference line off of a date? With the script listed above, it does not add a reference line for me when I enter it for the value field. Is there a better way to utilize ref line than how I am using it? Or are you using VLine instead of ref line? I am not terribly familiar with JSL, or scripting in general, but I am happy to learn. The JMP scripting guide and I are becoming well acquainted.
As a humble beginner, any help or insight is greatly appreciated.
Re: Vertical reference line based off of axis label instead of valueDid you know you can set your date column properties as Numeric continuous? If you do so then you can specify the line position directly as the desired date. This can then be scripted in to the JSL used to create your graph.
Re: Vertical reference line based off of axis label instead of valueThank you for replying Ian,
What I am attempting to accomplish:
I have been asked to create run charts for several variables on several instruments. These are intended to start two weeks prior to an identified or suspected process change. I do not see this as being a temporary request of me so I am hoping to make a field outside of JMP that the submitter can input their desired date. Then, poof, out pops a generated run chart with a reference line on the date that they have entered sparing me the tediousness of doing this at their beck and call.
My attempt at explaining what I am trying to do in JMP 12.2:
I grabbed the sample data for diameter for demonstration.
Control Chart(
Sample Label( :DAY ),
KSigma( 3 ),
Chart Col( :DIAMETER, Run Chart( Show Center Line( 0 ) ) ),
SendToReport(
Dispatch(
{"Run Chart of DIAMETER"},
"1",
ScaleBox,
{Add Ref Line( 4, "Solid", "Black", "", 1 )}
)
)
)

This works out great when I know what the "x-axis setting" value corresponds to the label. In the script above the 4 from "{Add Ref Line( 4, "Solid", "Black", "", 1 )}" is the date 05/04/1998. This is all good and well if my first value is always the same. However, I will only be dealing with a portion of the data table at a time. I would like to be able to call out the specific label, which happens to be a date, in the script instead of the value. This should allow me to automatically process a run chart for the four weeks prior to the date that is requested of me.
I am hoping that I am missing something obvious or perhaps there is a better way to deal with this problem than I am currently attempting.
Re: Vertical reference line based off of axis label instead of valueAs I think you have discovered, you can add reference lines (and ranges) to an axis, and if it's the horizontal axis such lines would be vertical.
But, from your description, I'm not sure what logic you want to use to position the reference. For example via JSL you can easily determine the date range of the data you just extracted, and then place the line 'half-way along'. Can you be more specific about what you want, please?