keenlabs/keen-js — pull request #143 by forivall (2014-08-18 22:09:38+00:00)
Title: expose constructor for simpler coffeescript / es6 extension

Allows plugins to be written in coffeescript (or es6 classes) natively:

Example (could be used with an extraction):

module.exports = class Histogram extends Keen.BaseVisualization
initialize: -> @render()
render: ->
@_chart = new google.visualization.Histogram(@el)
google.visualization.events.addListener(@_chart, 'error', @handleErrors)
@update()
update: ->
data = google.visualization.arrayToDataTable(@data.table)
options = Keen.utils.extend(@chartOptions, {
title: @title or ''
height: parseInt(@height)
width: parseInt(@width)
colors: @colors
})
@_chart.draw(data, options)
handleErrors: (stack) =>
message = stack['message'] || "An error occurred"
@trigger('error', message)

Keen.Visualization.register('google', {
'histogram' : Histogram
})