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.


12th June, Marco
Should I use SVG or canvas for the charts on my website?
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 show a static Y-axis

Example

Introduction

In the past, showing a custom static y-axis meant drawing the entire y-axis yourself. However now, with the drawing API Y-axis object, (and also the X-axis object) a lot of the coding that was necessary to achieve a custom y-axis has been eliminated. This example shows you how you can implement it.


The necessary HTML

This is the necessary HTML code that positions the second canvas for the axes over the top of the first. Relative and absolute positioning is used so that the canvas doesn't move and is directly over the first canvas.

<div style="position: relative; position: relative; width: 600px; margin-left: auto; margin-right: auto">
    <canvas id="axes" width="41" height="200" style="position: absolute; top: 0; left: 0; z-index: 3; background-color: white"></canvas>
    <div style="width: 600px; overflow: auto">
        <canvas id="cvs" width="1000" height="200"></canvas>
    </div>
</div>

The JavaScript to produce the chart

And here is the javascript to produce the chart. Usually, when doing custom drawing on your canvas and using dynamic features (eg tooltips), you would need to use the draw custom RGraph event so that your drawing is repeated after the canvas has been cleared. Here though, because the axes are being drawn on a separate canvas that isn't being redrawn, that isn't necessary.

<script>
    // This is the code that produces the chart
    new RGraph.Line({
        id: 'cvs',
        data: [4,6,8,5,9,6,4,8,4,6,15,2],
        options: {            
            xaxisLabels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
            tooltips: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
            yaxisScale: false,
            marginInner: 25,
            textSize: 16,
            linewidth: 5
        }
    }).draw();
    
    new RGraph.Drawing.YAxis({
        id: 'axes',
        x: 40,
        options: {
            yaxis: false,
            yaxisScaleMax: line.scale2.max,
            colors: ['black'],
            textSize: 14
        }
    }).draw();
</script>