By using two bar chart objects you can achieve a bar-in-bar effect. Here it shows the total amount of cars produced versus those sold. It's similar to a stacked or grouped Bar chart.
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:
<canvas id="cvs" width="600" height="250">
[No canvas support]
</canvas>
This is the code that generates the chart:
<script>
window.onload = function ()
{
var data = {}
data.shipped = [88000,88000,105000,105000,116000,116000,126000];
data.sold = [30000,54000,54000,62000,63000,68000,68000];
var bar1 = new RGraph.Bar({
id: 'cvs',
data: data.shipped,
options: {
gutterTop: 40,
gutterLeft: 70,
colors: ['rgba(0,0,255,0.2)'],
labels: ['Fred','Barney','Wilma','Betty','Dino','Bam-bam','Pebble'],
labelsAbove: data.shipped,
title: 'Total cars produced vs sold',
strokestyle: 'rgba(0,0,0,0)',
scaleZerostart: true,
textAccessible: true,
shadow: true
}
}).draw();
var bar2 = new RGraph.Bar({
id: 'cvs',
data: data.sold,
options: {
ymax: bar1.scale2.max,
gutterTop: 40,
gutterLeft: bar1.Get('gutterLeft'),
colors: ['pink'],
noaxes: true,
labelsAbove: true,
hmargin: 20,
ylabels: false,
backgroundGrid: false,
strokestyle: 'rgba(0,0,0,0)',
textAccessible: true,
shadow: true
}
}).draw();
};
</script>
<Back