BookmarkSubscribeSubscribe to RSS Feed

fit a spline with a variable


Occasional Contributor


May 21, 2018


I build a chart with dinamic legend that the user can choose by radio box.

The name of the legend that the user choose is saved as 'L1' variable.

I want to add a function that when a user clicks on one value from the legend the spline of this value become more bold.

I add a state handler to the file and tried to use this script:


rsh1 = test1 << Make Row State Handler( dt, rsupdate1 );

rsupdate1 =function({},
SplineSelectlist=dt:L1[dt<<get selected rows];
// MYSPLINE=EVAL(SplineSelect);
box8<<Fit Where(
:eval(L1) == eval(SplineSelect),
Fit Spline(
{Line Width( 5 )}


The 'fit where' state doesnt recognize the variable.

I also tried with 'parse' or without 'eval' or to define the variable before-

mycolumn= eval(L1);

but none of them work.


I will be glad to hear if there's a solution to this.

 Thank you.


Community Trekker


Jul 25, 2016

There is not enough information here to respond, and there are some syntax issues.


Does the graph have splines already drawn and you want the selected item highlighted?

Are you using GraphBuilder or Bivariate (Fit Y by X)?


:eval(L1) is not proper syntax.





Community Trekker


Jul 25, 2016

Since no more information was provided, I am guessing at what you need. Maybe you only needed to make your spline statement using and expresssion.   This script allows one or multiple legend values to be selected. It uses:

  • The default linking of an invisible summary table to manage legend selections. This invisible table is closed when the bivariate is closed.
  • A rowstate handler function to clear out previous splines and only show those selected from the legend. 
  • It's been tested on JMP14.1 and JMP13.21.



Names Default to Here(1);

dt0 = Open("$sample_data/");

//create a smaller table too many groupings
dt0 << Select Where( :Region=="Plains" | :Region=="South");
dt = dt0 << Subset(All Columns, Output Tablename("SomeStates"));


//change Year from Ordinal to Continuous to create a Bivariate report
dt:Year << Set Modeling Type("Continuous");  

//The legend column is hardcoded. It seemed like you know how to do that.
//I created a new column just for interest
gCol = dt << New Column("Region_State", character);
gcol << set each value( substr(:Region,1,1) || "_" || :State);
dt << Color by Column(:Region);

//Create the Bivariate report
biv = dt <<  Bivariate( Y(:SAT Math), X(:Year) );
//Add a row legion for the legend column. For your script you woudl have to remove the
//previous legend and add a new one.
rbiv = Report(biv);
fb = rbiv[FrameBox(1)];

//You would likely change both color and symbol, just made it different for interest
fb << Row Legend(:Region_State, color(0), Marker(1));

//It will be easier to create the Spline with a By group. The Summary table simplifies the task. 
sumdt =dt << Summary(Group(:Region_State), Invisible);
//if the biv winow is closed/ close summary table
biv << On Close (Close(sumdt, NoSave)); //closes the summary table and row state handler

//Create a row state handler function, that defines the tasks when rge rowstate of sumdt changes. 
f = Function({a},
	_c = biv << Xpath("//IfBox[@isTrue='true']");
    for(i=nitems(_c), i>=1, i--,  biv << (curve[i] << Remove Fit) ); 
    _yy = sumdt << get selected rows();
       _xx = (sumdt:Region_State<<get values)[_yy];
       _zz = (sumdt <<get rowstates )[_yy];
	   for(i = 1, i<=nitems(_xx), i++,
	   _clr = Color to RGB(ColorOf(AsRowState(_zz[i])));
	   //show(_yy[i], _xx[i], _zz[i], _clr[i] );
	   Eval(EvalExpr(biv << Fit Where(Expr(gcol)[]==Expr(_xx[i]), Fit Spline(0.1, Standardized,
            {Line Color(Expr(_clr) ), Line Width( 5 )}) ) ) );

rs = sumdt<<Make Row State Handler(f);
//Use Ctrl+ click to deselect or select multiple states [processes]