Accept DOM element in options.element (closes #11).

This commit is contained in:
Olly Smith 2012-02-28 22:00:08 +00:00
parent dc0a34dcbb
commit 0453724887
3 changed files with 10 additions and 3 deletions

View File

@ -8,7 +8,10 @@ class Morris.Line
constructor: (options) ->
if not (this instanceof Morris.Line)
return new Morris.Line(options)
@el = $ document.getElementById(options.element)
if typeof options.element is 'string'
@el = $ document.getElementById(options.element)
else
@el = $ options.element
@options = $.extend {}, @defaults, options
# bail if there's no data
if @options.data is undefined or @options.data.length is 0

View File

@ -7,7 +7,11 @@
function Line(options) {
if (!(this instanceof Morris.Line)) return new Morris.Line(options);
this.el = $(document.getElementById(options.element));
if (typeof options.element === 'string') {
this.el = $(document.getElementById(options.element));
} else {
this.el = $(options.element);
}
this.options = $.extend({}, this.defaults, options);
if (this.options.data === void 0 || this.options.data.length === 0) return;
this.el.addClass('graph-initialised');

2
morris.min.js vendored

File diff suppressed because one or more lines are too long