-
Notifications
You must be signed in to change notification settings - Fork 0
/
chart.js
64 lines (60 loc) · 1.26 KB
/
chart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*! js-charts-sdk
* Copyright (c) 2013 ChartBlocks
* Licensed under the MIT license.
* 2014-02-11 */
(function(window, document){
/**
*
* @param id chart ID
* @param options
* @returns chart
*/
var chart = function(id, options) {
this.initialize.apply(this, arguments);
return this;
};
/**
*
* @param {type} id
* @param {type} options
* @returns chart
*/
chart.prototype.initialize = function(id, options) {
this.id = id;
this.options = options;
return this;
};
/**
*
* @returns chart
*/
chart.prototype.render = function() {
var options = this.options, target, targets;
var iframe = this.iframe = document.createElement('iframe');
iframe.frameBorder = 0;
iframe.src = '//embed.chartblocks.com/1.0/?c=' + this.id;
iframe.width = options.width;
iframe.height = options.height;
if ((targets = document.querySelectorAll(options.target))) {
if (targets.length > 0) {
target = targets[0];
target.appendChild(iframe);
}
}
return this;
};
/**
*
* @type @exp;window@pro;CB
*/
var CB = window.CB = {
};
/**
*
* @param {type} id
* @param {type} options
* @returns chart
*/
CB.create = function(id, options) {
return new chart(id, options);
};})(window, document);