The drawing API


The RGraph Drawing API allows you to add various elements to your charts. These elements allow you to extend both the interactivity and the information presented on your charts by adding shapes to them. The elements that are available have a very similar structure to a chart library - you create and manipulate them in the same way. As well as this they support similar interactive properties - such as tooltips, the click event and the mousemove event. This makes them very useful for providing your users with extra information - much like tooltips do by themselves - and also highlighting areas on the chart.

Example usage of the drawing API is as follows:

    line = new RGraph.Line({
        id: 'cvs',
        data: [4,9,1,3,2,6,5],
        options: {
            xaxisLabels: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],
            marginInner: 5,
            tickmarksStyle: 'endcircle',
            marginTop: 35,
            marginBottom: 45,
            colors: ['black'],
            xaxis: false,
            yaxis: false,
            yaxisScale: false,
            textSize: 14
    marker1 = new RGraph.Drawing.Marker1({
        id: 'cvs',
        x: line.coords[3][0],
        y: line.coords[3][1],
        radius: 15,
        text: 'W',
        options: {
            tooltips: [
                '<b>Winner!</b><br />Mark sold by far the most' +
                'widgets and as a result is the winner!'
            highlightFill: 'rgba(255,0,0,0.7)'
    circle = new RGraph.Drawing.Circle({
        id: 'cvs',
        x: line.coords[2][0],
        y: line.coords[2][1], 15,
        radius: 20,
        options: {
            colorsStroke: 'black',
            colorsFill: 'rgba(255,0,0,0.7)'
    }).on('click', function (e, shape)
        alert('[NOTICE] Also worthy of note is the low point of the competition - which was wednesday')
    }).on('mousemove', function (e, shape)
    { = 'pointer';

    image = new RGraph.Drawing.Image({
        id: 'cvs',
        x: line.get('marginLeft') + 5,
        y: line.canvas.height - line.get('marginBottom') - 5,
        src: '/images/logo.png',
        options: {
            valign: 'bottom',
            tooltips: [
                '<b>Information</b><br />The image drawing object could be ' +
                'used as a method of<br />' +
                'providing more information to your users.'
            tooltipsEvent: 'onclick'

Available drawing API objects