Created
November 10, 2009 22:53
-
-
Save nikz/231347 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript" src="http://www.google.com/jsapi"></script> | |
| <script type="text/javascript"> | |
| google.load("visualization", "1", {packages:["linechart", "columnchart"]}); | |
| google.setOnLoadCallback(drawChart); | |
| function drawChart() { | |
| var data = new google.visualization.DataTable(); | |
| data.addColumn('string', 'Day'); | |
| data.addColumn('number', 'Logged Entries'); | |
| data.addRows(15); | |
| <% (0..14).each do |i| %> | |
| <% time = (14 - i).days.ago %> | |
| <% entries = @logged_entries[time.strftime("%d%m%Y")] || 0 %> | |
| data.setValue(<%= i %>, 0, '<%= time.strftime("%a %e %b") %>'); | |
| data.setValue(<%= i %>, 1, <%= entries %>); | |
| <% end %> | |
| var chart = new google.visualization.LineChart(document.getElementById('entries_per_day')); | |
| chart.draw(data, {width: 1080, height: 320, legend : 'none', axisFontSize : 11 }); | |
| var data = new google.visualization.DataTable(); | |
| data.addRows(<%= Account::TRIAL_SEGMENTS.size %>); | |
| data.addColumn("string", "Segment Name"); | |
| data.addColumn("number", "Number of Accounts"); | |
| <% Account::TRIAL_SEGMENTS.each_with_index do |segment, i| %> | |
| data.setValue(<%= i %>, 0, "<%= segment.humanize %>"); | |
| data.setValue(<%= i %>, 1, <%= Account.free_trial.send(segment).all.size %>); | |
| <% end %> | |
| var chart = new google.visualization.ColumnChart(document.getElementById('trial_segments')); | |
| chart.draw(data, {width: 575, height: 320, is3D: false, title: 'Trial Segments', legend: 'none' }); | |
| var data = new google.visualization.DataTable(); | |
| data.addRows(<%= Account::PAYING_SEGMENTS.size %>); | |
| data.addColumn("string", "Segment Name"); | |
| data.addColumn("number", "Number of Accounts"); | |
| <% Account::PAYING_SEGMENTS.each_with_index do |segment, i| %> | |
| data.setValue(<%= i %>, 0, "<%= segment.humanize %>"); | |
| data.setValue(<%= i %>, 1, <%= Account.with_subscription.send(segment).all.size %>); | |
| <% end %> | |
| var chart = new google.visualization.ColumnChart(document.getElementById('paying_segments')); | |
| chart.draw(data, {width: 495, height: 320, is3D: false, title: 'Paying Segments', legend: 'none' }); | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment