cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
mikedriscoll
Level VI

JMP script progress indicator

Hi,

With some searching on this forum and digging in the JMP scripting book, I've managed to mostly get my progress script working.  The only thing I don't like is that the vertical (y) axis has numbers on it. Can I turn these off? I was not able to find a way to do this.  Not sure if I should be using something other than a graph box() but my knowledge of this is fairly limited.

dlgStatus = new window("Conversion Progress",

    dlg_gb = graph box(

        Title ("Conversion Progress"),

        FrameSize ( 200, 30),

        xscale(0,100),

        yscale(0, 1), // <---- how to turn off so i don't see the y axis values?

        yaxis (show major ticks (0), show minor ticks (0)),

       

        xname("% complete"),

        yname("")

    )

);

dlgStatus[FrameBox(1)] << Add Graphics Script({Fill Color("blue"),Rect(0,1,50,0,1)}); // 50% on a scale to 100% shown in the xscale above. does not get scaled to the pixel count in frame size()

dlgStatus[FrameBox(1)] << Add Graphics Script({Fill Color("blue"),Rect(0,1,75,0,1)}); // 75% on a scale to 100% shown in the xscale above.

// above is just  a test.  the 50 and 75 would be a loop index variable divided by loop count, in my real script. It would get executed once in each loop iteration.

dlgStatus << closewindow();

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: JMP script progress indicator

You can get rid of the axes with these commands:

 

 

dlg_gb[AxisBox( 2 )] << Delete;
dlg_gb[AxisBox( 1 )] << Delete;

 


Put these two lines just before the first dlgStatus[FrameBox(1)]... command.

View solution in original post

6 REPLIES 6
pmroz
Super User

Re: JMP script progress indicator

You can get rid of the axes with these commands:

 

 

dlg_gb[AxisBox( 2 )] << Delete;
dlg_gb[AxisBox( 1 )] << Delete;

 


Put these two lines just before the first dlgStatus[FrameBox(1)]... command.

mikedriscoll
Level VI

Re: JMP script progress indicator

Thanks, that worked perfectly.

The (1) got rid of my y axis. I left the (2) in place to show %.

I also found I needed a bit of a wait (more than a wait(0);) to update the graphic... here is the end of my loop where i update the graph box:

    progress = floor((paramNum / numParams)*100);
    dlgStatus[FrameBox(1)] << Add Graphics Script({Fill Color("blue"),Rect(0,1,progress,0,1)}); //update progress
   wait(0.001);

    );

Not sure if i needed the "floor" function but it doesn't hurt in my case.

Re: JMP script progress indicator

I think that @pmroz offers a simple direct solution that is safe in this case. Be aware, though, that using the << Delete message to remove an display box object from the display tree might be dangerous in other cases. There are at least two other approaches for this reason. In general, you can modify the visibility of a display box with the << Visibility() message. Use the Collapse argument in this case. The other is a unique protocol for the Axis Box object. See examples here:

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = dt << Bivariate( Y( :weight ), X( :height ), Fit Line );

axis box = Report( biv )[AxisBox( 1 )];

axis box << Remove Axis Label( "weight" );
axis box << Show Major Labels( 0 );
axis box << Show Major Ticks( 0 );
SDF1
Super User

Re: JMP script progress indicator

Hi @mikedriscoll and @pmroz,

 

  I recently came across this post as I was wanting to generate a similar progress window that actually gave the iteration number X out of Y in a long modeling run. Anyway, I took your solution and modified it and added to one that I was working on here., so now I have both the progress bar and actual numbers. I like it. I'll probably have to modify it for my user's preferences, but it's a great start. Thanks for starting this discussion!

Names Default To Here( 1 );
i = 1;
imax = 100;
dlgStatus = New Window( "Overall Modeling Progress",
	V List Box(
		dlg_gb = Graph Box(

			Title( "Overall Modeling Progress" ), 

			FrameSize( 150, 15 ), 

			X Scale( 0, 100 ), 

			Y Scale( 0, 1 ), 

			yaxis( show major ticks( 0 ), show minor ticks( 0 ) ), 

       

			xname( "% complete" ), 

			yname( "" )

		),
		tb = Text Box(
			" Current step " || Char( i ) || " of " || Char( imax ),
			<<Set Font Size( 12 ),
			<<Justify Text( "center" ),
			<<Set width( 200 )
		)
	)
);

dlg_gb[Axis Box( 2 )] << Delete;
dlg_gb[Axis Box( 1 )] << Delete;

For( i = 1, i <= imax, i++,
	prog = (i / imax) * 100;
	dlgStatus[FrameBox( 1 )] << Add Graphics Script( {Fill Color( "blue" ), Rect( 0, 1, prog, 0, 1 )} );
	tb << set text( " Current step " || Char( i ) || " of " || Char( imax ) );
	Wait( 0.1 );
);

dlgStatus << closewindow();

Snap1.png

DS

 

lehaofeng
Level V

Re: JMP script progress indicator

Please ask a question, when my program runs for a long time, about 5 minutes, and the time runs differently on different computers, how can I make a corresponding progress bar based on the actual running waiting time?

mikedriscoll
Level VI

Re: JMP script progress indicator

If your script runs a single loop, you can use SDF1's example and just update the prog variable throughout. To save time and not update every iteration i update every 10 or 50 (don't remember exactly) using a mod() function of the iterating variable. JMP may have improved this in the last 11 years since I created the code, but initially it slowed the script down to update the bar every iteration, while iterating over a few hundreds to a few thousands of columns.

 

If your script is not looping, but is instead crunching through several operations, you might need to just update the progress bar throughout the script. For example if you have 10 operations that take 30s each, increment by 10% progress at each step. This would be a manual process on your part to determine how much time each section of code was taking to execute.

 

If there's some combination of the above, you could get creative about it, but either way it is going to be up to you to figure out how the execution time is distributed in your script and then plot the progress accordingly. JMP won't do it automatically, you need to script the code to update the bar based on progress.

 

This all assumes that even though there are faster and slower computers, each chunk of code will take a comparably proportional amount of total execution time to execute, which is pretty reasonable.