Sha256: 245790640a07d07f0f575a661a9099ab8aefb2533881476b6cedf22c8867b5e7

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

class WidgetPresenter
	constructor: (@pageInfos, @model, @el) ->
		@chartEl = @el.find('#chart')[0]
		@legendEl = @el.find('#legend')[0]
		@chart = new Dygraph.GVizChart(@chartEl)
		@draw()

	get: (arg) -> @model.get(arg)

	globalOptions: -> gon.options

	dateOffset: ->
		if @globalOptions.useUtc
			(new Date).getTimezoneOffset() * 60000
		else
			0
	
	options: -> {
		labelsDiv: @legendEl
		labelsSeparateLines: false
		rightGap: 30
		highlightCircleSize: 2

		highlightSeriesOpts:
			strokeWidth: 2
			strokeBorderWidth: 1
			highlightCircleSize: 5
	}

	mergedOptions: ->
		pageOptions = if @pageInfos.selected()
			@pageInfos.selected().get('dygraphsOptions')
		else
			{}

		$.extend(true,
			@options(),
			@globalOptions().dygraphsOptions,
			pageOptions,
			@get('dygraphsOptions')
		)

	data: -> new google.visualization.DataTable

	draw: ->
		@chart.draw @data(), @mergedOptions()

WidgetPresenter.create = (pageInfos, model, el) ->
	type = model.get('type')
	if type? && type.match(/^\w+$/)
		presenterClass = eval("#{type.capitalize()}Presenter")
		new presenterClass(pageInfos, model, el)
	else
		null

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pulse_meter-dygraphs_visualizer-0.4.21 lib/pulse_meter/dygraphs_visualize/coffee/presenters/widget.coffee
pulse_meter-dygraphs_visualizer-0.4.20 lib/pulse_meter/dygraphs_visualize/coffee/presenters/widget.coffee
pulse_meter-dygraphs_visualizer-0.4.19 lib/pulse_meter/dygraphs_visualize/coffee/presenters/widget.coffee
pulse_meter-dygraphs_visualizer-0.4.18 lib/pulse_meter/dygraphs_visualize/coffee/presenters/widget.coffee
pulse_meter-dygraphs_visualizer-0.4.17 lib/pulse_meter/dygraphs_visualize/coffee/presenters/widget.coffee