A page showing the various Y scale variations of the SVG HBar chart
This goes in the documents header:
<script src="RGraph.svg.common.core.js"></script>
<script src="RGraph.svg.hbar.js"></script>
Put this where you want the chart to show up:
<div style="width: 400px; height: 450px" id="chart-container1"></div></div>
<div style="width: 400px; height: 450px" id="chart-container2"></div></div>
<div style="width: 500px; height: 550px" id="chart-container3"></div></div>
<div style="width: 500px; height: 450px" id="chart-container4"></div></div>
<div style="width: 500px; height: 450px" id="chart-container5"></div></div>
<div style="width: 500px; height: 450px" id="chart-container6"></div></div>
This is the code that generates the chart:
<script>
new RGraph.SVG.HBar({
id: 'chart-container1',
data: [-5,-7,-9,-11,-13,-15],
options: {
gutterLeftAutosize: false,
gutterLeft: 15,
gutterRight: 50,
xaxisMax: -5,
xaxisMin: -15,
yaxisLabels: ['Harry','Lucy','Pete','Nick','Al','John'],
title: 'Both min and max negative',
}
}).draw();
new RGraph.SVG.HBar({
id: 'chart-container2',
data: [0,1,2,3,4,5,6],
options: {
xaxisMax: 10,
yaxisLabels: ['Harry','Lucy','Pete','Nick','Al','John','Kevin'],
title: 'Min set to zero and max positive',
vmargin: 10,
backgroundGridHlines: false,
backgroundGridBorder: false,
xaxis: false,
yaxis: false
}
}).draw();
new RGraph.SVG.HBar({
id: 'chart-container3',
data: [10,9,8,7,6,5,4,3,2,1,0,-1,-2,-3,-4,-5,-6,-7,-8,-9,-10],
options: {
xaxisMin: 'mirror',
yaxisLabels: [
'Harry','Lucy','Pete','Nick','Al','John','Kerridge',
'Harry','Lucy','Pete','Nick','Al','John','Kerridge',
'Harry','Lucy','Pete','Nick','Al','John','Kerridge'
],
title: 'Min negative and max positive',
backgroundGridHlines: false,
backgroundGridBorder: false,
colors: [
'red', 'blue','green',
'red', 'blue','green',
'red', 'blue','green',
'red', 'blue','green',
'red', 'blue','green',
'red', 'blue','green',
'red', 'blue','green'
],
colorsSequential: true,
}
}).draw();
new RGraph.SVG.HBar({
id: 'chart-container4',
data: [5,6,7,8,9,10],
options: {
gutterRight: 190,
title: 'Both min and max above zero',
yaxisLabels: ['Ken','Larry','Kevin','Jobe','Lucy','John'],
xaxisMin: 5,
xaxisMax: 10,
backgroundGridBorder: false,
backgroundGridHlines: false
}
}).draw();
new RGraph.SVG.HBar({
id: 'chart-container5',
data: [-1,-2,-3,-4,-5,-6,-7,-8,-9,-10],
options: {
gutterLeftAutosize: false,
gutterLeft: 15,
gutterRight: 50,
title: 'Zero max and negative min',
yaxisLabels: ['Ken','Larry','Kevin','Jobe','Lucy','John'],
xaxisMin: -10,
xaxisMax: 0,
backgroundGridBorder: false,
backgroundGridHlines: false
}
}).draw();
new RGraph.SVG.HBar({
id: 'chart-container6',
data: [-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],
options: {
colors: ['Gradient(red:white:red:red:#c00:#600)'],
vmargin: 1,
title: 'Offset axis, negative min positive max',
xaxisMin: -5,
xaxisMax: 20,
backgroundGridBorder: false,
backgroundGridHlines: false
}
}).draw();
</script>
« Back