Skip to main content
Question

Assign random colors to events in new Calendar report

  • February 26, 2018
  • 0 replies
  • 82 views

The new Calendar chart offers the ability to assign colors to events. That is, I'd like to visually differentiate records on this chart by color, but I don't care what color they are. I'd like to assign RANDOM colors to my events, which are appointments by certain personnel. My Appointments table looks up at my Personnel table, so I could laboriously assign each Personnel a hex color, look up to it, and assign the color for that event using the formula field in the new calendar chart builder.

But I'm lazy.

Can anyone suggest a random color assignment method? Might there be a way of generating a color based on some unique value in the Personnel table (record ID)? Maybe by looking up at a Color table created with data like this https://jonasjacek.github.io/colors/? There are 256 colors in this table, more than my active Personnel, so that would work if I knew a way to convert Record ID to a unique number between 1 and 256.
This topic has been closed for replies.

  • Registered
  • February 26, 2018
This is probably random enough for your purposes - see formula below. I didn't explore  multiple events on the same day but at the expense of making an even longer fomrula that can probably also be by introducing some entropy from the date created field (assuming the events were not created via bulk import)

Script solution would be perfect solution for this but you would have to have the calendar embedded on a parent records for easy script injections.

Ask if you don't understand - short time today.




Calendar Color Formula:

Case(Day([Date]),
   1, "#afb26b",
   2, "#ac5fd1",
   3, "#43a829",
   4, "#cf4aa3",
   5, "#59cd5b",
   6, "#6669cf",
   7, "#b5c134",
   8, "#944e8b",
   9, "#6ea127",
  10, "#df4c7d",
  11, "#40ae60",
  12, "#dd4653",
  13, "#48cdac",
  14, "#bb3d26",
  15, "#4db6d8",
  16, "#e27036",
  17, "#6984c7",
  18, "#d9a132",
  19, "#d88dc7",
  20, "#89c25b",
  21, "#a5485a",
  22, "#77bd87",
  23, "#dd8079",
  24, "#55842f",
  25, "#df9b69",
  26, "#2f8a72",
  27, "#9a5a2c",
  28, "#447a40",
  29, "#a78236",
  30, "#9ba036",
  31, "#6b6b25"
)

  • Quickbase Staff
  • February 27, 2018
Hey Jonathan,
In testing the calendar out, I built several formulas of this type:
var number color = 4;  Case(Mod([Record ID#],$color),  1, "#60b54d", 2, "#694092", 3, "#00b0f1", 4, "#ff9511", 0, "#ff0001")
That'll assign one of 5 hex colors used throughout the Quick Base UI to the event. If you want to support more colors, add them as lines in the format:

5, "#ffffff", 

 and increase the variable accordingly.

Here's a version which includes 83 colors: https://www.pastiebin.com/5a9468a997bd4

Sam Jones
QuickBase Product Manager