How to use DOM1-style RGraph custom events

[No canvas support]

Previously, adding custom RGraph events was rather verbose - being modelled on the DOM2 method of adding events. Now though you can use the older but more concise DOM1 method. You can only add one DOM1 event listener (which could do multiple things) but you can add both DOM1 and DOM2 style event listeners at the same time.

This example uses the ondraw custom event to add a highlight after-effect to the bars.

The code to achieve this is shown below.

    window.onload = (function ()
        var bar = new RGraph.Bar({
            id: 'cvs',
            data: [[47,75],[32,74],[71,85],[25,19],[23,71],[81,59],[43,130],[23,20]],
            options: {
                colors: ['#494949','#35A0DA'],
                labels: ['Alf','Bob','Carry','Dara','Edgar','Fliss','Gary','Harry'],
                ylabelsCount: 3,
                numyticks: 6,
                backgroundGridVlines: false,
                backgroundGridBorder: false
        }).on('draw', function (obj)
            var len = obj.coords.length;
            obj.context.fillStyle = 'rgba(255,255,255,0.15)';
            for (var i=0; i<len; ++i) {
                    obj.coords[i][2] / 2,

An example of the ontooltip event

[No canvas support]

This is an example of the ontooltip event that you can use to create charts in tooltips.

    var line = new RGraph.Line({
        id: 'cvs2',
        data: [14,16,13,15,5,8,9,12],
        options: {
            labels: ['Luis','Kev','Jim','Harry','Hoolio','liss','Rhonda','Fred'],
            tooltips: function () {return '<canvas id="tooltip_canvas" width="300" height="100"></canvas>';}),
            hmargin: 5,
            tickmarks: 'endcircle'
    line.ontooltip = function (obj)
        // This is the data for the tooltip bar chart
        var tooltip_data = [[4,4,6],[4,7,5],[10,1,2],[5,5,5],[1,2,2],[4,2,2],[2,4,3],[6,4,2]];
        // Get the visible tooltip
        var tooltip = RGraph.Registry.get('chart.tooltip');
        var index   = tooltip.__index__;
        var bar = new RGraph.Bar({
            id: 'tooltip_canvas',
            data: tooltip_data[index],
            options: {
                gutterLeft: 17,
                gutterRight: 5,
                gutterTop: 15,
                labels: ['Monday','Tuesday','Wednesday'],
                backgroundGrid: false,
                noyaxis: true,
                ylabels: false,
                labelsAbovebar: true