/home/mip/mip/public/template/AdminLTE/plugins/RGraph/demos/bar-stacked.html
<!DOCTYPE html >
<html>
<head>
<link rel="stylesheet" href="demos.css" type="text/css" media="screen" />
<script src="../libraries/RGraph.common.core.js" ></script>
<script src="../libraries/RGraph.common.key.js" ></script>
<script src="../libraries/RGraph.bar.js" ></script>
<title>A stacked bar chart</title>
<meta name="robots" content="noindex,nofollow" />
<meta name="description" content="A demonstration of a stacked Bar chart. The chart uses the ondraw event to add some text to the chart" />
</head>
<body>
<h1>A stacked bar chart</h1>
<p>
This is a stacked Bar chart. The labels that are inside the bars are achieved by using a DOM1 style ondraw event.
</p>
<canvas id="cvs" width="700" height="350">[No canvas support]</canvas>
<script>
window.onload = function ()
{
var canvas = document.getElementById("cvs");
var bar = new RGraph.Bar({
id: 'cvs',
data: [[5.33,2.33,3.32],[3.42,2.23,4.23],[4.23,3.23,4.99], [7.99,2.98,2.35], [2.75,1.02,5.24]],
options: {
grouping: 'stacked',
labels: ['John','James','Fred','Luke','Luis'],
labelsAbove: true,
labelsAboveDecimals: 2,
linewidth: 2,
strokestyle: 'white',
colors: ['Gradient(#4572A7:#66f)','Gradient(#AA4643:white)','Gradient(#89A54E:white)'],
shadowOffsetx: 1,
shadowOffsety: 1,
shadowBlur: 10,
hmargin: 25,
gutterLeft: 45,
backgroundGridVlines: false,
backgroundGridBorder: false,
key: ['Monday','Tuesday','Wednesday'],
keyColors: ['blue','#c00','#0c0'],
keyPosition: 'gutter',
keyPositionX: canvas.width - 300,
keyPositionY: 18,
keyPositionGutterBoxed: true,
axisColor: '#ccc',
noyaxis: true,
textAccessible: true
}
}).on('draw', function (obj)
{
for (var i=0; i<obj.coords.length; ++i) {
obj.context.fillStyle = 'white';
RGraph.Text2(obj.context, {
font:'Verdana',
'size':10,
'x':obj.coords[i][0] + (obj.coords[i][2] / 2),
'y':obj.coords[i][1] + (obj.coords[i][3] / 2),
'text':obj.data_arr[i].toString(),
'valign':'center',
'halign':'center'
});
}
}).draw();
};
</script>
<p></p>
This goes in the documents header:
<pre class="code">
<script src="RGraph.common.core.js"></script>
<script src="RGraph.common.key.js"></script>
<script src="RGraph.bar.js"></script>
</pre>
Put this where you want the chart to show up:
<pre class="code">
<canvas id="cvs" width="600" height="250">
[No canvas support]
</canvas>
</pre>
This is the code that generates the chart:
<pre class="code">
<script>
window.onload = function ()
{
var canvas = document.getElementById("cvs");
var bar = new RGraph.Bar({
id: 'cvs',
data: [[5.33,2.33,3.32],[3.42,2.23,4.23],[4.23,3.23,4.99], [7.99,2.98,2.35], [2.75,1.02,5.24]],
options: {
grouping: 'stacked',
labels: ['John','James','Fred','Luke','Luis'],
labelsAbove: true,
labelsAbovedecimals: 2,
linewidth: 2,
strokestyle: 'white',
colors: ['Gradient(#4572A7:#66f)','Gradient(#AA4643:white)','Gradient(#89A54E:white)'],
shadowOffsetx: 1,
shadowOffsety: 1,
shadowBlur: 10,
hmargin: 25,
gutterLeft: 45,
backgroundGridVlines: false,
backgroundGridBorder: false,
key: ['Monday','Tuesday','Wednesday'],
keyColors: ['blue','#c00','#0c0'],
keyPosition: 'gutter',
keyPositionX: canvas.width - 300,
keyPositionY: 18,
keyPositionGutterBoxed: true,
axisColor: '#ccc',
noyaxis: true,
textAccessible: true
}
}).on('draw', function (obj)
{
for (var i=0; i<obj.coords.length; ++i) {
obj.context.fillStyle = 'white';
RGraph.Text2(obj.context, {
font:'Verdana',
'size':10,
'x':obj.coords[i][0] + (obj.coords[i][2] / 2),
'y':obj.coords[i][1] + (obj.coords[i][3] / 2),
'text':obj.data_arr[i].toString(),
'valign':'center',
'halign':'center'
});
}
}).draw();
};
</script>
</pre>
<p>
<a href="https://www.facebook.com/sharer/sharer.php?u=http://www.rgraph.net" target="_blank" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=http://www.rgraph.net', null, 'top=50,left=50,width=600,height=368'); return false"><img src="../images/facebook-large.png" width="200" height="43" alt="Share on Facebook" border="0" title="Visit the RGraph Facebook page" /></a>
<a href="https://twitter.com/_rgraph" target="_blank" onclick="window.open('https://twitter.com/_rgraph', null, 'top=50,left=50,width=700,height=400'); return false"><img src="../images/twitter-large.png" width="200" height="43" alt="Share on Twitter" border="0" title="Mention RGraph on Twitter" /></a>
</p>
<p>
<a href="./">« Back</a>
</p>
</body>
</html>