Last active
August 29, 2015 14:00
-
-
Save mrosenberg/11403130 to your computer and use it in GitHub Desktop.
Responsive D3 charts in an Ember View
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
App.Chart = Ember.View.extend({ | |
tagName: 'svg', | |
reScale: function() { | |
d3.selectAll( this.svg[0][0].childNodes ).remove(); | |
Ember.run.scheduleOnce( 'afterRender', this, 'build' ); | |
}, | |
didInsertElement: function() { | |
var that = this; | |
$( window ).on( 'resize', function() { | |
Ember.run.debounce( that, that.reScale, 1000 ); | |
}); | |
Ember.run.scheduleOnce( 'afterRender', this, 'build' ); | |
}, | |
build: function() { | |
// D3 magic | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This destroys the chart and then renders it again. It would be possible to tween the data but that was not needed in this case.