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.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.
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.
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.
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,
backgroundGridColor: '#ddd',
backgroundGridVlines: false,
backgroundGridBorder: false,
xaxis: false,
yaxis: false,
spline: true,
yaxisScaleUnitsPost: '%',
marginLeft: 50,
marginTop: 50,
marginBottom: 50,
textColor: 'gray',
colors: ['rgba(0,0,0,0)'],
shadow: false,
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,
xaxis: false,
yaxis: false,
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>