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.


16th June, Rachel
I have a question about the 3D Bar chart
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?


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 »

Is there a z-index property for keys?


Posted by Joachim at 08:26 on Wednesday 30th October 2024 [link]
If you have a key within a (e.g.) line chart I may be ovelayed by part of the chart.

I tried to find out a way (like using a css z-index value) to place keys ontop of chart. Do you have a solution for this?

Posted by Richard at 10:26 on Wednesday 30th October 2024 [link]
How is your chart created? The keys are by default placed above the chart. Like this example shows:

<script>
    new RGraph.Line({
        id: 'cvs',
        data: [4,8,6,4,5,2,1,3,6,4,10,9],
        options: {
            key: ['Freddy','Killian', 'Charles'],
            keyBackground: '#fffa'
        }
    }).draw();
</script>


If you have two charts drawn on the same canvas then the second will be drawn over the first. So if you have a key on the first chart it will appear below the second chart.

The solution here would be to move the key and its configuration properties to the second chart. Like this:

<script>
    new RGraph.Bar({
        id: 'cvs',
        data: [4,8,6,4,5,2,1,3,6,4,10,9],
        options: {
            colors: ['black']
        }
    }).draw();

    new RGraph.Line({
        id: 'cvs',
        data: [4,8,6,4,5,2,1,3,6,4,10,9],
        options: {
            colors: ['red','black'],
            backgroundGrid: false,
            yaxisScale: false,
            xaxis: false,
            yaxis: false,
            key: ['Freddy','Killian'],
            keyBackground: '#fffa',
            marginInner: 25,
            linewidth: 5
        }
    }).draw();
</script>


Posted by Joachim at 10:27 on Wednesday 30th October 2024 [link]
hi,
Problem happens only if using option "filledRange" with line chart (line will overlay key)

Posted by Richard at 12:10 on Wednesday 30th October 2024 [link]
In that case you could try using a second Line chart which is drawn after your main chart which has similar settings except that axes, the scale and the background grid have been turned off and the data for the line is just [0]. Then add the key to this chart.

Because it's drawn after the main chart the key will be drawn on top as well - thus making it appear over the first chart. Here's some example code:

<script>
    // The main Line chart object
    new RGraph.Line({
        id: 'cvs',
        data: [
            [4,8,6,4,5,2,1,3,6,4,10,9],
            [1,2,3,2,3,1,0,0,2,1,2,1]
        ],
        options: {
            colors: ['red','red'],
            marginInner: 25,
            linewidth: 5,
            shadow: false,
            filled: true,
            filledRange: true,
            filledColors: ['pink']
        }
    }).draw();

    // The second Line chart object that just draws the key
    new RGraph.Line({
        id: 'cvs',
        data: [0],
        options: {
            colors: ['#0000'],
            key: ['Freddy','Killian'],
            keyColors: ['red','black'],
            keyBackground: '#fffa',
            marginInner: 25,
            linewidth: 1,
            shadow: false,
            backgroundGrid: false,
            xaxis: false,
            yaxis: false,
            yaxisScale: false
        }
    }).draw();
</script>

[Replies are closed]