Skip to content

Instantly share code, notes, and snippets.

@austinbv
Created August 30, 2011 13:42
Show Gist options
  • Select an option

  • Save austinbv/1180912 to your computer and use it in GitHub Desktop.

Select an option

Save austinbv/1180912 to your computer and use it in GitHub Desktop.
default_chart_options = function() {
return {
chart: {
renderTo: "chart",
defaultSeriesType: 'pie'
},
xAxis: {
categories: []
},
credits: {
enabled: false
},
series: [
{
data: []
}
]
};
};
build_pie_chart = function(duration) {
var catagories, chart_options, first, name, trend;
chart_options = new default_chart_options;
first = true;
catagories = [];
chart_options.defaultSeriesType = 'pie';
chart_options.title = {
text: "Mentions of Justin Bieber and other World religions in the past " + duration
};
chart_options.tooltip = {
formatter: function() {
return "<b>" + this.point.name + "</b>:<br> was mentioned " + this.y + "<br> times and is <br> " + (Math.round(this.percentage)) + "% of tested traffic";
}
};
for (name in trends) {
trend = trends[name];
get_total(trend, duration, function(trend, total) {
chart_options.xAxis.categories.push(trend.title);
return chart_options.series[0].data.push({
name: trend.title,
y: total
});
});
}
return new Highcharts.Chart(chart_options);
};
defualt_chart_options =
chart:
renderTo: "chart"
defaultSeriesType: 'pie'
xAxis:
categories: []
credits:
enabled: false
series:[
data: []
]
build_pie_chart = (duration) ->
chart_options = defualt_chart_options
first = true
catagories = []
chart_options.title =
text: "Mentions of Justin Bieber and other World religions in the past #{duration}"
chart_options.tooltip =
formatter: ->
"<b>#{@point.name}</b>:<br>
was mentioned #{@y}<br>
times and is <br>
#{Math.round @percentage}% of tested traffic"
for name, trend of trends
get_total(trend, duration, (trend, total) ->
chart_options.xAxis.categories.push(trend.title)
chart_options.series[0].data.push(
name: trend.title
y: total
)
new Highcharts.Chart(chart_options)
)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment