Names Default To Here(1);New Window("Example",
trapx =20;
trapy =50;
handx =70;
handy =80;
trapcolor="blue";
handcolor="blue";Graph Box(
Frame Size(200,200),handle( handx, handy,// any handle(s) must come before MousetrapFunction({a, b}, handx=a; handy=b;Write(Eval Insert("\!nhand drag ^a^ ^b^"));
handcolor="magenta";),// the mouse-up handler Function({a, b}, handx=a; handy=b;Write(Eval Insert("\!nhand release ^a^ ^b^"));
handcolor="cyan";));Mousetrap(// should not be more than one Mousetrap, the first one captures all clicksFunction({a, b}, trapx=a; trapy=b;Write(Eval Insert("\!ntrap drag ^a^ ^b^"));
trapcolor="red";),// the mouse-up handler Function({a, b}, trapx=a; trapy=b;Write(Eval Insert("\!ntrap release ^a^ ^b^"));
trapcolor="green";));// the drawing occurs outside of the mousetrap or handlepencolor(trapcolor);pensize(3);Circle({0,0},Sqrt( trapx * trapx + trapy * trapy ));pencolor(handcolor);pensize(3);Circle({0,0},Sqrt( handx * handx + handy * handy ));));
If you need one or more handles, they must appear before the mousetrap because a click will be consumed by the mousetrap if no previous handle took it.
Created:
Nov 15, 2024 11:37 PM
| Last Modified: Nov 15, 2024 8:45 PM(1973 views)
| Posted in reply to message from lala 11-10-2024
Slightly changed the script to display weight values instead of more:
names default to here(1);
dt =Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Show Control Panel(0),
Variables( X(:height ), Y(:weight ), Overlay(:sex )),
Elements( Points( X, Y, Legend(1)), Smoother( X, Y, Legend(2))));
fb =Report( gb )[FrameBox(1)];
xx = yy =0;
valuesMatrix =:height << Get Values;//***new*** Get column values for height
fb << addgraphicsscript(//Mousetrap(
xx = x;
yy = y;);V Line( xx );// at this point you can highlight all the values near xxFor( irow =1, irow <=N Rows( dt ), irow +=1,If(Abs( dt:height[irow]- xx )<0.5,// big class height step is 1, <.5 selects a single column of weightsMarker(Marker State(4),{dt:height[irow], dt:weight[irow]})));
valuesRows =char(:weight[loc(valuesMatrix,round(xx))]);//***new*** write to char weight values for all rows of height at position round(xx)
xwidth =X Range();
xmidpoint =X Origin()+ xwidth /2;If( xx < xmidpoint,Text({xx + xwidth /100, yy},"height "||Char(Round( xx ))||"\!nweight "|| valuesRows )////***new*** exchanged "more" with weigth and list of weight values for that location of height,Text( right justified,{xx - xwidth /100, yy},"height "||Char(Round( xx ))||"\!nweight "|| valuesRows ));// );
you may even could add sorting the values ascending/descending.
hoverline.mp4
Video Player is loading.
Current Time 0:00
/
Duration 0:08
Loaded: 0%
0:00
Stream Type LIVE
Remaining Time -0:08
1x
Chapters
descriptions off, selected
captions settings, opens captions settings dialog
captions off, selected
default, selected
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
This is a modal window. This modal can be closed by pressing the Escape key or activating the close button.