Skip to content

Instantly share code, notes, and snippets.

@wheaties
Created October 29, 2013 03:03
Show Gist options
  • Save wheaties/7208576 to your computer and use it in GitHub Desktop.
Save wheaties/7208576 to your computer and use it in GitHub Desktop.
Backbone-Nvd3 Example
var Bullet = {
orient: function(arg){
this.chart = this.chart.orient(arg);
return this;
},
ranges: function(arg){
this.chart = this.chart.ranges(arg);
return this;
},
markers: function(arg){
this.chart = this.chart.markers(arg);
return this;
},
measures: function(arg){
this.chart = this.chart.measures(arg);
return this;
},
forceX: function(arg){
this.chart = this.chart.forceX(arg);
return this;
}
}
var BulletChartView = Backbone.View.extend({
initialize: function(model){
var self = this;
this.model = model;
this.listenTo(model, 'change', function(){
self.render();
});
this.chart = bullet();
},
render: function(){
//I feel lazy.
}
});
//See, no need for 'options' method. Direct NVD3 access to set up chart just like you would before.
_.extend(BulletChartView.prototype, Bullet);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment