Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
Sorting event data; multi-day and single

I am building an event calendar and am stuck binning single-day events around multi-day events. Each day is a div and I can build a month calendar no problem. The problem is mainly when multi-day events overlap and one will break line. The top blue line is continuous, yellow until 6th, red until 7th.
enter image description here
I have searched 'bin stacking' and many other approaches but can't seem to find what seems apt. Part of the problem is my maths limitations and found algorithms end up leave me feeling boggled. My current (non-math) concept is to build an array of arrays; 'number of days in the month' wide by 'expected maximum number of events high.'
Roughly like:

    xxxxxx... xxx // say 31 days  
    xxxxxx... xxx  
    ... +6  
    xxxxxx... xxx  
    xxxxxx... xxx // say max 10 events in any day.

A bit of pseudo code...
Run through array[0] for blueEv > is [0][4]=='x' && [0][5]=='x' && [0][6]=='x' = yes, then lay it in.
for yellowEv > is [0][4]=='x' && [0][5]=='x' = no - then
is [1][4]=='x' && [1][5]=='x' = yes - then do it
redEv... [0] no good [1/] no good and [2] fits
and so on through spanned events and then slot in singles into remaining 'x' slots
remove 'x's and empty arrays at the end and... well, it works but I suspect there is a much more elegant way of doing this.

Pointing to any existing algorithms or functions or some such would be great. I can code tolerably well enough so, in the absence of any known existing code, an outline of approach would great. I am just rounding out the list-view (piece of cake :) and girding my loins ready for month-view.
Q. Why don't I use an existing cal? There are certainly plenty. A. Learning + fun.

Thank you.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!