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.
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.
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:
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>