Sha256: 48af3c5df04226d745a34f71053f78badf4ad566361b4c65399aedc06d67af72

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

class WidgetPresenter
	constructor: (@pageInfos, @model, el) ->
		chartClass = @chartClass()
		@chart = new chartClass(el)
		@draw()

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

	globalOptions: -> gon.options

	dateOffset: ->
		if @globalOptions.useUtc
			(new Date).getTimezoneOffset() * 60000
		else
			0
	
	options: ->
		{
			title: @get('title')
			height: 300
			chartArea:
				left: 10
		}

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

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

	data: -> new google.visualization.DataTable

	chartClass: -> google.visualization[@visualization]

	cutoff: ->
	
	cutoffValue: (v, min, max) ->
		if v?
			if min? && v < min
				min
			else if max? && v > max
				max
			else
				v
		else
			0

	draw: (min, max) ->
		@cutoff(min, max)
		@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

4 entries across 4 versions & 1 rubygems

Version Path
pulse_meter_visualizer-0.4.22 lib/pulse_meter/visualize/coffee/presenters/widget.coffee
pulse_meter_visualizer-0.4.21 lib/pulse_meter/visualize/coffee/presenters/widget.coffee
pulse_meter_visualizer-0.4.20 lib/pulse_meter/visualize/coffee/presenters/widget.coffee
pulse_meter_visualizer-0.4.19 lib/pulse_meter/visualize/coffee/presenters/widget.coffee