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.10 released
Version 7.10 (released in January 2026) is the latest version of RGraph and contains various updates to the code which you can see on the changelog page. There's also a big tidy up in terms of comments and a significant change to the way that the internal code is referenced which should lead to a performance improvement in effects and animations.

Download »

 

New HTML datagrid
In the April 2025 (v6.21) release a new datagrid object was added. This makes it easy to add static or dynamic data tables to your pages. It can be used whether you use the canvas or SVG libraries or entirely standalone.

Read more »

 

Download
Get the latest version of RGraph (version 7.10, 18th January 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 »

 

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]