- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Dynamic Reference Lines in Graph Builder
I am trying to (simply) create custom reference lines and areas in Graph Builder so when I use a local data filter the references dynamically adjust to the data being presented. In the attached there are two "Model Types" (A and B) and the saved script shows the reference areas for Model Type B. When you select "A" using the local data filter, the graph changes but, of course, the references (having been set manually using axis reference ranges) does not change.
I have tried adding columns to represent the ranges and pointing to those from the script you can add by right clicking the graph area. But these scripts (to my knowledge) don't allow pointing to a column. It seems a simple way would be to add a reference to the axis (per usual) but have a "dynamic" option that would let you script the reference lines (in the form of Y = mX + B, and of course curvilinear versions) or script reference ranges, with either option pointing to columns or able to calculate the line/range on the fly based on available data that may not be one of the graph variables but would be one of the table variables.
All help greatly appreciated. JMP support punted on this and suggested I post here.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Dynamic Reference Lines in Graph Builder
What I would suggest is adding new columns to your table and then using those in the graph. Usually this is most flexible option (in my opinion), if it fits your need, BUT it can be very annoying to build in graph builder.
With this method you can also view all your Model Types at the same time if needed by using X/YGroup (or Page)
I added new column for Mean, green top/bottom and yellow top/bottom (just some mean +/- sigma limits in my example)
Using Filter Change handler to set reference lines is other option or you could write graphic script which should be able to handle this but can be complicated to figure out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Dynamic Reference Lines in Graph Builder
Most likely what you are looking for is adding multiple line charts to same graph builder (I think I had four in that example: yellow fill, green fill, mean and line between points). You can do it with right click and Add -> Line and then modify the settings as needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Dynamic Reference Lines in Graph Builder
This can be done with a Filter Change handler:
dt = current data table();
gb = dt << Graph Builder(
Size( 707, 814 ),
Variables( X( :Date ), X( :Day of Week, Position( 1 ) ), Y( :FP Rate ) ),
Elements(
Line( X( 1 ), X( 2 ), Y, Legend( 4 ) ),
Points( X( 1 ), X( 2 ), Y, Legend( 5 ) )
)
);
ldf = gb << Local Data Filter(
Add Filter( columns( :Model Type ), Where( :Model Type == "B" ) )
);
f = function ({a},myrows =ldf << Get Filtered Rows;
myData =dt [myrows, "FP Rate"];
myMean = mean(myData);
mystdDev = std dev (myData);
y1 = myMean - 2 * mystdDev;
y2 = myMean + 2 * mystdDev;
// remove old ref lines
Eval(Eval Expr(report(gb)[AxisBox(2)] <<Remove Ref Line( Expr(Eval List({0, y1 old})))));
Eval(Eval Expr(report(gb)[AxisBox(2)] <<Remove Ref Line( Expr(Eval List({y1 old, y2 old})))));
Eval(Eval Expr(report(gb)[AxisBox(2)] <<Remove Ref Line( Expr(Eval List({y2 old,1})))));
// add new ref lines
report(gb)[AxisBox(2)] << {Add Ref Line( {0, y1}, "Solid", "Light Yellow", "", 1, 0.25 ),
Add Ref Line( {y1, y2}, "Solid", "Green", "", 1, 0.25 ),
Add Ref Line( {y2, 1}, "Solid", "Light Yellow", "", 1, 0.25 )
};
y1 old = y1;
y2 old = y2;
);
// gets trigger if user changes the selection
x = ldf << Make Filter Change Handler(f);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Dynamic Reference Lines in Graph Builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Dynamic Reference Lines in Graph Builder
What I would suggest is adding new columns to your table and then using those in the graph. Usually this is most flexible option (in my opinion), if it fits your need, BUT it can be very annoying to build in graph builder.
With this method you can also view all your Model Types at the same time if needed by using X/YGroup (or Page)
I added new column for Mean, green top/bottom and yellow top/bottom (just some mean +/- sigma limits in my example)
Using Filter Change handler to set reference lines is other option or you could write graphic script which should be able to handle this but can be complicated to figure out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Dynamic Reference Lines in Graph Builder
I've been able to pretty easily recreate this with the exception of what I think you hint at with your "BUT" statement. When I add, say, the high and low yellow lines, they get included in the same "line" control panel so changing fill there, of course, changes fill for all variables The thing I can't seem to find on the web is how to add a new line control panel so I can use "fill between" for the yellow reference lines but "none" for the main data line. Can you point me in the right direction? And thank you for your help. This will solve the problem if I can figure out how to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Dynamic Reference Lines in Graph Builder
Most likely what you are looking for is adding multiple line charts to same graph builder (I think I had four in that example: yellow fill, green fill, mean and line between points). You can do it with right click and Add -> Line and then modify the settings as needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Dynamic Reference Lines in Graph Builder
jthi,
Of course minutes after I posted I figured it out. For others, the answer is add all the variables you want to the Y axis, right click in the graph field, select "Add…" from the context menu and add, for example, another line. Repeat as needed. Then, in the element control panels on the left of the graph, turn on/off the variables you need for each range and select "Fill between." Then adjust colors, etc. as usual.