A Line chart demonstrating the axis options
This goes in the documents header:
<script src="RGraph.common.core.js"></script>
<script src="RGraph.line.js"></script>
Put this where you want the chart to show up:
<button onclick="obj = getObject(); obj.set('xaxisPosition', obj.get('xaxisPosition') == 'bottom' ? 'center' : 'bottom'); RGraph.Redraw();">Toggle the X axis position</button>
<button onclick="obj = getObject(); obj.set('yaxisPosition', obj.get('yaxisPosition') == 'left' ? 'right' : 'left'); RGraph.Redraw();">Toggle the Y axis position</button>
<button onclick="obj = getObject(); obj.set('yaxisLabels', obj.get('yaxisLabels') ? false : true); RGraph.Redraw();">Toggle the Y axis labels</button>
<button onclick="obj = getObject(); obj.set('yaxisLabelsSpecific', obj.get('yaxisLabelsSpecific') ? null : ['High','Medium','Low']); RGraph.Redraw();">Toggle specific Y axis labels</button>
<button onclick="obj = getObject(); obj.set('yaxisScaleMin', obj.get('yaxisScaleMin') ? 0 : 50); RGraph.Redraw();">Toggle Y axis minimum (50) setting</button>
<button onclick="obj = getObject(); obj.set('xaxis', !obj.get('xaxis')); RGraph.Redraw();">Toggle X axis </button>
<button onclick="obj = getObject(); obj.set('xaxisLabels', obj.get('xaxisLabels') ? null : ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']); RGraph.redraw();">Toggle X labels</button>
<br />
<canvas id="cvs" width="900" height="400">
[No canvas support]
</canvas>
This is the code that generates the chart:
<script>
function getObject ()
{
return RGraph.ObjectRegistry.getFirstObjectByType('line');
}
line = new RGraph.Line({
id: 'cvs',
data: [65,70,74,64,58,94,75,64,68,78,64,63],
options: {
yaxisScaleMax: 100,
xaxisLabels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
xaxisPosition: 'center',
textSize: 16,
marginBottom: 45,
marginRight: 95,
marginLeft: 85
}
}).draw();
</script>