Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 0aae73fbbe
Fetching contributors…

Cannot retrieve contributors at this time

41 lines (39 sloc) 1.675 kB
You are free to copy and use this sample in accordance with the terms of the
Apache license (
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>D3 Visualization API Sample</title>
<script src=""></script>
<script type="text/javascript" src="libs/underscore-1.1.6.js"></script>
<script type="text/javascript" src="libs/backbone.js"></script>
<script type="text/javascript" src="libs/d3.min.js"></script>
<script type="text/javascript" src="backbone.cartodb.js"></script>
<script type="text/javascript" src="d3.cartodb.js"></script>
<link href='css/cartodb.d3.default.css' rel='stylesheet' type='text/css' />
<style type="text/css">
#cartodb_d3 {
float: left; width: 800px;
<script type="text/javascript">
var CartoDB = Backbone.CartoDB({user: 'examples'});
var EarthQuakes = CartoDB.CartoDBCollection.extend({
sql: function() {
return "select month,avg(magnitude) as magnitude from earthquakes group by month order by month asc";
var eq = new EarthQuakes();
var CartoD3 = Backbone.CartoD3(eq);
$(document).ready(function() {
var barchart = new CartoD3.BarChart({ el: $("#cartodb_d3"), variable: 'magnitude', label: 'month', title: "Global Earthquake Magnitude by Month"});
<body style="font-family: Arial;border: 0 none;">
<div id="cartodb_d3"></div>
Jump to Line
Something went wrong with that request. Please try again.