A 3D Pie chart with a HTML key
This goes in the documents header:
<script src="RGraph.common.core.js"></script>
<script src="RGraph.common.key.js"></script>
<script src="RGraph.pie.js"></script>
Put this where you want the chart to show up:
<div id="container" style="display: inline-block; position: relative">
<canvas id="cvs" width="350" height="350">[No canvas support]</canvas>
</div>
This is the code that generates the chart:
<script>
var colors = ['red','yellow','blue','cyan','green','pink','white','#ddd'];
var key = RGraph.HTML.Key('container',
{
colors: colors,
labels:['Louise', 'Fred', 'Charley', 'Lucy','Kevin','Luis','Pete','Jake'],
tableCss: {
position: 'absolute',
top: '50%',
right: '-70px',
transform: 'translateY(-50%)'
}
});
new RGraph.Pie({
id: 'cvs',
data: [4,8,4,6,5,3,2,5],
options: {
gutterLeft: 50,
gutterRight: 50,
linewidth: 0,
strokestyle: 'rgba(0,0,0,0)',
colors: colors,
variant: 'pie3d',
radius: 100,
radius: 80,
shadowOffsety: 5,
shadowColor: '#aaa',
exploded: [,,20]
}
}).draw();
</script>
« Back