Ajout d'annotations par programme à un tracé existant avec JSLSalut tout le monde,
Je cherche à ajouter des métadonnées en « petits caractères » via JSL à mon tracé après avoir créé le tracé dans Graph Builder.
Vous trouverez ci-dessous deux exemples de ce que j'aimerais faire avec JSL : le champ de texte des métadonnées 1 se trouve dans la zone de tracé, le champ de texte des métadonnées 2 se trouve à l'extérieur, en bas du graphique. Dans l'exemple de tracé, je viens d'ajouter les champs de texte par l'outil d'annotation dans l'interface graphique. Cependant, j'ai du mal à comprendre comment y parvenir en JSL.
C'est mon premier message ici - merci d'avance pour toute aide !

les fenêtresRe : Ajout d'annotations par programme à un tracé existant avec JSLVoici un code câblé qui fait ce que vous avez spécifié

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 : Ajout d'annotations par programmation à un tracé existant avec JSLMerci, Jim, c'était rapide !
Cela me mène presque au but. Je peux maintenant générer les textes que je souhaite.
Cependant, si j'enregistre un graphique réalisé de cette manière sous forme de script, j'obtiens quelque chose comme ceci :
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"
);
)}
)
)
)
et si j'essaie d'exécuter le script, j'obtiens une erreur
>objet non inscriptible lors de l'accès ou de l'évaluation de 'Report(gb)[ /*###*/axisbox(1)]' , Report( gb )[/*###*/axisbox( 1 )]
Ce qui me semble logique, puisque « gb » n'est pas défini dans le script. Existe-t-il un moyen de contourner ce problème ?
Re : Ajout d'annotations par programmation à un tracé existant avec JSLIl vous manque la variable « gb » qui pointe vers l'instance Graph Builder
gb = Graph Builder(
Re : Ajout d'annotations par programmation à un tracé existant avec JSLEh bien, c'est vrai, mais c'est ainsi que le script est enregistré par JMP lorsque j'utilise par exemple "enregistrer le script... dans la table de données".
Cependant, j'ai trouvé une solution en utilisant Eval et EvalExpr à partir d'ici :
https://community.jmp.com/t5/Discussions/GraphBuilder-gt-FrameBox-lt-lt-Add-Graphics-Script-V-Line-x-y1/td-p/366991
de cette façon, j'ai réussi à tout faire fonctionner :
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 : Ajout d'annotations par programmation à un tracé existant avec JSLVous pouvez également apporter une légère modification au script de Jim et utiliser X Origin et Y Origin pour définir l'emplacement
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"
);
);