About
RGraph is a JavaScript charts library based on
HTML5 SVG and canvas. RGraph is mature (over 17 years
old) and has a wealth of features making it an ideal
choice to use for showing charts on your website.
Version 7 released
Version 7 (released in August 2025) is the latest version of RGraph and
brings with it a big improvement in the quality
of the text that's rendered on canvas charts.
This new improvement in text rendering is
the major focus in this release. Read more
about the new scaling feature at the link below.
New HTML datagrid
In the April 2025 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.00, 12th August 2025) 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.Post-processing on a Bar chart
This Bar chart uses the custom RGraph draw event to add
some highlighting to each bar.
There's an svg version of this chart in
the download archive.
The highlighting is added using the draw event (which is triggered at the end of the draw function) so the coordinates of the bars are available.
The gradient is created using this bit of code, which uses an RGraph function for creating gradients easily:
obj.context.fillStyle = RGraph.linearGradient({ object: obj, // The chart object x1: 0, y1: 0, x2: 0, y2: 250, // strartX, startY, endX, endY colors: [ 'rgba(255,255,255,.75)', // Start color 'rgba(255,255,255,0)' // End color ] });
The responsive function reduces the size of the text, turns off axes and the shadow and removes the css float from the canvas tag.
This goes in the documents header:
<script src="RGraph.common.core.js"></script> <script src="RGraph.bar.js"></script>Put this where you want the chart to show up:
<div style="float: left"> <canvas id="cvs" width="600" height="250">[no canvas support]</canvas> </div>This is the code that generates the chart - it should be placed AFTER the canvas tag(s):
<script> // Create the bar chart just like a normal grouped bar chart new RGraph.Bar({ id: 'cvs', data: [[47,75],[32,74],[71,85],[25,19],[23,71],[81,59],[43,130],[23,20]], options: { marginLeft: 50, colors: ['#494949','#35A0DA'], xaxisLabels: ['Alf','Bert','Craig','Dan','Edgar','Fred','Gary','Harry'], yaxisLabelsCount: 3, yaxisTickmarksCount: 3, backgroundGridHlinesCount: 3, backgroundGridVlines: false, backgroundGridBorder: false, colorsStroke: 'rgba(0,0,0,0)', shadowOffsety: -3, responsive: [ {maxWidth: null,width:600,height:300,options: {textSize:14,marginInner: 5,shadow:true, xaxis: false,yaxis: false,}, parentCss: {'float': 'left',textAlign:'none'}}, {maxWidth: 900, width:400,height:200,options: {textSize:10,marginInner: 2,shadow:false,xaxis: false,yaxis: false,}, parentCss: {'float': 'none',textAlign:'center'}} ], // Now use the draw event and the coordinates that were created when // the chart was drawn to add highlighting to the left side of each // bar. The highlighting is graduated from semi-opaque white at the top // to fully transparent white at the bottom. events: { function (obj) { var len = obj.coords.length; for (var i=0; i<len; ++i) { // Get the coordinates for each bar - full height but only half // width. var x = obj.coords[i][0], y = obj.coords[i][1], w = obj.coords[i][2] / 2, h = obj.coords[i][3]; // Create the gradient using an RGraph API function obj.context.fillStyle = RGraph.linearGradient({ object: obj, x1: 0, y1: 0, x2: 0, y2: 250, colors: ['rgba(255,255,255,.75)','rgba(255,255,255,0)'] }); // Draw the highlight rectangle obj.context.fillRect(x,y,w,h) } } } } }).draw(); </script>