The animate() function

Share RGraph:   

Summary
The RGraph animate() function is similar in operation to the jQuery animate() function but instead of CSS properties it animates RGraph configuration properties. The chart below shows you how you can use it to create your own animation effects.

[No canvas support]

The animate() function is an older function that was previously a part of RGraph that has now been rewritten and reinstated to RGraph. I can be used in a similar fashion to the jQuery animate() function but instead of animating CSS properties it animates (numeric) RGraph properties. The chart shown here uses the trace2() effect and then when that has completed it animates the size of the tickmarks so that they grow from nothing to their correct size. The hmargin is also animated at the same time and starts at zero and grows to 15. Here is the source code for the charts shown here.

<script>
    new RGraph.Line({
        id: 'cvs',
        data: [4,8,6,3,5,2,4],
        options: {
            backgroundGridVlines: false,
            backgroundGridColor: '#eee',
            backgroundGridBorder: false,
            textSize: 16,
            textColor: 'black',
            labels: ['John','Fred','Lucy','Idan','Lois','Pete','Jenn'],
            hmargin': 0,
            noaxes: true,
            tickmarks: 'dot',
            ticksize: 0,// This is the initial size of the tickmarks
            scaleZerostart: true,
            textAccessible: true
            
        }
    }).trace2({frames: 60}, function (obj)
    {
        obj.animate({
            'ticksize': 7
        });
    });
</script>

Above, the animate() is run upon completion of the trace2() effect, however by using method chaining you can just as easily have them run concurrently like so:

<script>
    new RGraph.Line({
        id: 'cvs',
        data: [4,8,6,3,5,2,4],
        options: {
            backgroundGridVlines: false,
            backgroundGridColor: '#eee',
            backgroundGridBorder: false,
            textSize: 16,
            textColor: 'black',
            labels: ['John','Fred','Lucy','Idan','Lois','Pete','Jenn'],
            hmargin: 0,
            noaxes: true,
            tickmarks: 'dot',
            ticksize: 0,// This is the initial size of the tickmarks
            scaleZerostart: true
            
        }
    }).trace2({frames: 60}).animate({
        'ticksize': 7
    });
</script>

Comments

Add a new comment...