Skip to content

Instantly share code, notes, and snippets.

@dstufft
Created April 20, 2012 16:25
Show Gist options
  • Save dstufft/2430111 to your computer and use it in GitHub Desktop.
Save dstufft/2430111 to your computer and use it in GitHub Desktop.
<script>
var palette = new Rickshaw.Color.Palette({scheme: 'spectrum2000'});
var graph = new Rickshaw.Graph.Ajax({
element: $("#download-chart .chart")[0],
renderer: 'area',
stroke: true,
dataURL: '/stats/Django/delta.json',
onData: function(d){
// Hide the Spinner
$("#download-chart .loading").removeClass("loading");
return $.map(d, function(i){ i["color"] = palette.color(); return i; });
},
onComplete: function(s){
var hoverDetail = new Rickshaw.Graph.HoverDetail({
graph: s.graph,
xFormatter: function(x) { var d = new Date(x*1000); return "Week of " + d.toString("MMM d"); },
yFormatter: function(y) { return parseInt(y) + " downloads"; }
});
var ticksTreatment = 'glow';
var xAxis = new Rickshaw.Graph.Axis.Time({
graph: s.graph,
timeUnit: 'week',
ticksTreatment: ticksTreatment
});
var yAxis = new Rickshaw.Graph.Axis.Y({
graph: s.graph,
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
ticksTreatment: ticksTreatment
});
xAxis.render();
yAxis.render();
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment