Skip to content

Instantly share code, notes, and snippets.

@klaemo
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klaemo/d9e1d38c32a187543de6 to your computer and use it in GitHub Desktop.
Save klaemo/d9e1d38c32a187543de6 to your computer and use it in GitHub Desktop.
starplot.js
AppView.renderSubview(starplot)
-> starplot.initialize()
-> starplot.render() (automatisch aufgerufen durch AppView.rendersubview)
-> starplot.renderWithTemplate() (aufgerufen in starplot.render())
// jetzt exisitert das HTML element starplot.el inklusive svg
-> d3.select()...
var View = require('ampersand-view')
var d3 = require('d3')
var template = require('../templates/routes.jade')
// make this the general app view
var routes = View.extend({
template: template,
events: {
'click button': 'render'
},
initialize: function () {
console.log('hello')
},
render: function () {
this.renderWithTemplate(this)
var svg = d3.select(this.query('svg'))
svg.append('circle')
.attr('cx', 20)
.attr('cy', 20)
.attr('r', 10)
console.log('hi')
return this
}
})
module.exports = routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment