Friday, December 18, 2009

FileMaker 8+ gradient progress bar with one field - without containers


In the following article I will share a technique that I implemented in our current development, which needed FM8 techniques, as our client currently uses that.

I needed a progress bar, which looks great to show a script progress on a found set.

I didn't want to use containers and started thinking about how I would be able to create the progress bar without them.

Here's what I came up with:



The progress bar is a simple repeating field calculation(text) with 100 repetitions.

It uses the following calculation:

Let ( [r1=123;g1=80;b1=200;r2=10;g2=180;b2=50] ;

If ( Truncate ( (Get(RecordNumber)/Get(FoundCount)) * 100 ; 0) ≥ Get ( CalculationRepetitionNumber );


TextColor ( "█" ;RGB(


r1 + Floor((Get ( CalculationRepetitionNumber ) * (r2 - r1) / 100));

g1 + Floor((Get ( CalculationRepetitionNumber ) * (g2 - g1) / 100));

b1 + Floor((Get ( CalculationRepetitionNumber ) * (b2 - b1) / 100))


)


);""))


The first part of it is a LET calculation where I set up the beginning and the ending RGB colors, which will be used to calculate the actual repetition font color. The second part is a percentage calculator based on the current record and the found set.
The last part is used to calculate the actual RGB color.

The layout is simple, I just added the 100 repetitions, resized it, and set the font size to 72 points. I also added a fill color to the containers, that is what you can see under the gradient bar.

By modifying the rgb values you can come up with any color gradient you like:


I attached a sample file where you can find the calculation, investigate it, etc.

You can download it here.

Please check the demo file, and use this technique it if you like it.


Please visit our site, http://crm.fm which has our main FileMaker product, and support us by buying it. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.