@chartOptions @model.getOptions(), {+silent}
@loadData()
- onReady: ->
- return if @ready
- @triggerReady()
- @onSync()
### Chart Options Tab, Scaffold
@scaffold = @addSubview new ChartOptionScaffold
- # @scaffold.collection.reset that if o.graph_spec
- # @scaffold.on 'change', @onScaffoldChange
- @chartType.on 'ready', @onChartTypeReady
### Graph Data UI
@loadData()
onChartTypeReady: ->
- @scaffold.collection.reset @chartType.options_ordered
+ @scaffold.collection.reset @model.chartType.options_ordered
@scaffold.on 'change', @onScaffoldChange
@chartOptions @model.getOptions(), {+silent}
return if @ready
console.log "(#this via GraphEditView).ready!"
@unwait() # clears `wait()` from `initialize`
- # @ready = @scaffold.ready = true
+ @model.chartType.on 'ready', @onChartTypeReady
@triggerReady()
@scaffold.triggerReady()
@chartOptions @model.getOptions(), {+silent}
attributes.options or= {}
attributes.slug or= attributes.id if attributes.id?
@optionCascade = new Cascade attributes.options
+ @on 'change:chartType', ~> @chartType = ChartType.create this
BaseModel.call this, attributes, opts
@constructor.register this
@parents = new GraphList
- @chartType = ChartType.create this
# Insert submodels in place of JSON
@dataset = new DataSet {id:@id, ...@get 'data'}
initialize : (o={}) ->
@model or= new Graph
@id = @graph_id = _.domize 'graph', (@model.id or @model.get('slug') or @model.cid)
- @chartType = @model.chartType.withView this
GraphView.__super__.initialize ...
for name of @__debounce__
@wait()
Seq()
.seq_ (next) ~>
- @chartType.once 'ready', next.ok
- .seq_ (next) ~>
@model.once 'ready', next.ok .load()
.seq_ (next) ~>
+ @model.chartType.once 'ready', next.ok
+ .seq_ (next) ~>
@model.once 'data-ready', next.ok .loadData()
.seq ~>
@unwait()
@onReady()
+ onReady: ->
+ return if @ready
+ @triggerReady()
+ @onSync()
### Persistence {{{
if callout = @model.getCalloutData()
{year:yoy, month:mom} = callout
attrs.callout =
- latest : @chartType.numberFormatter(callout.latest, 2, false).toString()
+ latest : @model.chartType.numberFormatter(callout.latest, 2, false).toString()
year :
dates : yoy.dates.map( -> moment(it).format('MMM YY') ).join(' — ')
value : ( 100 * yoy.value[2] / yoy.value[0] ).toFixed(2) + '%'
* Resize the viewport to the model-specified bounds.
*/
resizeViewport: ->
- @chartType.resizeViewport()
+ @model.chartType?.withView(this).resizeViewport()
/**
* Redraw chart inside viewport.
*/
renderChart: ->
- @chart = @chartType.render()
+ @chart = @model.chartType?.withView(this).render()
this
/**