I have an array of years:
$years = [1952,1954,1961,1962,1965,1982,1984,1984,1984,1985,1986,1986,1987,1988,1990,1991,1991,1993,1995]
I'm creating a timeline and my timeline uses 10 years of ranges, so it looks like this:
1950 1960 1970 1980
.........|.........|.........|.........|.........
With the help of the jQuery each function i loop through these years and i display them on the timeline by creating a div and i position them using the left css attribute (1 year is 22px):
$.each(years, function(key, value) {
var event = $('<div>').addClass('event');
var posX = value*21;
event = event.html(value).css('left',posX+'px');
$('#timeline').append(event);
});
So far so good, but us you can see i have lots of years and i can't display them correctly.
If in a 10 year range theres more than 3 events, i want to display a button instead of the event div and when i click on it i can use a popup to show the rest of the events.
How can i achieve this?
{1952: ['event'], 1984: ['event1', 'event2']}
– Christian Varga Dec 23 '12 at 17:48