Using the animate() function
The animate
function is an older function that was previously a part of RGraph that
has now been rewritten and reinstated to RGraph. It can be used in a similar fashion
to the jquery
animate
function but instead of animating css
properties, it animates
(numeric) RGraph properties. The example shown below uses the trace
effect and then
when that has finished it animates the size of the tickmarks so that they grow from
nothing to their correct size. The marginInner
is also animated at the same time and
starts at zero and grows to 15. Here's the source code:
<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', xaxisLabels: ['John','Fred','Lucy','Idan','Lois','Pete','Jenn'], marginInner': 0, xaxis: false, yaxis: false, spline: true, tickmarksStyle: 'dot', tickmarksSize: 0,// This is the initial size of the tickmarks } }).trace({frames: 60}, function (obj) { obj.animate({ tickmarksSize: 7, marginInner: 15 }); }); </script>
Above, the animate
function is run upon completion of the trace
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', xaxisLabels: ['John','Fred','Lucy','Idan','Lois','Pete','Jenn'], marginInner: 0, xaxis: false, yaxis: false, spline: true, tickmarksStyle: 'dot', tickmarksSize: 0, // This is the initial size of the tickmarks } }).trace({frames: 60}).animate({ tickmarksSize: 7, marginInner: 15 }); </script>