// Generated by CoffeeScript 1.10.0 (function() { window.Table = Backbone.D3View.extend({ namespace: null, tagName: 'table', initialize: function() { return this.listenTo(this.model, 'change:rows', this.render); }, render: function() { var data_cells, header, header_cells, rows, rows_data; rows_data = this.model.get('rows'); header = rows_data.length > 0 ? Object.keys(rows_data[0]) : []; this.d3el.selectAll('*').remove(); header_cells = this.d3el.append('tr').selectAll('th').data(header); header_cells.enter().append('th').text(function(d) { return d; }); rows = this.d3el.append('tbody').selectAll('tr').data(rows_data); rows.enter().append('tr'); data_cells = rows.selectAll('td').data(function(d) { return Object.keys(d).map(function(k) { return d[k]; }); }); return data_cells.enter().append('td').text(function(d) { return d; }); } }); }).call(this);