Created
October 29, 2013 03:03
-
-
Save wheaties/7208576 to your computer and use it in GitHub Desktop.
Backbone-Nvd3 Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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