     @yScale = d3.scale.linear().domain @model.yDomain()
 
     @svg ?= d3.select(@$el[0]).append('svg')
-    @yAxisMarker = @svg.append('g')
-        .attr('class', 'y axis')
-        .attr('transform', "translate(#{@xPadding}, 0)")
+    if @yAxisVisible
+      @yAxisMarker = @svg.append('g')
+          .attr('class', 'y axis')
+          .attr('transform', "translate(#{@xPadding}, 0)")
+    else
+      @xPadding = 0
 
     @xAxisMarker = @svg.append('g')
         .attr('class', 'x axis')

    @xScale.range([@xPadding, @width - @xPadding])
    @yScale.range([@height - @yPadding, @yPadding])

    yAxis = d3.svg.axis().scale(@yScale)
                  .orient('left')
                  .ticks(4)

    xAxis = d3.svg.axis().scale(@xScale)
                  .ticks(3)

    @xAxisMarker
        .attr('transform', "translate(0, #{@height - @yPadding})")
        .call(xAxis)
    @yAxisMarker.call(yAxis)

    verticalPadding  = @$el.innerHeight() - @$el.height()
    horizontalPadding = @$el.innerWidth()  - @$el.width()

  renderGraph: ->
    @setupGraph() unless @svg
    @resize()

    z = d3.scale.category20c()
    Kearny.colorCounter ?= 0
    Kearny.colorCounter += 1

    area = d3.svg.area()
             .interpolate('basis')
             .x((d) => @xScale(d[1] * 1000))
             .y1((d) => @yScale(d[0]))
             .y0(@height - @yPadding)

    @svg.selectAll('path')
         .data(@model.get('data'), (d) -> d.target)
         .attr('d', (d) -> area(d.datapoints))
         .enter()
           .append('path').transition()
           .attr('d', (d) -> area(d.datapoints))
           .attr('fill', (_, i) -> z(i + Kearny.colorCounter))

    @$el.addClass('has-content')

Kearny.AppView = Backbone.View.extend
  el: '#kearny-main'
  gutters: 40
  minWidth: 300
  maxWidth: 500

  initialize: ->
    @dashboard = new Kearny.Dashboard(name: 'default')

Kearny.DataView = Backbone.View.extend
  defaultScale: 'day'
  defaultFormat: 'area'
  height: 400
  width: 600
  xPadding: 40
  yPadding: 20
  yAxisVisible: false

  initialize: ->
    @listenTo(@model, 'change:data', @render)
    @listenTo(@model, 'change:format', @renderGraph)
    @listenTo(@model, 'destroy', @remove)

  className: 'dataView'

  events:
    'dblclick' : 'fetchData'
    'click'    : 'cycleFormat'

  fetchData: -> @model.fetchData()

  getFormat: -> @model.get('format') || @defaultFormat
  cycleFormat: ->
    formats = _.keys(@generators)
    nextFormat = @getFormat()

    while (nextFormat == @getFormat())
      nextFormat = formats[Math.floor(Math.random() * formats.length)]

    @model.set('format', nextFormat)


  template: _.template($('#dataview-template').html())

