MENU
.net Powerful JavaScript charts
About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 15 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.19, 28th September 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 »

Adding zoom to your charts

As shown in the chart above, you can now add zoom functionality to your svg charts. It probably best suits a Scatter chart which has many points where being able to zoom in on an area might provide a bit of extra clarity. The zoom functionality is available for all of the svg charts though.

To use it, just include the RGraph.svg.common.zoom.js library and add the zoom option to your charts configuration. Once you've done that you can click and drag to highlight an area to zoom in on. When you click and drag the box drawn will stick to the correct dimensions that match the width and height of the svg tag.

When the svg changes to the zoomed-in area you can click and drag the zoomed area left, right, up and down. Try it on the example above. And you can use your mouse wheel to increase or decrease the zoom level (ie zoom in/out).

When you've finished you can press your Esc key on your keyboard to revert the chart back to the original. Here's the code that poduces the chart above.

<script src="RGraph.svg.common.core.js" ></script>
<script src="RGraph.svg.common.zoom.js" ></script>
<script src="RGraph.svg.scatter.js" ></script>

<div style="text-align: center">
    <div id="cc" style="width: 600px; height: 250px"></div>
</div>

<script>
    new RGraph.SVG.Scatter({
        id: 'cc',
        data: [{x:10,y:5},{x:11,y:6},{x:13,y:2},{x:15,y:2},{x:11,y:3},{x:13,y:1},{x:48,y:3},{x:11,y:9}],
        options: {
            backgroundGridVlines: false,
            backgroundGridBorder: false,
            yaxis: false,
            xaxisScaleMax: 50,
            zoom: true,
            xaxisLabels: ['Monday','Tuesday','Wednesday','Thursday','Friday'],
            xaxisLabelsSize: 14,
            xaxisLabelsBold: true
        }
    }).draw();
</script>