그래픽 스크립트 추가 및 제거비교적 복잡한 애니메이션 시퀀스 중에 여러 그래픽 스크립트가 Graph Builder에 추가되고 그래프 빌더에서 제거되는 JSL 루틴을 작성했습니다. 추가 및 제거해야 하는 스크립트는 분석 중인 데이터 세트에 따라 다르므로 다음과 같은 많은 항목을 스크립팅해야 합니다(여기서 gb는 내 GraphBuilder 개체이고 myScript1 및 myScript2는 모두 내가 정의한 표현식입니다. 다른 곳):
If( k == 5, Report( gb ) << dispatch( {}, "Graph Builder", FrameBox, {Add Graphics Script( 1, Description( "Script" ), myScript1 )} ));
If( k == 10, Report( gb ) << dispatch( {}, "Graph Builder", FrameBox, {Remove Graphics Script( 2 )} ));
If( k == 15, Report( gb ) << dispatch( {}, "Graph Builder", FrameBox, {Add Graphics Script( 1, Description( "Script" ), myScript2 )} ));
내 문제는 번호로 스크립트를 참조하기 때문에 삭제해야 하는 스크립트를 추적할 수 없다는 것입니다. 그래프 빌더에서 스크립트에 할당한 번호는 스크립트가 제거될 때마다 변경됩니다.
내가 알아 ~해야 한다 잠재적으로 모든 그래픽 스크립트를 if-then-else 절에 의해 다양한 섹션 간에 제어가 전환되는 하나의 큰 스크립트로 결합할 수 있지만 잠재적으로 수십 개의 스크립트가 있고 모든 것이 아마도 매우 지저분해질 것입니다.
이름으로 그래픽 스크립트를 참조할 수 있습니까? 본질적으로 다음과 같이 할 수 있기를 원합니다.
report(gb) << dispatch( {}, "Graph Builder", FrameBox, {Remove Graphics Script( myScript2 )} );
위의 방법은 작동하지 않지만 (분명히 그렇지 않으면 문제가 없을 것입니다) 내가 놓친 비슷한 것이 있는지 궁금합니다.
제안해 주셔서 감사합니다.
Re: 그래픽 스크립트 추가 및 제거크레이지,
자세한 예시 감사합니다. 편집 스크립트 예제는 많은 사람들에게 유용할 것입니다.
그러나 나는 설명 태그가 있고 스크립트에 대한 핸들을 얻는 것이 얼마나 좋을지 생각하고 있습니다.
thisOne = rbiv_fb << Xpath( "//TopSeg[@description='bluepoly'] " );
아마 JMP 15?
Re: 그래픽 스크립트 추가 및 제거나도 좋아 @gzmorgan0 두 번째 접근법. 목록을 유지하는 대신 스크립트를 검색하는 또 다른 아이디어가 있습니다. JSL 스크립트에서 0과 같은 표현식; 또는 "프레드"; 아무것도 하지 않습니다. 그것은 평가되고 버려집니다. 따라서 다음과 같은 그래픽 스크립트
"red"; fill color(...); circle(...);
arg( script, 1 ) 함수를 사용하여 "빨간색"을 반환하여 나중에 연구할 수 있는 식별자를 처음에 가질 수 있습니다.
dt = Open( "$sample_data/big class.jmp" );
gb = dt << Graph Builder(
Size( 525, 452 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 6 ) ) )
);
colors = {"red", "green", "blue", "yellow", "cyan", "magenta", "orange", "purple", "gray"};
For( i = 1, i <= N Items( colors ), i++,
Eval( // the "i" variable needs to be cast-in-stone so it will not be needed if the graph
Eval Expr( // is saved in a journal. EvalExpr will pre-eval the expr() below...
(Report( gb )[framebox( 1 )]) << addGraphicsScript(
1,
Expr( colors[i] ); // this will be the identifier for the script
Fill Color( Expr( colors[i] ) ); // pre-eval the color name, not just the subscript
Circle( {80 + 5 * Expr( i ), 50 + 2 * Expr( i )}, 1, "FILL" );
)
)
)
);
findSegById = Function( {frame, id}, // locate a graphics script by an id string
{child = frame << childSeg, script}, // the frame has a list of graphics scripts
While( !Is Empty( child ),
If( child << className == "TopSeg", // TopSeg is the className of a graphics script
script = child << getscript; // check the script to see if the first
If( Arg( script, 1 ) == id, // statement is the id name
Return( child )
);
);
child = child << sib;
);
Return( child ); // empty, not found
);
Wait( 1 );
thisOne = findSegById( Report( gb )[framebox( 1 )], colors[5] ); // the cyan script
thisOne << delete;
Wait( 1 );
thisOne = findSegById( Report( gb )[framebox( 1 )], "green" );
thisOne << delete;
Wait( 1 );
thisOne = findSegById( Report( gb )[framebox( 1 )], colors[9] ); // the gray script
thisOne << delete;
Wait( 1 );
// if needed, you can retrieve, edit, and replace the script
thisOne = findSegById( Report( gb )[framebox( 1 )], "blue" );
oldScript = thisOne << getscript;
newScript = Substitute( Name Expr( oldScript ), "FILL", Empty() ); // hollow black outline remains
Eval( Eval Expr( thisOne << setscript( Expr( Name Expr( newscript ) ) ) ) );
// gb << inval;
Print( If( Is Empty( findSegById( Report( gb )[framebox( 1 )], "argyle" ) ), "Good", "Bad" ) );
Three filled circles removed and one hollowed outThree filled circles removed and one hollowed out3개의 채워진 원이 제거되고 1개의 속이 비어 있음
Use the customize popup menu item to see the scripts; this is the edited scriptUse the customize popup menu item to see the scripts; this is the edited script사용자 정의 팝업 메뉴 항목을 사용하여 스크립트를 확인하십시오. 이것은 편집된 스크립트입니다
Re: 그래픽 스크립트 추가 및 제거안녕하세요 - 정말 도움이 많이 됩니다. 특히 귀하가 설명하는 두 번째 방법은 기발합니다. eval(substitute(expr(...))) 구성이 내가 사용하고 싶은 맥락에서 어떻게 작동하는지 보여주는 예는 찾기가 다소 어렵기 때문에 (적어도 나에게는) 더 읽기 쉬운 글을 쓰는 경향이 있습니다. 그러나 스마트 스크립트는 훨씬 적습니다. 그러나이 경우에는 분명히 귀하의 예에 훨씬 더 가까운 것이 필요하며 적응할 것입니다.
종종 이와 같은 상황에서 가장 중요한 것은 무거운 총을 문제로 돌리기 전에 간단한 트릭을 놓치지 않았는지 처음부터 확인하는 것입니다 
많은 감사
Re: 그래픽 스크립트 추가 및 제거축하하거나 대본을 작성하십시오. 귀하의 구문으로 볼 때 JSL을 처음 사용하는 것 같습니다.
도움이 될 만한 예제 스크립트가 2개 있습니다.첫 번째는 스크립트 표현식 참조(이름)를 사용합니다. 스크립트를 추가한 후 프레임 상자를 마우스 오른쪽 버튼으로 클릭하고 사용자 지정을 선택합니다.그래픽 스크립트의 JSL은 표시되지 않고 expr 참조만 표시됩니다. 작동합니다. 그러나 귀하 또는 사용자가 그래프를 저널링하면 나중에 저널이 닫힙니다.새 세션에서 저널을 열면 해당 표현식이 정의되지 않고 그래픽이 그려지지 않습니다. 이 방법은 그래픽 스크립트에 변수 충돌이 없고 그래프가 현재 세션에서만 관련이 있는 경우에 작동합니다. Xpath는 프레임박스 TopSeq, 사용자가 추가한 그래픽, 이 경우에는 스크립트 참조만 찾는 데 사용됩니다.
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
orangepoly = Expr( Transparency( 0.5 );
Fill Color( {1.0, 0.5, 0.0} );
Polygon( [60, 72, 57], [75, 120, 120] );
);
bluepoly = Expr(
Transparency( 0.5 );
Fill Color( {0.0, 0.5, 1.0} );
Polygon( [60, 72, 57], [150, 120, 120] );
);
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv << report;
rbiv_fb = rbiv[frame box( 1 )];
rbiv_fb << Add Graphics Script(orangepoly);
rbiv_fb << Add Graphics Script(bluepoly);
//right click on the framebox and select Customize
/*just the expr reference is visible
If this graph is journaled, the journal is closed and reopened the graphics from the script
will not appear. look up Freeze All for the journal. */
glist = (rbiv_fb << XPath("//TopSeg")) << get script;
idx = contains(glist, expr(bluepoly));
Wait( 3 );
rbiv_fb << Remove Graphics Script( idx );이 두 번째 방법은 스크립트를 프레임박스에 내장합니다. 스크립트를 추가한 후 프레임박스를 마우스 오른쪽 버튼으로 클릭하고 사용자 지정을 선택한 다음 스크립트를 클릭하여 두 방법의 차이점을 확인합니다. 목록에 스크립트 삽입을 추가한 후 스크립트 이름입니다. 스크립트를 제거할 때 목록에서 제거하십시오. 이 목록은 스크립트가 활성화된 동적 계정이며 해당 위치를 찾는 데 기능이 사용됩니다.
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
glist={};
orangepoly = Expr(
Transparency( 0.5 );
Fill Color( {1.0, 0.5, 0.0} );
Polygon( [60, 72, 57], [75, 120, 120] );
);
bluepoly = Expr(
Transparency( 0.5 );
Fill Color( {0.0, 0.5, 1.0} );
Polygon( [60, 72, 57], [150, 120, 120] );
);
addgraph = Function({gnme}, {gexpr}, //"orangepoly")
Eval(Parse("gexpr = NameExpr("||gnme||")" ) );
Eval(Substitute(Expr(rbiv_fb << Add Graphics Script(_xxx)), Expr(_xxx), NameExpr(gexpr) ) );
insert into(glist, gnme );
); //end addgraph
rmvgraph = Function({gnme}, {idx},
idx = contains(glist, gnme);
if(idx>0,
rbiv_fb << Remove Graphics Script(idx);
removefrom(glist, idx)
);
); //end rmvgrph
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv << report;
rbiv_fb = rbiv[frame box( 1 )];
addgraph("orangepoly");
addgraph("bluepoly");
//right click on the framebox and select Customize
//the actual script is embedded
Wait( 3 );
rmvgraph("bluepoly");위시리스트 항목에 동의합니다. 이 스크립트(TopSegs)에 설명/이름 태그를 추가합니다.