Skip to content

Instantly share code, notes, and snippets.

@stuartchaney
Created April 9, 2011 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartchaney/911483 to your computer and use it in GitHub Desktop.
Save stuartchaney/911483 to your computer and use it in GitHub Desktop.
ruby embedded highcharts js
<div id="fb_chart" style="width: 100%; height: 300px;"></div>
<% content_for :javascripts do %>
<script type="text/javascript">
new Highcharts.Chart({
chart: { renderTo: 'fb_chart', defaultSeriesType: 'area' },
title: { text: 'Facebook Publish to Token Rate per Day' },
xAxis: { type: 'datetime' },
yAxis: {
title: { text: false }
},
tooltip: {
formatter: function () {
return Highcharts.dateFormat("%B %e %Y", this.x) + ': ' +
+ Highcharts.numberFormat(this.y, 2);}
},
series: [{
name: "Total Tokens",
pointInterval: <%= 1.day * 1000 %>,
pointStart: <%= 3.weeks.ago.at_midnight.to_i * 1000 %>,
data: <%= (3.weeks.ago.to_date..Date.today).map { |date| FbToken.total_on(date).to_i}.inspect %>
},
{
name: "Published",
pointInterval: <%= 1.day * 1000 %>,
pointStart: <%= 3.weeks.ago.at_midnight.to_i * 1000 %>,
data: <%= (3.weeks.ago.to_date..Date.today).map { |date| FbToken.published.total_on(date).to_i}.inspect %>
}]
});
</script>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment