Color By

The Percolate campaign calendar allows for coloring campaigns based on custom fields. In order to achieve this functionality on the client side the following steps are used:

1. Load color map

You are only looking for color maps with a status of active.
Color map

2. Load meta data schemas

You are looking for:
resource_types - campaign
type - metadata

3. Filter out correct schema fields

You want schema fields that match any of the following types: term, select, and multi-select.

4. Determine whether or not a schema field should be shown

A schema field should be shown if the color map contains options for that field.

5. Get metadata for each campaign


6. Finding the right color

  • Find the metadata on the campaign that matches the selected schema ID.
  • In that metadata objects ext locate the item who's key matches the selected field key.
  • Get the value for the object you just located. (This is the selected option for the field)
  • Find the matching color mappings for that schema ID and field key.
  • Loop through those color mappings until you find one who's value matches the value found in the campaigns metadata.
  • This color mapping has a color associated with it (as a hex string)
  • Use that hex string to display the color.
  • If the steps above do not return a match, display the no_value_color for that field.
    Note: When trying to locate the correct color for taxonomies look for a color for every term that is chosen until a color is located. If no color is returned begin searching through parents. If all parents are exhausted refer use no_value_color.