An SVG Bar chart showing the inflation rate over the past year
This goes in the documents header:
<script src="RGraph.svg.common.core.js"></script>
<script src="RGraph.svg.bar.js"></script>
Put this where you want the chart to show up:
<div style="width: 750px; height: 300px" id="chart-container"></div>
This is the code that generates the chart:
<script>
data = [3.1,3,3,2.7,2.5,2.4,2.4,2.4,2.5,2.7,2.4,2.4];
max = 3.5;
bar = new RGraph.SVG.Bar({
id: 'chart-container',
data: data,
options: {
xaxisLabels: ['','','Jan 2018','','','Apr 2018','','','Jul 2018','','','Oct 2018'],
xaxisTextBold: true,
xaxis: false,
yaxisScaleMax: 3.5,
yaxisScaleDecimals: 1,
yaxisScaleUnitsPost: '%',
yaxis: false,
labelsAbove: true,
labelsAboveDecimals: 1,
labelsAboveUnitsPost: '%',
title: 'UK Inflation over the past 12 months',
textSize: 9,
hmargin: 10,
colors: ['Gradient(#4682B4:#76B2E4)'],
backgroundGridDotted: true,
shadow: true
}
}).draw();
</script>