Agregar anotaciones mediante programación a un gráfico existente con JSLHola a todos,
Estoy buscando agregar algunos metadatos en "letra pequeña" a través de JSL a mi gráfico después de haberlo creado en Graph Builder.
A continuación se muestran dos ejemplos de lo que me gustaría hacer con JSL: el campo de texto de metadatos 1 está en el área de trazado, el campo de texto de metadatos 2 está fuera, en la parte inferior del gráfico. En el gráfico de ejemplo, acabo de agregar los campos de texto mediante la herramienta de anotación en la GUI. Sin embargo, me resulta difícil descubrir cómo lograr esto en JSL.
Esta es mi primera publicación aquí. ¡Gracias de antemano por cualquier ayuda!

ventanasRe: Agregar anotaciones mediante programación a un gráfico existente con JSLAquí hay un código cableado que hace lo que usted especificó

Names Default To Here( 1 );
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);
// To add text within the graph one way is to use "Add Graphics Script"
// to the graph
Report( gb )[Outline Box( 1 ), framebox( 1 )] <<
add graphics script(
xMin = Report( gb )[axisbox( 1 )] << get min;
yMin = Report( gb )[axisbox( 2 )] << get min;
Text Color( "red" );
Text(
Right Justified,
{xMin + 46, yMin + 1},
"Metadata1 " || Format( Today(), "yyyymmdd" ) || "/OwnerName"
);
Text( Right Justified, {xMin + 32, yMin + .1}, "path c:tmp/graph-01.jrp" );
);
// Add Outside of the graph
Report( gb )[Outline Box( 1 )] << Append(
V List Box(
Text Box( "Metadata1 " || Format( Today(), "yyyymmdd" ) || "/OwnerName" ),
Text Box( "path c:tmp/graph-01.jrp" )
)
);
Re: Agregar anotaciones mediante programación a un gráfico existente con JSLGracias, Jim, ¡esto fue rápido!
Esto casi me lleva al límite. Ahora puedo generar los textos que quiero.
Sin embargo, si guardo un gráfico hecho de esta manera como un script, obtengo algo como esto:
Graph Builder(
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
5,
Description( "" ),
xMin = Report( gb )[axisbox( 1 )] << get min;
yMin = Report( gb )[axisbox( 2 )] << get min;
Text Color( "red" );
Text(
Right Justified,
{xMin + 46, yMin + 1},
"Metadata1 " || Format( Today(), "yyyymmdd" ) || "/OwnerName"
);
Text(
Right Justified,
{xMin + 32, yMin + 0.1},
"path c:tmp/graph-01.jrp"
);
)}
)
)
)
y si intento ejecutar el script me sale un error
>objeto no suscribible en el acceso o evaluación de 'Report(gb)[ /*###*/axisbox(1)]' , Report( gb )[/*###*/axisbox( 1 )]
Lo cual creo que tiene sentido, ya que "gb" no está definido en el script. ¿Hay alguna solución?
Re: Cómo agregar anotaciones mediante programación a un gráfico existente con JSLFalta la variable "gb" que apunta a la instancia de Graph Builder
gb = Graph Builder(
Re: Cómo agregar anotaciones mediante programación a un gráfico existente con JSLBueno, esto es cierto, pero así es como JMP guarda el script cuando, por ejemplo, uso "guardar script... en la tabla de datos".
Sin embargo, encontré una solución usando Eval y EvalExpr desde aquí:
https://community.jmp.com/t5/Discussions/GraphBuilder-gt-FrameBox-lt-lt-Add-Graphics-Script-V-Line-x-y1/td-p/366991
De esta manera conseguí que todo funcionara:
Names Default To Here( 1 );
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);
yMin = Report( gb )[axisbox( 1 )] << get min;
yMin = Report( gb )[axisbox( 2 )] << get min;
//I need the values "hard-coded"" in the new graphics script to be added => hence i
//need to use the Eval(EvalExpr( .. )) trick from
//https://community.jmp.com/t5/Discussions/GraphBuilder-gt-FrameBox-lt-lt-Add-Graphics-Script-V-Line-x-y1/td-p/366991
Eval(EvalExpr(
Report( gb )[Outline Box( 1 ), framebox( 1 )] <<
add graphics script(
Text Color( "red" );
Text( {expr(xMin),expr(yMin)}, "path c:tmp/graph-01.jrp" );
)
));
Re: Cómo agregar anotaciones mediante programación a un gráfico existente con JSLTambién puedes hacer una ligera modificación al script de Jim y usar X Origin y Y Origin para establecer la ubicación.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 456),
Show Control Panel(0),
Variables(X(:weight), Y(:height)),
Elements(Points(X, Y, Legend(3)), Smoother(X, Y, Legend(4)))
);
Report(gb)[FrameBox(1)] << Add Graphics Script(
Text Color("Red");
Text({X Origin(), Y Origin()},
"Metadata1 " || Format(Today(), "yyyymmdd") || "/OwnerName\!Npath c:tmp/graph-01.jrp"
);
);