Hi,
I am using Graph Builder to display:
The "updated_date" is the only common factor between all data sets, which have been collected from 3 different databases
I would like to have the possibility to have an X Reference line displayed while I click and hold the mouse on any of the plots. On mouse release it should disappear.
The Reference line should be displayed across all plots simultaneously.
An example of what I need is seen below:
Looking forward to seeing what creative solutions may be provided
- Philip
Using the original method, your code would have to update 2 AND 3 when 1 is manipulated (and cyclic permutations thereof).
But with Craige's '<<inval' approach, the code becomes much simpler:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 528, 448 ),
Show Control Panel( 0 ),
Variables( X( Transform Column( "Row", Formula( Row() ) ) ), Y( :height ), Y( :weight ), Y( :age ) ),
);
::exx = 1;
gbfb3 = Report( gb )[FrameBox( 3 )];
gbfb3 << AddGraphicsScript(
Pen Color( "Red" );
Pen Size( 2 );
Mousetrap(
::exx = x;
gb << inval;
);
V Line( ::exx );
);
gbfb1 = Report( gb )[FrameBox( 1 )];
gbfb1 << AddGraphicsScript(
Pen Color( "Red" );
Pen Size( 2 );
Mousetrap(
::exx = x;
gb << inval;
);
V Line( ::exx );
);
gbfb2 = Report( gb )[FrameBox( 2 )];
gbfb2 << AddGraphicsScript(
Pen Color( "Red" );
Pen Size( 2 );
Mousetrap(
::exx = x;
gb << inval;
);
V Line( ::exx );
);
You could probably adapt this approach to your specific case:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 528, 448 ),
Show Control Panel( 0 ),
Variables( X( Transform Column( "Row", Formula( Row() ) ) ), Y( :height ), Y( :weight ) )
);
::exx = 1;
gbfb1 = Report(gb)[FrameBox(1)];
gs1 = Expr(
gbfb1 << AddGraphicsScript(
PenColor("Red");
PenSize(2);
Mousetrap(::exx = x; gbfb2 << removeGraphicsScript(1); gs2);
VLine(::exx);
);
);
gbfb2 = Report(gb)[FrameBox(2)];
gs2 = Expr(
gbfb2 << AddGraphicsScript(
PenColor("Red");
PenSize(2);
Mousetrap(::exx = x; gbfb1 << removeGraphicsScript(1); gs1);
VLine(::exx);
);
);
gs1;
gs2;
Hi Ian,
Thank you for your fast response.
This is exactly what I am looking for but I need it to work across 3 plots
Using the "$SAMPLE_DATA/Big Class.jmp dataset I added a plot for :age but unfortunately when I try to set this up to work across 3 plots I have been unable to get it working. I can get 2 out of 3 working at any time.
Would it be possible to add some comments to the script to explain what is the logic? My apologies for this inconvenience.
In my case it would suffice that when clicking on the center plot (:weight) the reference line would be drawn upwards and downwards covering all plots.
Here is what I have done:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 528, 448 ),
Show Control Panel( 0 ),
Variables( X( Transform Column( "Row", Formula( Row() ) ) ), Y( :height ), Y( :weight ), Y( :age ) ),
);
::exx = 1;
gbfb3 = Report(gb)[FrameBox(3)];
gs3 = Expr(
gbfb3 << AddGraphicsScript(
PenColor("Red");
PenSize(2);
Mousetrap(::exx = x; gbfb1 << removeGraphicsScript(1); gs1);
VLine(::exx);
);
);
gbfb1 = Report(gb)[FrameBox(1)];
gs1 = Expr(
gbfb1 << AddGraphicsScript(
PenColor("Red");
PenSize(2);
Mousetrap(::exx = x; gbfb2 << removeGraphicsScript(1); gs2);
VLine(::exx);
);
);
gbfb2 = Report(gb)[FrameBox(2)];
gs2 = Expr(
gbfb2 << AddGraphicsScript(
PenColor("Red");
PenSize(2);
Mousetrap(::exx = x; gbfb3 << removeGraphicsScript(1); gs3);
VLine(::exx);
);
);
gs1;
gs2;
gs3;
The resulting plot looks like this:
When I click inside the "age" plot, all goes well with the Ref. Line moving with the mouse across all plots.
However when I click inside the "height" plot the following happens:
The Reference line moves through "height" and "weight" but not "age"
Likewise when I click inside the "weight" plot the following happens:
The Reference line moves through "weight" and "age" but not "height"
Could you please take a look?
Thanks,
Philip
Using the original method, your code would have to update 2 AND 3 when 1 is manipulated (and cyclic permutations thereof).
But with Craige's '<<inval' approach, the code becomes much simpler:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 528, 448 ),
Show Control Panel( 0 ),
Variables( X( Transform Column( "Row", Formula( Row() ) ) ), Y( :height ), Y( :weight ), Y( :age ) ),
);
::exx = 1;
gbfb3 = Report( gb )[FrameBox( 3 )];
gbfb3 << AddGraphicsScript(
Pen Color( "Red" );
Pen Size( 2 );
Mousetrap(
::exx = x;
gb << inval;
);
V Line( ::exx );
);
gbfb1 = Report( gb )[FrameBox( 1 )];
gbfb1 << AddGraphicsScript(
Pen Color( "Red" );
Pen Size( 2 );
Mousetrap(
::exx = x;
gb << inval;
);
V Line( ::exx );
);
gbfb2 = Report( gb )[FrameBox( 2 )];
gbfb2 << AddGraphicsScript(
Pen Color( "Red" );
Pen Size( 2 );
Mousetrap(
::exx = x;
gb << inval;
);
V Line( ::exx );
);
Each cell in the trellis plot that Graph Builder produces is a separate 'FrameBox()', and the challenge is to update each of these when only one is changed. The code above relies on repeatedly deleting and reinstating a graphics script for each FrameBox(), and this is clumsy to say the least.
Craige@jmp was kind enough to point out a better way: Simply send the Graph Builder object itself an '<< inval' message, which forces all of the associated FrameBoxes to redraw appropriately:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 528, 448 ),
Show Control Panel( 0 ),
Variables( X( Transform Column( "Row", Formula( Row() ) ) ), Y( :height ), Y( :weight ) )
);
::exx = 1;
gbfb1 = Report( gb )[FrameBox( 1 )];
gbfb1 << AddGraphicsScript(
Pen Color( "Red" );
Pen Size( 2 );
Mousetrap(
::exx = x;
gb << inval; // make sure the other graph updates
);
V Line( ::exx );
);
gbfb2 = Report( gb )[FrameBox( 2 )];
gbfb2 << AddGraphicsScript(
Pen Color( "Red" );
Pen Size( 2 );
Mousetrap(
::exx = x;
gb << inval; // make sure the other graph updates
);
V Line( ::exx );
);
Thank you Ian and Craig for your solution(s).
This works beautifully
If you are up to another challenge, ..... I was wondering if activated labels could be displayed when the Reference Line is placed on any point in any chart.
Recall that there will never be a situation that points will occur exactly on the same x-axis location in my application.
I my case, the labels would be operator written comments relating to testing, manufacturing or process monitoring.
This is more "nice to have" rather than necessary but it would be very nice
- Philip
Can JMP graphics have this effect?
@jpol
-> yes, with some adjustments to the JSL code in the other discussion : )