MENU
.net Powerful JavaScript charts
About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 16 years old) and has a wealth of features making it an ideal choice to use for showing charts on your website.

More »

 

Download
Get the latest version of RGraph (version 6.20, 1st December 2024) from the download page. You can read the changelog here. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

Download »

 

License
RGraph can be used for free under the GPL or if that doesn't suit your situation there's an inexpensive (£129) commercial license available.

More »

The drawing API

Introduction

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:

<script>
    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
        }
    }).draw();
    
    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)'
        }
    }).draw();
    
    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)
    {
        e.target.style.cursor = 'pointer';
    }).draw();


    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'
        }
    }).draw();
</script>

Available drawing API objects