diff --git a/src/view.js b/src/view.js index 671336af..6e6cf111 100644 --- a/src/view.js +++ b/src/view.js @@ -4,17 +4,18 @@ recline.DataExplorer = Backbone.View.extend({ tagName: 'div', className: 'data-explorer', template: ' \ -
\ - \ - \ - \ - \ - \ + \ ', events: { + 'change input[name="nav-toggle"]': 'navChange' }, initialize: function() { @@ -24,11 +25,28 @@ recline.DataExplorer = Backbone.View.extend({ this.dataTable = new recline.DataTable({ model: this.model }); + this.flotGraph = new recline.FlotGraph({ + model: this.model + }); + this.flotGraph.el.hide(); this.el.append(this.dataTable.el) + this.el.append(this.flotGraph.el); }, render: function() { $(this.el).html($(this.template)); + }, + + navChange: function(e) { + // TODO: really ugly and will not scale to more widgets ... + var widgetToShow = $(e.target).val(); + if (widgetToShow == 'datatable') { + this.flotGraph.el.hide(); + this.dataTable.el.show(); + } else if (widgetToShow == 'graph') { + this.flotGraph.el.show(); + this.dataTable.el.hide(); + } } }); @@ -43,6 +61,7 @@ recline.DataTable = Backbone.View.extend({ }, initialize: function() { + this.el = $(this.el); var that = this; this.model.fetch().then(function() { that.model.getRows().then(function(rows) { @@ -78,9 +97,9 @@ recline.FlotGraph = Backbone.View.extend({ // TODO: normalize css template: ' \ -
\ -
\ -
\ +
\ +
\ +
\

Help

\

To create a chart select a column (group) to use as the x-axis \ then another column (Series A) to plot against it.

\ @@ -90,25 +109,25 @@ recline.FlotGraph = Backbone.View.extend({
\
\
    \ -
  • \ +
  • \ \ \
  • \ -
  • \ +
  • \ \ \
  • \ -
  • \ +
  • \ \ \
  • \
\ -
\ - \ +
\ + \
\ -
\ - \ - \ +
\ + \ + \
\ \
\ @@ -119,6 +138,7 @@ recline.FlotGraph = Backbone.View.extend({ }, initialize: function() { + this.el = $(this.el); }, toTemplateJSON: function() { return {};