Ne0nx3r0 / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

[Enhancement] CompactEventPainter: Stack events by ZoomLevel (year, month, day, hour, minute, aso.) #393

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
New config parameter:

Timeline.createBandInfo({
    // ...

    zoomSteps: new Array(
        /...
    ),
    eventPainter:   Timeline.CompactEventPainter,
    eventPainterParams: {

        stackByZoomLevel: true, // <- NEW!

        // ...
    }
});

--------------------------------------------------

Extend/change compact_painter.js near line 114 to this:

//...
if (filterMatcher(evt)) {

    var dateMatch = false;

    if(this._params.stackByZoomLevel && previousInstantEvent != null){
        var date1 = previousInstantEvent.getStart();
        var date2 = evt.getStart();
        var t1 = date1.getTime();
        var t2 = date2.getTime();

        switch(this._band._zoomSteps[this._band._zoomIndex].unit) {
            case SimileAjax.DateTime.MILLISECOND:
                dateMatch = t1 == t2;
                break;
            case SimileAjax.DateTime.SECOND:
                dateMatch = (t1 / 1000).toInt() == (t2 / 1000).toInt();
                break;
            case SimileAjax.DateTime.MINUTE:
                dateMatch = (t1 / 60000).toInt() == (t2 / 60000).toInt();
                break;
            case SimileAjax.DateTime.HOUR:
                dateMatch = (t1 / 3600000).toInt() == (t2 / 3600000).toInt();
                break;
            case SimileAjax.DateTime.DAY:
                dateMatch = (t1 / 86400000).toInt() == (t2 / 86400000).toInt();
                break;
            case SimileAjax.DateTime.WEEK:
                dateMatch = (t1 / 604800000).toInt() == (t2 / 604800000).toInt();
                break;
            case SimileAjax.DateTime.MONTH:
                var ym1 = date1.getUTCFullYear() + date1.getUTCMonth();
                var ym2 = date2.getUTCFullYear() + date2.getUTCMonth();
                dateMatch = ym1 == ym2;
                break;
            default:
                dateMatch = date1.getUTCFullYear() == date2.getUTCFullYear();
        }
    }

    if (!evt.isInstant() || evt.isImprecise()) {
        this.paintEvent(evt, metrics, this._params.theme, highlightMatcher(evt));
    } else if (dateMatch) {
        bufferedEvents[bufferedEvents.length - 1].push(evt);
    } else {
        bufferedEvents.push([ evt ]);
        previousInstantEvent = evt;
    }
}
//...

greetings André

Original issue reported on code.google.com by a.fied...@oe-konzept.de on 1 Sep 2010 at 1:27

GoogleCodeExporter commented 9 years ago

Original comment by ryan...@csail.mit.edu on 23 Jun 2011 at 9:29