almende / chap-links-library

a web based visualization library for displaying graphs, networks, and timelines
http://almende.github.com/chap-links-library
Apache License 2.0
599 stars 167 forks source link

On executing draw/redraw the slider not rendering after first time calling the draw method of chaps link library timeline. #361

Open navneetpersi0935 opened 8 years ago

navneetpersi0935 commented 8 years ago

Please help its urgent, actually there is a feature we need to implement in our project that if i change the first and last time to change the range on timeline, so at the same time i want to change the first and last item on another timeline accordingly by using draw.redraw method but we are getting blank timeline and also not getting any error. so please help.

    $scope.changeVisibleChartRange = function(dateObj){
        //charttimeline.setVisibleChartRange(dateObj.startr, dateObj.endr);
        $scope.externalStartDate = dateObj.startr;
        $scope.externalEndDate = dateObj.endr;

        $scope.charttimelinedata2 = [
                {'start': $scope.externalStartDate, 'content': 'First'},
                {'start': $scope.externalEndDate, 'content': 'Last'} 
        ];

        //set data for redrawing the timeline
        //charttimeline.redraw($scope.charttimelinedata2);

        //$scope.drawVisualization();
        charttimeline.redraw();
    }

    // handler to draw timeline slider
    $scope.drawVisualization = function(){

        // create and populate an array with data
        $scope.charttimelinedata = [
                {'start': $scope.timelineStartSelector, 'content': 'First'},
                {'start': $scope.timelineEndRange, 'content': 'Last'} 
        ];

        var maxRange = $scope.addMinutes($scope.timelineEndRange, 2);

        // specify options
        $scope.timelineoptions = {
            "width":  "100%",
            "height": "120px",
            "min": $scope.timelineStartRange,          // lower limit of visible range
            "max": maxRange,         // upper limit of visible range
            "zoomMin": 1000 * 60,            // one day in milliseconds
            "zoomMax": 1000 * 60 * 60 * 24 * 31,  // zoom level for maximum 31 days
            "editable": true
        };

        // Instantiate our timeline object.
        charttimeline = new links.Timeline(document.getElementById('timeline_slider'), $scope.timelineoptions);    
        links.events.addListener(charttimeline, 'changed', $scope.onRangeChange);
        links.events.addListener(charttimeline, 'add', $scope.onadd);
        // Draw our timeline with the created data and options
        charttimeline.draw($scope.charttimelinedata);  

        charttimeline.setSelection([{'row':0}]);
        charttimeline.move(0.5);
        charttimeline.zoom(-0.1);
        $scope.rangeSetExternally = false;
    }    
josdejong commented 8 years ago

You probably mean to call charttimeline.draw(data) instead of redraw, which doesn't accept data.