Hola a todos,
Necesito cambiar las posiciones de las etiquetas de los puntos de datos. Mi problema es que necesito definir las nuevas posiciones de las etiquetas (ver variable LabelPosText ) dentro de la declaración de expresión. Sé que esto no sería necesario en el ejemplo siguiente, pero quiero ahorrarte el esfuerzo de trabajar con mi código extenso, así que te muestro un ejemplo simplificado.
Ahora no puedo obtener el contenido de la variable LabelPosText en la parte de expresión de Graph Builder (la línea respectiva está etiquetada con //aquí necesito ayuda
). He probado varias combinaciones de Eval(), Eval Expr(), etc., pero nada me ha funcionado.
¡Muchas gracias por tu ayuda!
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Eval(
Parse(
"dt << New Script(\!"test script\!",
<BR /> //defining new label positions for some data points
Rows = dt << get rows where( :Sex == \!"F\!" );
LabelPosText = \!"\!";
For Each({row, idx}, Rows,
WeightValue = Column( dt, \!"weight\!")[row];
HeightValue = Column( dt, \!"height\!")[row];
LabelPosText = LabelPosText || \!"{\!"|| char(row-1) ||\!", -5, 12, \!"|| char(WeightValue) ||\!", \!"|| char(HeightValue) ||\!"}\!";
if(idx < N Items(Rows),
LabelPosText = LabelPosText || \!", \!"
)
);
Graph Builder(
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch( {}, \!"Graph Builder\!", FrameBox,
{DispatchSeg(
Marker Seg( 1 ),
{Label Offset( LabelPosText ), //here I need help ;)
Set Force Labels( \!"Label by Row\!" )}
)}
)
)
)
)"
)
Es posible calcularlos internamente. Si existe la posibilidad de que cambien entre distintas ejecuciones de scripts de tabla, deberían estar dentro de ellos; de lo contrario, los movería hacia afuera y evaluaría el valor dentro del script.
En general, siempre evitaría usar EvilParse (Eval(Parse()) ya que es una pesadilla de depurar y, en mi opinión, casi nunca hay una razón para usarlo. Esto parece complicado, pero lo abordaría con algo como esto
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Label Offset has very annoying format to build as it isn't list with lists
// but just something with lists
table_script = Expr(
Names Default To Here(1);
Rows = Current Data Table() << get rows where(:Sex == "F");
offsets = Expr(Label Offset());
For Each({row, idx}, Rows,
WeightValue = :weight[row];
HeightValue = :height[row];
l = Eval List({row - 1, -5, 12, WeightValue, HeightValue});
Insert Into(offsets, l);
);
Eval(Substitute(
Expr(Graph Builder(
Size(528, 456),
Show Control Panel(0),
Variables(X(:weight), Y(:height)),
Elements(Points(X, Y, Legend(5))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{DispatchSeg(
Marker Seg(1),
{_labeloffset_,
Set Force Labels("Label by Row")}
)}
)
)
)),
Expr(_labeloffset_), Name Expr(offsets)
));
);
Eval(EvalExpr(
dt << New Script("test script",
Expr(Name Expr(table_script));
);
));
También puede mover el desplazamiento de etiqueta fuera del generador de gráficos y enviar el mensaje al generador de gráficos después de que se haya creado (no estoy seguro de si esto configura correctamente las etiquetas de fuerza establecidas)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Label Offset has very annoying format to build as it isn't list with lists
// but just something with lists
table_script = Expr(
Names Default To Here(1);
Rows = Current Data Table() << get rows where(:Sex == "F");
offsets = Expr(Label Offset());
For Each({row, idx}, Rows,
WeightValue = :weight[row];
HeightValue = :height[row];
l = Eval List({row - 1, -5, 12, WeightValue, HeightValue});
Insert Into(offsets, l);
);
gb = Graph Builder(
Size(528, 456),
Show Control Panel(0),
Variables(X(:weight), Y(:height)),
Elements(Points(X, Y, Legend(5))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{DispatchSeg(
Marker Seg(1),
{Set Force Labels("Label by Row")}
)}
)
)
);
ms = Report(gb)[FrameBox(1)] << Find Seg(MarkerSeg(1));
Eval(EvalExpr(Send(ms, Expr(Name Expr(offsets)))));
wait(0);
);
Eval(EvalExpr(
dt << New Script("test script",
Expr(Name Expr(table_script));
);
));
El guión de la mesa final debería verse así
Names Default To Here(1);
Rows = Current Data Table() << get rows where(:Sex == "F");
offsets = Expr(Label Offset());
For Each({row, idx}, Rows,
WeightValue = :weight[row];
HeightValue = :height[row];
l = Eval List({row - 1, -5, 12, WeightValue, HeightValue});
Insert Into(offsets, l);
);
gb = Graph Builder(
Size(528, 456),
Show Control Panel(0),
Variables(X(:weight), Y(:height)),
Elements(Points(X, Y, Legend(5))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{DispatchSeg(Marker Seg(1), {Set Force Labels("Label by Row")})}
)
)
);
ms = Report(gb)[FrameBox(1)] << Find Seg(Marker Seg(1));
Eval(Eval Expr(ms << Expr(Name Expr(offsets))));
Wait(0);
y el script que obtienes del generador de gráficos
Graph Builder(
Size(528, 456),
Show Control Panel(0),
Variables(X(:weight), Y(:height)),
Elements(Points(X, Y, Legend(5))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{DispatchSeg(
Marker Seg(1),
{Label Offset(
{8, -5, 12, 112, 60},
{0, -5, 12, 95, 59},
{9, -5, 12, 107, 61},
{1, -5, 12, 123, 61},
{10, -5, 12, 67, 56},
{2, -5, 12, 74, 55},
{3, -5, 12, 145, 66},
{4, -5, 12, 64, 52},
{15, -5, 12, 81, 61},
{16, -5, 12, 91, 62},
{17, -5, 12, 142, 65},
{18, -5, 12, 84, 63},
{19, -5, 12, 85, 62},
{27, -5, 12, 92, 62},
{28, -5, 12, 112, 64},
{34, -5, 12, 112, 65},
{35, -5, 12, 115, 60},
{37, -5, 12, 116, 62}
), Set Force Labels("Label by Row")}
)}
)
)
);
Muy nuevo, gracias por esta información, ¡especialmente con No Labels puede ser realmente útil!
Para Label Offset , no pude encontrar mucha documentación: ¿parece que no hay ninguna funcionalidad que los usuarios puedan usar?
Interesante:
- Las coordenadas x/y parecen utilizarse únicamente para una doble comprobación. Esto se puede utilizar para simplificar el comando:
simplemente proporcione valores incorrectos para MALE para deshacerse de ellos.
- ¿Qué sistema de coordenadas se utiliza para los desplazamientos? Un desplazamiento constante no da como resultado un desplazamiento constante para cada etiqueta.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
LabelPosOffsets = Expr(Label Offset());
For Each row(
Insert Into(LabelPosOffsets,Eval List({row() - 1, -100,100,:weight+if( sex=="F", 0,1),:height}))
);
Eval (Eval Expr(Graph Builder(
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ), Color( :sex ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch( {}, "Graph Builder", FrameBox,
{DispatchSeg(
Marker Seg( 1 ),
{ Expr(Name Expr(LabelPosOffsets) ), Set Force Labels( "Label by Row" )}
)}
)
)
)));