This isn't supported natively but is quite easy to achieve with two canvas tags that are positioned so that one is on top of the other (as you can see below). The rear canvas draws the same Bar chart as the front one but without any data - so you just see the grid. The front canvas draws the bar chart - and then a custom ondraw event uses the standard canvas clearRect() function is used to return bits of the top canvas back to transparency - so that the grid on the rear canvas shows through.
<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="padding: 15px"> <canvas id="cvs1" width="750" height="250" style="position:absolute; top: 0; left: 0">[No canvas support]</canvas> <canvas id="cvs2" width="750" height="250" style="position:absolute; top: 0; left: 0">[No canvas support]</canvas> </div>This is the code that generates the chart:
<script> // This is the data for the chart var data = [4,5,2,1,3,4,4]; data.forEach(function (v, k, arr) { arr[k] = RGraph.arrayPad([], v, 1); }); // This will become the background. Then the white lines that create the // segmentation are drawn on the top canvas (which has the full Bar chart on). new RGraph.Bar({ id: 'cvs1', data: [0,0,0,0,0,0,0], options: { colors: ['rgba(0,0,0,0)'], noaxes: true, ylabels: false, gutterLeft: 75 } }).draw(); new RGraph.Bar({ id: 'cvs2', data: data, options: { gutterLeft: 75, grouping: 'stacked', shadow: false, colors: [ 'red', 'rgba(255,0,0,0.5)', 'rgba(255,0,0,0.25)', 'rgba(255,0,0,0.125)', 'rgba(255,0,0,0.0625)' ], colorsReverse: true, noaxes: true, backgroundGrid: false, scaleZerostart: false, ylabelsOffsety: 33, ylabelsOffsetx: -3, ylabelsSpecific: ['Level 5','Level 4','Level 3','Level 2','Level 1',''], labels: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'] } }).on('draw', function (obj) { var co = obj.context; RGraph.path2(co, 'cr 0 % 1000 10', obj.getYCoord(0) - 5); RGraph.path2(co, 'cr 0 % 1000 10', obj.getYCoord(1) - 5); RGraph.path2(co, 'cr 0 % 1000 10', obj.getYCoord(2) - 5); RGraph.path2(co, 'cr 0 % 1000 10', obj.getYCoord(3) - 5); RGraph.path2(co, 'cr 0 % 1000 10', obj.getYCoord(4) - 5); RGraph.path2(co, 'cr 0 % 1000 10', obj.getYCoord(5) - 5); }).draw(); </script>