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.
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
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.
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?
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.Updated multi-color Line chart demo
Written by Richard Heyes, RGraph author, on 17th August 2022
Here's an updated version of a demo that's already
in the download archive.
The colors have been changed, tickmarks added, it
now uses the es6 spread operator when
copying the configuration to the second chart, a
key has been added and the way that the gradients
are setup (using the beforedraw
RGraph event). All the code for it is shown below
and it should work as-is with version 6.08.
<script>
// The data for both of the Line chart objects
data = [8,4,6,2,1,5,3,3,4,8,9,8,4,1,3,4,7,8,8,5,6,4,1,2,3,4,2,3,1,5,3,5,1,5,6,8,7,9];
// Draw a Line chart that shows the fill of the chart
line = new RGraph.Line({
id: 'cvs',
data: data,
options: {
backgroundGrid: false,
xaxisLabels: [
'','Q1\n2014','', '','Q2\n2014','',
'','Q3\n2014','', '','Q4\n2014','',
'','Q1\n2015','', '','Q2\n2015','',
'','Q3\n2015','', '','Q4\n2015',''
],
filled: true,
spline: true,
yaxisScaleUnitsPost: '%',
marginLeft: 50,
marginTop: 50,
marginBottom: 50,
textColor: 'gray',
colors: ['transparent'],
keyLabelsSize: 16,
linewidth: 1,
textSize: 16,
textFont: "'Calibri Light', sans-serif",
events: {
beforedraw: function (obj)
{
var height = obj.canvas.height;
// Create the gradient that is used as the fill color
grad = obj.context.createLinearGradient(0,50,0,height - 50);
grad.addColorStop(0, '#0003');
grad.addColorStop(0.2, '#0003');
grad.addColorStop(0.2, '#f0f3');
grad.addColorStop(0.4, '#f0f3');
grad.addColorStop(0.4, '#0a03');
grad.addColorStop(0.6, '#0a03');
grad.addColorStop(0.6, '#00f3');
grad.addColorStop(0.8, '#00f3');
grad.addColorStop(0.8, '#f003');
grad.addColorStop(1.0, '#f003');
// Apply the gradient to the charts fill
obj.set({
filledColors: [grad]
});
}
}
}
}).draw();
// Now create and draw the second, non-filled line that sits on
// top of the fill.
line2 = new RGraph.Line({
id: 'cvs',
data: data,
options: {
...line.properties,
filled: false,
labels: null,
yaxisLabels: false,
backgroundGrid: false,
tickmarksStyle: 'filledcircle',
key: null,
key: ['V Low','Low','Normal','High','V high'],
keyColors: ['red','blue','#0a06','#f0f','black'],
keyPosition: 'margin',
keyPositionX: 65,
keyColorShape: 'circle',
responsive: [
{maxWidth: null, width: 700, height: 300,options: {linewidth:2}},
{maxWidth: 900, width: 500, height: 200,options: {linewidth:1}}
],
events: {
beforedraw: function (obj)
{
var height = obj.canvas.height;
// Create the gradient that is used as the stroke color
grad = obj.context.createLinearGradient(0,50,0,height - 50);
grad.addColorStop(0, '#000');
grad.addColorStop(0.2, '#000');
grad.addColorStop(0.2, '#f0f');
grad.addColorStop(0.4, '#f0f');
grad.addColorStop(0.4, '#0a0');
grad.addColorStop(0.6, '#0a0');
grad.addColorStop(0.6, '#00f');
grad.addColorStop(0.8, '#00f');
grad.addColorStop(0.8, '#f00');
grad.addColorStop(1.0, '#f00');
obj.set({
colors: [grad]
});
}
}
}
}).draw();
</script>