API
@-Formulas
JavaScript
LotusScript
Reg Exp
Web Design
Notes Client
XPages
 
View Color Columns
I'm sure many of you have used color columns that were introduced with Notes/Domino 6. This tip covers them a little bit and could go into the "things you didn't know" category about them.

First, let me go over the basics of color columns. A color column applies either just a foreground color or both a foreground and background color to all the columns to the right of the color column, or until another color column is applied. "Applied" is the key and I will explain exactly what that means later on.

The color column itself does not need to be shown to the user. In fact, I always set the color column to be hidden all the time.

On the first tab of the column properties, there is a check box called "use value as color". This indicates a color column.

The value of the formula indicates the color. For example, a list of 3 numbers where each number is between 0 and 255 (inclusive) indicates the foreground color of the column and the subsequent columns. The first number is the red value of the color, the second is the green value of the color, and the third is the blue value of the color. But you're not limited to 255. As long as the number is greater than 0, Notes will take the Modulo of that number and 255 (get the remainder of the number divided by 255) and the Modulo value will be used.

Negative numbers can also be used. But the math becomes a bit confusing. For example, a list with the values -255 : 255 : 0 results in an aquamarine color, which is the same as 0 : 255 : 255. The negative number is translated, but the other numbers are adjusted as well. But at least you'll get a value instead of the code erroring out.

If a list of 6 numbers is used, then the first three numbers indicate the background color and the last three numbers indicate the foreground color. Again, it makes the most sense when the numbers are in the range of 0 to 255, but any numbers can be used.

If only one group (three numbers) is used, then that's the foreground color. If two groups (six numbers) are used, then it's the background color first and the foreground color second. That took me a while to get used to - the foreground color is second in two groups.

If a list of "n" numbers, where "n" is not 3 or 6, is used, the color column reverts to a black foreground and white background. So you must use lists of 3 or 6 numbers.

My favorite way of setting the color column value is with strings, though. Some people don't know of this possibility.

If the value is a hex string (letters 0 through 9 or A through F) color code (the RGB value where the first two characters are the red value, the next two are the green, and the last two are the blue) then that will be used for the foreground color. For example, "0080FF" is a blue color. There are many pages out on the internet (including one of our own) that give you color codes. These are easier to work with (for me, at least) than trying to convert values to decimal and using the numbers as described above.

If the value is an array of two hex strings, then the first hex string is the background color and the second hex string is the foreground color (same as the number lists described above).

As long as the string is a hex number of at least 6 characters, it can be any length. The last 6 characters will be used for the color. So, "FFFFFFFFFFF000000" will result in a black color because the last 6 characters are "000000", which is black.

If the string isn't a hex number, then it doesn't matter what the last 6 characters are. So, "FFFFXFFFFFFFF" will revert to a black foreground and white background because of the letter "X" inside the string.

If you are using the view properties to define row colors and alternate row colors, the color columns are applied "over the top" of the view settings. For example, if the row has a light gray background because of the view's row (or alternate row) color and you specify a light gray foreground color with a color column, the text could blend in together because the view's light gray row background and the color column's light gray foreground will mix. If you are specifying both the foreground and background color, you might sometimes (depending on the colors used and other factors) see a little "border" around your background color on the row. That "border" is the row's background color coming through, but being overwritten by the color column's background color.

In general, if you are using color columns and specifying both the foreground and background color, it is probably best to not use the view properties to set background colors for rows or alternate rows. If you're specifying only the foreground color in the color columns, then it should be fine as long as the colors don't clash.

One neat use for a color column is showing a "bar chart" in a view. Let's say you have monthly documents and sales totals in each document. You could have a view with a bunch of columns showing the totals. The first column would start things off. It would be a color column, hidden all the time, with the color you want to use as its value: "008000" : "FFFFFF". The background color is a medium green color. The foreground color is white, but doesn't matter in this example.

The second column is one space wide and cannot be resized. Its value is an empty space: " ". This is only used to show the background color.

The third column either resets the color or leaves it alone. So it checks the sales value. A formula something like this would work:

@If(Sales <= 1000; "FFFFFF" : "000000; "")

So, if sales for the month are less than or equal to $1,000 then the color is reset to black on white. If sales for the month are greater than $1,000 then the empty string is used which means the color value is not used - the same color that was there before is maintained.

The fourth column is a duplicate of the second column. The fifth column looks like the third column except the upper bound on the sales amount is increased. More and more groups of columns are added - an empty space column, then a column that either resets the color or leaves it alone.

When you're done, you have a view that shows a horizontal bar graph of sales for each month, like the one in this example. Obviously, you'll need to adjust the amounts to fit your needs, but you get the idea. And it might be a good idea to have a some kind of label to indicate the month. One thing I've done in the past is had the second column, instead of a space, be three characters wide and contain the month abbreviation.

I hope this gives you some ideas on how color columns work, and the different ways you can get the color column values in your views.