Skip to content

Instantly share code, notes, and snippets.

@vicentereig
Last active December 10, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicentereig/4433716 to your computer and use it in GitHub Desktop.
Save vicentereig/4433716 to your computer and use it in GitHub Desktop.
avoiding inline JS
$ = jQuery
class GoogleChartWrapper
@defaults = {}
constructor: (@$el, @options={}) ->
$.extend true, @options, @defaults, @$el.data()
@chart = new google.visualization.ChartWrapper options
@chart.draw()
$.fn.chartWrapper = (options={}) ->
@each ->
$el = $(@)
api = new GoogleChartWrapper($el, options)
$el.data('GoogleChartWrapper', $el)
$ = jQuery
$ ->
$('#iteration-visualization').chartWrapper
chartType: 'ColumnChart'
options:
title: 'Iteration Contents Charts'
isStacked: true
colors: ['#DFE32D','#A8CFFF', '#FF9797']
containerId: 'iteration-visualization'
#iteration-visualization{data: {dataTable: @dataTable.to_json.html_safe}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment