Sha256: 6a07c8357c3c367e26921999f2a81063d19eeb8e7fdd9fa9c00b0e6d8979b6f5

Contents?: true

Size: 879 Bytes

Versions: 9

Compression:

Stored size: 879 Bytes

Contents

ELA.Views ?= {}

class ELA.Views.ChartView extends ELA.Views.ViewportView
  initialize: (options = {}) ->
    unless options.name?
      throw 'ELA.Views.GraphView: option `name` is required'

    if options.chart?.view
      @ChartView = options.chart.view.toFunction()
    else
      @ChartView = ELA.Views.ChartJS
    @displayParams = @model.displayParams[options.name] = new @ChartView.Params

    @chartConfig = $.extend(true, {}, options.chart?.config)
    @chartDataFunction = options.chart?.dataFunction or 'data'

    @subviews = {}

  render: =>
    $chart = $('<div>', class: 'chart')
    view = @subviews.chart ?= new @ChartView
      model: @model
      parentView: this
      localePrefix: @localePrefix
      params: @displayParams
      dataFunction: @chartDataFunction
      config: @chartConfig

    $chart.html(view.render().el)
    @$el.html($chart)
    this

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ela-3.4.3 app/js/lib/views/chart_view.coffee
ela-3.4.2 app/js/lib/views/chart_view.coffee
ela-3.4.0 app/js/lib/views/chart_view.coffee
ela-3.3.1 app/js/lib/views/chart_view.coffee
ela-3.3.0 app/js/lib/views/chart_view.coffee
ela-3.2.0 app/js/lib/views/chart_view.coffee
ela-3.1.1 app/js/lib/views/chart_view.coffee
ela-3.1.0 app/js/lib/views/chart_view.coffee
ela-3.0.0 app/js/lib/views/chart_view.coffee