-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.flinkchart.js
More file actions
36 lines (35 loc) · 1.1 KB
/
jquery.flinkchart.js
File metadata and controls
36 lines (35 loc) · 1.1 KB
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
(function($) {
var name = "flinkCharts";
$.fn.flinkchart = function(optsOrMethod) {
return $(this).filter("canvas").each(function() {
if(!$.data(this, name)) {
if(optsOrMethod && $.type(optsOrMethod) !== "object") {
throw new Error("flinkCharts: invalid options format");
}
var type = null;
if($(this).data("chart")) {
type = $(this).data("chart");
} else if(optsOrMethod.chart) {
type = optsOrMethod.chart;
} else {
throw new Error("flinkCharts: no chart parameter given");
}
/**
* Add new chart types to this switch statement
*/
switch(type) {
case "line":
if(typeof $.fn.flinkchart.LineChart === "function") {
$.data(this, name, new $.fn.flinkchart.LineChart($(this), optsOrMethod));
}
break;
default:
throw new Error("flinkCharts: " + type + " is not a valid chart type");
break;
}
} else if($.isFunction($(this).data(name)[optsOrMethod])) {
$(this).data(name)[optsOrMethod]();
}
});
}
})(jQuery);