Skip to content

Instantly share code, notes, and snippets.

@mohitjain1
Created February 23, 2013 17:27
Show Gist options
  • Save mohitjain1/5020582 to your computer and use it in GitHub Desktop.
Save mohitjain1/5020582 to your computer and use it in GitHub Desktop.
daily stats
<%= javascript_include_tag 'highcharts' %>
<%= javascript_include_tag 'exporting' %>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'growth_rate'
},
title: {
text: 'Growth Charts - Users, Companies, Reports, Groups'
},
xAxis: {
type: 'datetime'
},
yAxis: {
title: {
text: 'Counts'
}
},
tooltip: {
formatter: function() {
return ''+
Highcharts.dateFormat('%e. %b', this.x) +' -> '+ this.y;
}
},
plotOptions: {
spline: {
lineWidth: 4,
states: {
hover: {
lineWidth: 5
}
},
marker: {
enabled: false,
states: {
hover: {
enabled: true,
symbol: 'circle',
radius: 5,
lineWidth: 1
}
}
}
}
},
series: [
{
name: 'Total Signups Today',
pointInterval: <%= 1.day * 1000 %>,
pointStart: <%= 30.days.ago.to_i * 1000 %>,
data: <%= User.daily_records_counts_array_in_past_n_days %>
}, {
name: 'Total Company Created Today',
pointInterval: <%= 1.day * 1000 %>,
pointStart: <%= 30.days.ago.to_i * 1000 %>,
data: <%= Company.daily_records_counts_array_in_past_n_days %>
}
, {
name: 'Total Reports Created Today',
pointInterval: <%= 1.day * 1000 %>,
pointStart: <%= 30.days.ago.to_i * 1000 %>,
data: <%= Report.daily_records_counts_array_in_past_n_days %>
}
, {
name: 'Total Groups Created Today',
pointInterval: <%= 1.day * 1000 %>,
pointStart: <%= 30.days.ago.to_i * 1000 %>,
data: <%= Group.daily_records_counts_array_in_past_n_days %>
}
, {
name: 'Total Submissions Created Today',
pointInterval: <%= 1.day * 1000 %>,
pointStart: <%= 30.days.ago.to_i * 1000 %>,
data: <%= Submission.daily_records_counts_array_in_past_n_days %>
}
, {
name: 'Total Activities Created Today',
pointInterval: <%= 1.day * 1000 %>,
pointStart: <%= 30.days.ago.to_i * 1000 %>,
data: <%= Activity.daily_records_counts_array_in_past_n_days %>
}
]
,
navigation: {
menuItemStyle: {
fontSize: '10px'
}
}
});
});
});
</script>
<div id="growth_rate" style="min-width: 400px; height: 400px;"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment