Skip to content

Commit 5f3dafa

Browse files
committed
Initial checkin separating src and demobrowser
0 parents  commit 5f3dafa

File tree

4 files changed

+162
-0
lines changed

4 files changed

+162
-0
lines changed

.gitignore

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# Compiled binary addons (http://nodejs.org/api/addons.html)
20+
build/Release
21+
22+
# Dependency directory
23+
# Commenting this out is preferred by some people, see
24+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
25+
node_modules
26+
27+
# Users Environment Variables
28+
.lock-wscript
29+
30+
.DS_Store

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 FusionCharts Technologies
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
angular-fusioncharts
2+
====================
3+
4+
Angular JS Bindings for FusionCharts

src/ng-fusioncharts.js

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
(function () {
2+
var fc = angular.module('ngFusionCharts', []);
3+
4+
5+
fc.directive('fcChart', function ($http) {
6+
return {
7+
scope: {
8+
fcWidth: '@',
9+
fcHeight: '@',
10+
fcDataset: '@',
11+
fcCategories: '@',
12+
fcChartAttrs: '@',
13+
fcChartClick: '@'
14+
},
15+
link: function (scope, element, attrs) {
16+
var chart = null,
17+
events = {
18+
chartClick: function (ev, props) {
19+
if(attrs.fcChartClick) {
20+
scope.$parent[attrs.fcChartClick](ev, props);
21+
}
22+
}
23+
};
24+
if(attrs.fcConfig) {
25+
chart = new FusionCharts(scope[attrs.fcConfig]);
26+
scope[attrs.fcChartObject] = chart;
27+
chart.render ();
28+
} else if(attrs.fcJsonUrl) {
29+
$http.get(attrs.fcJsonUrl)
30+
.success(function (data) {
31+
data.renderAt = element[0];
32+
chart = new FusionCharts(data);
33+
scope[attrs.fcChartObject] = chart;
34+
chart.render ();
35+
})
36+
.error(function (err) {
37+
throw err;
38+
});
39+
} else {
40+
var chartConfigObject = {
41+
type: attrs.fcType,
42+
width: attrs.fcWidth,
43+
height: attrs.fcHeight,
44+
renderAt: element[0],
45+
dataFormat: attrs.fcDataFormat || 'json',
46+
dataSource: {},
47+
events: events
48+
};
49+
attrs.$observe('fcWidth', function (newVal) {
50+
chart.resizeTo (scope.fcWidth, scope.fcHeight);
51+
});
52+
attrs.$observe('fcHeight', function (newVal) {
53+
chart.resizeTo (scope.fcWidth, scope.fcHeight);
54+
});
55+
56+
if(attrs.fcDatasource) {
57+
chartConfigObject.dataSource = scope[attrs.fcDatasource];
58+
attrs.$observe('fcDatasource', function (newVal) {
59+
chart.setJSONData (JSON.parse(newVal));
60+
}, true);
61+
} else {
62+
// chartConfigObject.dataSource.chart = scope[attrs.fcChartAttrs];
63+
attrs.$observe('fcChartAttrs', function (newVal) {
64+
setTimeout(function () {
65+
chartConfigObject.dataSource.chart = JSON.parse(newVal);
66+
chart.setJSONData (chartConfigObject.dataSource);
67+
}, 0);
68+
}, true)
69+
if(attrs.fcData) {
70+
// chartConfigObject.data = scope[attrs.fcData];
71+
attrs.$observe('fcData', function (newVal) {
72+
setTimeout(function () {
73+
chartConfigObject.dataSource.data = JSON.parse(newVal);
74+
chart.setJSONData (chartConfigObject.dataSource);
75+
}, 0);
76+
}, true);
77+
}
78+
if(attrs.fcCategories) {
79+
// chartConfigObject.dataSource.categories = scope[attrs.fcCategories];
80+
attrs.$observe('fcCategories', function (newVal) {
81+
setTimeout(function () {
82+
chartConfigObject.dataSource.categories = JSON.parse(newVal);
83+
chart.setJSONData (chartConfigObject.dataSource);
84+
}, 0);
85+
}, true);
86+
}
87+
if(attrs.fcDataset) {
88+
// chartConfigObject.dataSource.dataset = scope[attrs.fcDataset];
89+
attrs.$observe('fcDataset', function (newVal) {
90+
setTimeout(function () {
91+
chartConfigObject.dataSource.dataset = JSON.parse(newVal);
92+
chart.setJSONData (chartConfigObject.dataSource);
93+
});
94+
}, true);
95+
}
96+
97+
}
98+
99+
var chart = new FusionCharts(chartConfigObject);
100+
scope[attrs.fcChartObject] = chart;
101+
chart.render ();
102+
}
103+
}
104+
}
105+
});
106+
}());

0 commit comments

Comments
 (0)