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-2.js
76 lines (66 loc) · 2.43 KB
/
index-2.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
65
66
67
68
69
70
71
72
73
74
75
76
/**
* 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 tempData = [
[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 rainData = [
[65,33,-28,20,-56,105,90,10,50,30,80,4],
[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 combineData = [tempData, rainData];
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 rainData = {
type:'line',
label: "Rain in MM",
backgroundColor: "rgba(102, 194, 255, 0.25)",
borderColor: "rgba(102, 194, 255, 0.75)",
borderWidth: 1,
hoverBackgroundColor: "rgba(102, 194, 255, 0)",
hoverBorderColor: "rgba(102, 194, 255, 0.9)",
data:[]
};
var dc = new DynamicChart(combineData, chartLabels);
dc.showChart("chart", "click", divs, "data-value", 0, rainData);
dc.showChart("chart", "change", select, "value", select.selectedIndex, rainData);
var dcData = dc.getData();
var dcOPts = dc.getOptions();
var dcDataSets = dcData.datasets;
var lineChart = dcDataSets;
});