From SeedCode Documentation

SeedCodeCalendar12: EventColors

How are events color coded?

The calendar colors events based on the contents of a field of your choosing. We call this field the event "status" in the documentation and sample file, but you can use any field you'd like.

Setting up color coding begins on the Source No X layout (Source No 1, Source No 2, etc.) you made when integrating the calendar. That layout has a tab called "colors" on which you can specify the field you'd like to use for color coding.

(Note: We also have a color field in the events table so we can show a color beside the event on the Event List and Event Details layouts. This calc (SampleEvents::z_sc_ColorCalc) begins with a Let() statement were you can specify which field is being used for your colors.)

Then, on the Settings tab of the calendar you'll see a button called "assign colors". Click that and you can drag a color into each one of your "status" values.

A few notes about how this works...

The portal on the left is based on records from the CalendarColors table and the "new status" button will make a new record in that table so you can create as many "statuses" as you want.
The portal is sorted by the value list "Status" so you'll want to keep that value list in synch with the contents of this portal. We use a by-hand value list here instead of basing the value list on CalendarColors records because we like how you can specify the sort order of a value list and use separators ("-") that you can't when you base a value list on a field.
You can override the color of any status by simply typing a new RGB value into each row.
You can easily alter the pallets of possible colors by editing the field definition for the field "CalendarInterface::ColorRGBValues" where the RGB values of each pallet are declared.

Can I color code by Source instead of by a field?

Yes. If you aren't using the "Status" field in your source table(s), change it to a calc field that returns the name of the source (e.g., "Sample Events"). Make sure the result type for the calc is Text. If you are using the Status field, make a different calc field for the source, then just map the field object on the "Colors" tab on the "Source No X" layouts to that new field.

Can I color by a field outside the Event, like the Event's Project's Status?

Yes, but only if you create a calc in the events table that reflects this value from the related record (the project in this example). All the fields on the Source No X layout need to come from the table that layout is based on--not from related tables.

Can I use the triangle of color from the Simple Day View on other views?

Yes. The simple day view (go to Settings / click "Use simple...") uses a different display for colors so that the color doesn't fill the whole event.

If you want to use this display on other views, edit the calc CalendarColorReptCalc in the calendar rows table. The second line of this calc sets "objecto" to use our triangle display only when the mode is "Day" (our simple day mode). Edit this line to use the triangle in any other modes you'd like. For your reference, a list of possible modes can be found here.

You may also want to change the font size of the value "display" at the end of this calc just on the week and month views if you switch them to the triangle display. You'll see an example line there commented out which does this for you.

Troubleshooting Colors

Here are some tips to make sure color coding works as you expect.

(Note that colors were fundamentally reworked in version 7.23 and are much more stable now as they don't depend on fonts, check out the version history notes for instructions on upgrading to the new build.)

1. Make sure that the field you use for color mapping on the Source No X layout, and the field you use in SampleEvents::z_sc_ColorCalc are the same fields.
2. If no events show up with colors navigate to the Calendar Rows layout in layout mode and make sure there is a big chunk of color in the field CalendarColorGlob. If there isn't, run the upon opening script again.
3. If that doesn't get any color visible in that field (it should be visible in the field without you having to enter the field with your cursor), copy and paste the contents of that field from an uncloned copy of the file.
4. Still not working? Try running the script "Load Calendar Graphics - alternate".
5. Finally make sure the value list of possible statuses (or whatever value list you're using as possible values for your color coded field) matches the list of values shown in the Assign Colors layout.
6. If you see a black bar instead of your color, it is likely that you have operators (math symbols or FileMaker expressions) in the color name (the event status). We try to trap for most of these but there are a lot of possible combinations. Try different versions of your status name without the operators. Remember you need to change this in the event itself, in the status value list, and in the "assign colors" screen in settings.
Retrieved from http://archive.seedcode.com/pmwiki/pmwiki.php?n=SeedCodeCalendar12.EventColors
Page last modified on May 31, 2014, at 10:13 PM