Skip to content

Instantly share code, notes, and snippets.

@hkouns
Created February 22, 2016 15:28
Show Gist options
  • Save hkouns/f68e059af3ae0e0b0107 to your computer and use it in GitHub Desktop.
Save hkouns/f68e059af3ae0e0b0107 to your computer and use it in GitHub Desktop.
Very Rough
import datetime
class AttendTrend(object):
pass
class ContributionTrend(object):
pass
Data.AttendTrendList = []
Data.ContributionTrendList = []
Data.days = 7
Data.lastSun = q.LastSunday
one_days = datetime.timedelta(days=1)
five_days = datetime.timedelta(days=5)
seven_days = datetime.timedelta(days=7)
thirty = datetime.timedelta(days=30)
D1 = datetime.date.today()
D2 = D1 - seven_days
D3 = D2 - seven_days
fund = 0
startweek=0
weekbefore = 7
Data.NumPres = []
Data.Dates = []
Data.contribs = []
Data.Paired = []
for i in range(26):
x = AttendTrend()
y = ContributionTrend()
x.date = D1
x.year = D1.year
x.month = D1.month
x.day = D1.day
x.present = q.NumPresentDateRange(1114, 41, 0, D1, Data.days)
y.date = D1
y.year = D1.year
y.month = D1.month
y.day = D1.day
y.contribs = q.ContributionTotals(weekbefore, startweek, fund)
Data.AttendTrendList.append(x)
Data.ContributionTrendList.append(y)
startweek = startweek + 7
weekbefore = weekbefore + 7
D1 = D1 - seven_days
template = """
<style>
#vitalStats { width:auto; margin-left:auto; margin-right:auto; text-align: Center;}
#vitalStats td { text-align: Center; }
</style>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization Animation Example
</title>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {packages: ['corechart'], language:'en'});
</script>
<script type="text/javascript">
function init() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('date');
data.addColumn('number');
{{#each AttendTrendList}}
data.addRow([new Date({{Fmt year "G0"}}, {{Fmt month "G0"}}, {{Fmt day "G0"}}), {{Fmt present "G0"}}]);
{{/each}}
// Create and populate the data table.
var data1 = new google.visualization.DataTable();
data1.addColumn('date');
data1.addColumn('number');
{{#each ContributionTrendList}}
data1.addRow([new Date({{Fmt year "G0"}}, {{Fmt month "G0"}}, {{Fmt day "G0"}}), {{Fmt contribs "G0"}}]);
{{/each}}
var options = {title: "Worship Attendance Trend",
width:400, height:240,
legend:'none',
legend:'none',
strictFirstColumnType: true,
hAxis: {title: "Week", format:'MMM yy'},
vAxis: {title: "Number Present"}};
var options1 = {title: "Total Contributions Trend",
width:400, height:240,
legend:'none',
legend:'none',
strictFirstColumnType: true,
hAxis: {title: "Week", format:'MMM yy'},
vAxis: {title: "Total Contributions ($)"}};
// Create and draw the visualization.
var chart = new google.visualization.LineChart(document.getElementById('chart_div')).
draw(data, options);
// Create and draw the visualization.
var chart1 = new google.visualization.LineChart(document.getElementById('chart1_div')).
draw(data1, options1);
}
google.setOnLoadCallback(init);
</script>
</head>
<body style="font-family: Arial;border: 0 none; width: 400px; margin:0px; padding:0px">
<BR>
<table id="vitalStats" class="table">
<tr><th colspan="2"><br>Vital Stats Trends</th></tr>
<tr><td>
<BR>
<div id="chart_div" style="width: 400px; height: 240px;"></div>
</td></tr>
<tr><td>
<div id="chart1_div" style="width: 400px; height: 240px;"></div>
</td></tr>
<tr><td>
<B> Date : Present</B>
{{#each AttendTrendList}}<li>{{date}} : {{present}} </li>{{/each}}
</td></tr>
<tr><td>
<B> Date : Contributions</B>
{{#each ContributionTrendList}}<li>{{date}} : {{Fmt contribs "C"}}</li>{{/each}}
</td></tr>
</table>
</body>
"""
print model.RenderTemplate(template)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment