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

More »

 

Version 7.20
Version 7.20 (released in June 2026) is the latest version of RGraph and the major change in this version is an update to the default values of properties making for better looking charts without having to set any properties. Read more about this and other changes in the changelog.

Download »

 

Download
Get the latest version of RGraph (version 7.20, 9th June 2026) 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 »

 

Latest forum posts
These are the latest support forum posts that have been posted or updated.

9th June, Richard
New version of RGraph: version 7.20
3rd June, Patrick
Question about installing RGraph
1st June, Ouja
How do I add a click event to a bar in my Bar chart?
8th May, Anthony Kuma
Does the SVG Line chart have outofbounds functionality?


Support forum »

 

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 »

How to create an animated and adjustable Line chart

[No canvas support]

Introduction

The Line chart adjusting can be very useful - but it's not particularly usable on touch-based devices (eg mobiles and tablets). This is because of the requirement to drag a point on the Line to its new location and dragging isn't terribly intuitive or even feasible in these environments.

But the Line chart can still be adjusted in these environments as this example shows you. A bit of custom coding is needed - but as it's all provided to you here (and with new functions that were added in version 6.10) the amount of code necessary has been reduced dramatically and it's just a matter of copying and pasting! This version of adjusting is also animated, whereas regular adjusting is not.

There's also an example in the download archive that you can examine that provides you with an example of it in action (this demo, however, uses the adjustableXonly option which is not animated). And you can find that file in the demos/ folder. But first, let's have a look at the code that goes into making the chart.

The code for the chart

Here's the code that makes the chart - as you can see the two new Line chart functions that were added in version 6.10 (obj.closest and the obj.growPoint) have reduced the necessary code to a very small amount. So this should make implementing the code easier for you.

<script>
    line = new RGraph.Line({
        id: "cvs",
        data: [4,8,5,2,6,7,9,1,5,4,3,8],
        options: {
            xaxisLabels: ["Alf","Bob","Chip","Dug","Ed","Fay","Gaz","Hal","Indy","Jay","Kev","Lou"],
            textSize: 14,
            marginInner: 10,
            tickmarksStyle: "endcircle",
            tickmarksSize: 5
        }
    }).draw();
    
    line.canvas.onclick = function (e)
    {
        var indexes = line.closest(e, true, 30);
        var value   = line.getValue(e);

        line.growPoint(indexes.dataset, indexes.index, value, 15);
    }
</script>

Using the adjustingXonly option

The Line chart does have an adjustableXonly option which may do what you want with you just having to specify it in your chart configuration. However, you need to note that this type of adjusting is not animated whilst the adjusting detailed on this page is.