Reputation: 5240
I've got an app that's basically a calendar, the users can enter events for each day. Now I have to find the best way to show the calendar for a full month while highlighting the busiest days.
Obviously the color is the choice here, but I'm wondering how you guys would do it. I have brainstormed the following:
max
events for a day and from there, divide it by the number of colors available. So if one day had 30 events and we have 3 colors, the first one would be from 0 to 9, the following from 10 to 19 and the last from 20 on.average
and divide it by colors/2
, so if the average is 10 events and we have 3 colors, the math would be 10/1.5 = 6.66 which means that the first color range will be from 0 to 6.66, the second from 6.67 to 13.32 and the last from 13.33 on.However, I'm not sure this would be the best way to solve this. Both are linear and the first could mess the things quite a bit if our average is about 20 and the maximum had 100 events, just two colors will be showing up.
I'm no statician, but I think this problem could be solved with percentiles and quartiles, but I'm not really sure how to implement it.
Thanks.
Upvotes: 3
Views: 167
Reputation: 15087
I would suggest an algorithm for a logarthmic distribution which is often used for building tag clouds. Tags are your days, counts of tags are the number of events for a day.
A good implementation for PHP and Python (not checked it properly yet) seems to be this one. Here's an example:
$tags = array(
array('tag' => 1,
'count' => 10),
array('tag' => 2,
'count' => 30),
array('tag' => 3,
'count' => 5),
array('tag' => 4,
'count' => 5));
$colours = array('green', 'yellow', 'red');
foreach(tagcloud($tags, 0, count($colours) - 1, 0) as $d) {
echo '<div style="background-color:' . $colours[floor($d['size'])] . '">Day: '.$d['tag'].' Events: '.$d['count'].'</div>';
}
Upvotes: 1
Reputation: 13289
A few ideas:
Upvotes: 0