An SVG Waterfall chart using the Google Sheets connector
This goes in the documents header:
<script src="RGraph.svg.common.core.js"></script>
<script src="RGraph.svg.common.sheets.js"></script>
<script src="RGraph.svg.waterfall.js"></script>
Put this where you want the chart to show up:
<div style="width: 1000px; height: 300px" id="chart-container"></div>
This is the code that generates the chart:
<script>
new RGraph.Sheets('1ncvARBgXaDjzuca9i7Jyep6JTv9kms-bbIzyAxbaT0E', function (sheet)
{
var data = sheet.get('B2:B13'),
labels = sheet.get('A2:A13');
for (var i=0; i<labels.length; i+=2) {
labels[i] = "\n" + labels[i];
}
labels.push('Total');
new RGraph.SVG.Waterfall({
id: 'chart-container',
data: data,
options: {
gutterTop: 50,
textSize: 9,
xaxisLabels: labels,
tooltips: labels,
yaxis: false,
backgroundGridColor: '#eee',
backgroundGridVlines: false,
backgroundGridBorder: false,
strokestyle: '#aaa',
yaxisLabelsCount: 6,
xaxisColor: '#333',
title: 'Cumulative total of widgets sold by Brian',
titleSubtitle: 'Numbers are sales by store only',
titleSubtitleItalic: true,
labelsAbove: true,
labelsAboveUnitsPost: 'pc'
}
}).draw();
});
</script>
« Back