14 Replies Latest reply on Jun 30, 2012 1:06 PM by art

RGB functions

Hi all,

My situation is: I want to program a battery bar chart. ie basic rectangle say 2cm wide and 6cm long (basic estimate). I have already used the inspector to draw the outline!

I want to show 2 basic colours ie. green and red - Green for a positive score and red for negative score! I already have the score pre-determined from a previous calculation. In tis case I have 96% positive and 4% negative!

I want to show the colour of this bar or 'battery' as I call it with a RGB value of green - 96% and the remaining 4% = red!

Is there a way to say eg. colour or RGB the rectangle with a 96% green and the remaining 4% of the remaining area = red?

The 96% and 4% could vary but not important at this stage. I'm just wanting to know the correct syntax to do this. Was thinking along the lines of maybe (plain english ....) something like RGB (co-ordinates of the rectangle...?) value =green and RGB(co-ordinates remainder) value = red ...?

Any suggestions would be appreciated!

Appreciated!

Art

• 1. Re: RGB functions

Many folks would suggest that you render the graphic in a web viewer: build the HTML for the image you want in a calculation, and load that in a web viewer. If you're not comfortable with HTML, another approach is to put a repeating field on the layout and use conditional formatting to change the color of different repetitions.

• 2. Re: RGB functions

I have done this type of thing by stacking 2 charts of the same info, with the green one on top of the read one. The green chart would be set to show only up to max value of 96, while the red behind it would show up to 100. When the charts pass 96, the read will appear in the remaining area.

• 3. Re: RGB functions

Thanks, the reating field sounds like my type of approach .. the only thing is how do i get the entire are filled especially in the dimensions i quoted earlier ..?

• 4. Re: RGB functions

Thanks Stephen, Havent thought of this approach though. Makes sense .. I will give it a try.. thanks..Art

• 5. Re: RGB functions

art wrote:

Is there a way to say eg. colour or RGB the rectangle with a 96% green and the remaining 4% of the remaining area = red?

No, but you could use a calculation field with a Text result, e.g.:

gggggggg

formatted in Webdings font.

EDIT:

Haven't noticed Jeremy's suggestion of repeating field: that would work well, too.

Message was edited by: Michael Horak

• 6. Re: RGB functions

Just one thing ...

I actually wanted to program and settle for an exact position as employing a graph (which also makes sense .. but not for my situation) will take up extra space on my layout .. You see it forms part of a dashboard screen and I've allocated certain areas of my layout for certain 'displays'. I can 'colour' the whole rectangle red and just 'overlay' the green bar - the only thing is just how do i specify the co-ordinates or size of the area to dislay green?

• 7. Re: RGB functions

the webdings 'thing' could work but my vertical dimensions should be ideally about 2cm high and thats my problem ..

• 8. Re: RGB functions

You can set a abuilt-in FM chart to display the color scheme of your choice, and set its labels to 1pt and its background to transparent. This will cause it to have fairly small  border areas, and it can overlay other stuff on the layout without being in the way of them if they are packed that tight.

• 9. Re: RGB functions

I'd put two conditional formatting calculations on the repeating field. The first one would format each repetition red when "not IsEmpty ( \$\$PROGRESS )", where \$\$PROGRESS contains the proportion of the chart you want to be green, .96 for your example. This is so you can turn the bar "off" by leaving or setting \$\$PROGRESS to null. The second one would format each repetition green when "Get ( CalculationRepetitionNumber ) / <repetitionCount> ≥ \$\$PROGRESS", where <repetitionCount> is how many repetitions are being displayed. This will override the red from the first conditional format.

Charts are a good quick way to accomplish this sort of thing, but the repeating field gives you more control over exactly where on the layout the bar with display. Even when you turn off all the "chrome" in the chart formatting that you can, there's still space between the chart object borders and the charted bar itself that we aren't in control of, so it can take some trial-and-error to position it exactly where you want it.

• 10. Re: RGB functions

Thanks guys, i like jbante's approach. will note it and keep it in mind. however michael's suggestion just gave an idea to use the a simple font formatting technique eg. using the 'shift' & 'back-slash' key for the vertical bar and font-size it it to lets say 72 and use it in my formula..

Thanks guys. appreciated

• 11. Re: RGB functions

I (before charts) used 100 instances of the "|" (pipe character) in a field (sometimes overlaying the same field 2-3 times and offset a px to "fill" the bar). Then you can calculate the color of the text to the length needed for both colors. This works for multiple colors, as well.

It's quick and dirty way to "bar chart", especially if you need multiple lines (bars).

Beverly

• 12. Re: RGB functions

Beverly, thanks. I like it. It's simple and no real fuss to program! However, how do you 'pack' these "|" characters tightly together so that there's no visible 'spaces' between them...? I tried it but when you change to a bigger, bolder font - you can never get rid of the spaces between the pipe characters! The idea is to get an even and solid bar - not a bar with 'gaps' ? In other words, when I pack these '||||||||||" together I want to see a solid bar ...? something like the actual bars on the BAR CHART of FMP?

Any ideas?

Thanks

Arthur

• 13. Re: RGB functions

That's why I overlay several copies of the field. Nudge each field enough to make it appear to be together.

If you have trouble, I'll make a demo file.

-- sent from my iPhone4 --

Beverly Voth

--

Message was edited by: Beverly Voth; added graphic

1 of 1 people found this helpful
• 14. Re: RGB functions

Thanks ...

Very clear and i understand fully ...

Thanks a million, especially for taking time on a week-end.

Really appreciate!!!!!

Bev for President ..?