This is quite an old demo of a Line chart but has stood up through the years (months...?) very well and still looks very presentable.
Its simply a black line chart with two datasets that both use custom tickmarks. These custom tickmarks are drawn by utilising the RGraph.path2() API function. This is a function that makes drawing with the canvas API (on a canvas...) far less verbose than it usually is.
Before drawing commences, using the beforedraw event, the canvas is cleared to a plain black colour. You might find this as a performance enhancing tip on variopus canvas performance articles though by the second frame you'll not be drawing on a transparent canvas - so it might be a superfluous action.
The trace() Line chart effect is used here - but an options object is passed to the effect function call. This just a regular JavaScript object which contains a single property - frames. As the name suggests this stipulates the number of frames in the animation. Lower numbers mean for quicker animations that finish sooner.
This goes in the documents header:<script src="RGraph.common.core.js"></script> <script src="RGraph.line.js"></script>Put this where you want the chart to show up:
<canvas id="cvs" width="600" height="250" style="border-radius: 5px; box-shadow: 3px 3px 3px #ccc"> [No canvas support] </canvas>This is the code that generates the chart:
<script> new RGraph.Line({ id: 'cvs', data: [ [7.0,6.9,9.5,14.5,18.2,21.5,25.2,26.5,23.3,18.3,13.9,9.6], [0.2,0.8,5.7,11.3,17.0,22.0,24.8,24.1,20.1,14.1,8.6, 2.5] ], options: { labels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'], shadow: false, noxaxis: true, noyaxis: true, colors: ['#0f0','#76D0FF'], tickmarks: function (obj, data, value, index, x, y, color, prevX, prevY) { RGraph.path2( obj.context, 'b lw 2 a % % 6 0 % false f null s black', x, y, RGraph.TWOPI ); }, linewidth: 3, textColor: '#eee', gutterLeft: 40, gutterBottom: 40, gutterTop: 40, gutterRight: 40 } }).on('beforedraw', function (obj) { RGraph.clear(obj.canvas, 'black'); }).trace2({frames: 15}); </script>