This repository has been archived by the owner on Sep 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
53 lines (46 loc) · 1.69 KB
/
index.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
/**
* NOTE: this file is used purely to demo the code
*/
/**
* @global addEventHandler
* @required @param {HTML Object} elem = the html element that you wish to target
* @required @param {String} eventType = the event that you want the action to occur on
* @required @param {Function} handler = the callback function
*/
var addEventHandler = function(elem, eventType, handler) {
if (elem.addEventListener)
elem.addEventListener(eventType, handler, false);
else if (elem.attachEvent)
elem.attachEvent('on' + eventType, handler);
};
/**
* @global ready
* @required @param {Function} clalback = the clalback function
* NOTE: Shorter than writing $(document).ready(function....), however, feel free to delete this code
* @return {Function}
*/
window.ready = function(callBack) {
try {
setTimeout(addEventHandler(document, "DOMContentLoaded", callBack), 20);
} catch (e) {
addEventHandler(document, "DOMContentLoaded", callBack);
console.log(e.message);
}
};
/**
* @global
* NOTE: this is just an example - Feel free to delete this code
*/
var example = ready(function(){
var chartData = [
[10,10,12,13,16,20,23,24,22,18,13,11],
[65,59,10,81,56,55,40,120,50,70,90,40],
[65,33,-28,20,-56,105,90,10,50,30,80,4]
];
var chartLabels = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
var divs = document.getElementsByClassName("demo");
var select = document.getElementById("demo");
var dc = new DynamicChart(chartData, chartLabels);
dc.showChart("chart", "click", divs, "data-value");
dc.showChart("chart", "change", select, "value", select.selectedIndex);
});