Discussions

Expand all | Collapse all

Assign random colors to events in new Calendar report

  • 1.  Assign random colors to events in new Calendar report

    Posted 02-26-2018 17:00
    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.


  • 2.  RE: Assign random colors to events in new Calendar report

    Top
    Contributor
    Posted 02-26-2018 17:44
    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"
    )


  • 3.  RE: Assign random colors to events in new Calendar report

    Posted 02-26-2018 18:04
    Thanks Dan. Unfortunately Date Created isn't unique in this table. I'm trying to figure out a way of converting the unique field of Record ID, which might have values like 3, 24, 481, and 1005, to a different-but-still-unique value of 1 through 256, which I'd then assign to a unique color using a separate table or just putting it all in the formula field as you've demonstrated. Any thoughts on that sort of conversion?


  • 4.  RE: Assign random colors to events in new Calendar report

    Posted 02-26-2018 20:07
    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


  • 5.  RE: Assign random colors to events in new Calendar report

    Posted 02-27-2018 00:48
    These works very nicely with my current data set Sam, thank you! But this still doesn't guarantee unique colors, right? Your formula with 82 colors would yield the same for a record ID of 83 as it would for 165, wouldn't it?

    Not sure if you have a product management role for calendars, but here are some things I would love to see with calendar charts:
    • Dynamic filters. Please.
    • Chart settings to include hours of the day display options for Day/Month views. That is, the settings would include optional start and end times to display (because I never have events starting at 3am or going until 11pm :)
    • Drag to edit events. Drag start/end times to change. Drag entire event to change day or start time.
    Yes I can put these in uservoice.


  • 6.  RE: Assign random colors to events in new Calendar report

    Posted 02-27-2018 15:26
    Jonathan,
    Good news! Request 3 is already in there. You just need to make sure your start and end fields are both editable (not summary, formula, or lookup).

    And yes, please put those in User Voice. My team's going to be primarily focusing on other things now, but if we get enough feedback we'll go back to calendars and look at adding other features like those.

    Sam Jones
    QuickBase Product Manager
     


  • 7.  RE: Assign random colors to events in new Calendar report

    Posted 07-10-2018 15:15
    Sam, 

    To follow up your comment about Jonathan's request #3, you said "Request 3 is already in there. You just need to make sure your start and end fields are both editable (not summary, formula, or lookup)."

    Are you saying that if the User manually enters both the Start and End date, that on the Calendar report, the User can drag the Start Date in/out by X amount of days and/or drag the End Date in/out by X amount of days and the dates will adjust?  Right now I am just experiencing the date range moving when i drag it vs the date range adjusting in or out depending on which date you adjust.  Hopefully that makes sense.

    Thank you in advance for the clarification.