Skip to content

Commit dbbf85f

Browse files
committed
Fixed module injection for es6 addDep feature
1 parent 819488e commit dbbf85f

File tree

5 files changed

+135
-7
lines changed

5 files changed

+135
-7
lines changed

dist/README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# angular2-fusioncharts
2+
3+
## Installation
4+
5+
To install `angular2-fusioncharts` library, run:
6+
7+
```bash
8+
$ npm install angular2-fusioncharts --save
9+
```
10+
11+
And then in your Angular `AppModule`:
12+
13+
```typescript
14+
import { BrowserModule } from '@angular/platform-browser';
15+
import { NgModule } from '@angular/core';
16+
17+
import { AppComponent } from './app.component';
18+
19+
// Import angular2-fusioncharts
20+
import { FusionChartsModule } from 'angular2-fusioncharts';
21+
22+
// Import FusionCharts library and chart modules
23+
import * as FusionCharts from 'fusioncharts';
24+
import * as Charts from 'fusioncharts/fusioncharts.charts';
25+
import * as FintTheme from 'fusioncharts/themes/fusioncharts.theme.fint';
26+
27+
// Pass the fusioncharts library and chart modules
28+
FusionChartsModule.fcRoot(FusionCharts, Charts, FintTheme);
29+
30+
@NgModule({
31+
declarations: [
32+
AppComponent
33+
],
34+
imports: [
35+
BrowserModule,
36+
// Specify FusionChartsModule as import
37+
FusionChartsModule
38+
],
39+
providers: [],
40+
bootstrap: [AppComponent]
41+
})
42+
export class AppModule { }
43+
```
44+
45+
Once the library is imported, you can use its components, directives in your Angular application:
46+
47+
In your Angular AppComponent:
48+
49+
```javascript
50+
import {Component} from '@angular/core';
51+
52+
@Component({
53+
selector: 'my-app',
54+
templateUrl: './app.component.html'
55+
})
56+
export class AppComponent {
57+
dataSource: Object;
58+
title: string;
59+
60+
constructor() {
61+
this.title = "Angular 2 FusionCharts Sample";
62+
63+
this.dataSource = {
64+
"chart": {
65+
"caption": "Harry's SuperMart",
66+
"subCaption": "Top 5 stores in last month by revenue"
67+
},
68+
"data": [{
69+
"label": "Bakersfield Central",
70+
"value": "880000"
71+
}, {
72+
"label": "Garden Groove harbour",
73+
"value": "730000"
74+
}, {
75+
"label": "Los Angeles Topanga",
76+
"value": "590000"
77+
}, {
78+
"label": "Compton-Rancho Dom",
79+
"value": "520000"
80+
}, {
81+
"label": "Daly City Serramonte",
82+
"value": "330000"
83+
}]
84+
}
85+
}
86+
}
87+
```
88+
89+
90+
```xml
91+
<!-- You can now use fusioncharts component in app.component.html -->
92+
<h1>
93+
{{title}}
94+
</h1>
95+
<fusioncharts
96+
width="600"
97+
height="350"
98+
type="Column2D"
99+
dataFormat="JSON"
100+
[dataSource]="dataSource"
101+
></fusioncharts>
102+
```
103+
104+
## Development
105+
106+
To generate all `*.js`, `*.js.map` and `*.d.ts` files:
107+
108+
```bash
109+
$ npm run tsc
110+
```
111+
112+
To lint all `*.ts` files:
113+
114+
```bash
115+
$ npm run lint
116+
```
117+
### [Demos and Documentation](http://fusioncharts.github.io/angular2-fusioncharts/)

dist/src/fusioncharts.service.js

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/fusioncharts.service.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"ng": "ng",
66
"start": "ng serve",
77
"start-prod": "ng serve --prod",
8-
"build": "rm -rf dist/ && node_modules/.bin/ngc -p tsconfig-aot.json && rollup -c rollup.config.js && cp package-dist.json dist/package.json && npm run uglify",
8+
"build": "rm -rf dist/ && node_modules/.bin/ngc -p tsconfig-aot.json && rollup -c rollup.config.js && cp package-dist.json dist/package.json && cp README.md dist/ && npm run uglify",
99
"docs": "ng build --prod && npm run build",
1010
"test": "ng test",
1111
"lint": "ng lint",
@@ -81,7 +81,7 @@
8181
"rollup": "^0.45.2",
8282
"ts-node": "~3.0.4",
8383
"tslint": "~5.3.2",
84-
"typescript": "~2.3.3"
84+
"typescript": "2.9.2"
8585
},
8686
"engines": {
8787
"node": ">=4.4.1"

src/angular2-fusioncharts/src/fusioncharts.service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export class FusionChartsService {
3636
this.resolveFusionCharts(fcRoot.core, fcRoot.modules);
3737
}
3838

39+
40+
3941
resolveFusionCharts(core: any, modules: any[]) {
4042
if (core && core.id &&
4143
core.id === 'FusionCharts') {
@@ -46,7 +48,11 @@ export class FusionChartsService {
4648

4749
if (modules) {
4850
modules.forEach((FusionChartsModules: any) => {
49-
FusionChartsModules(core);
51+
if (FusionChartsModules.getName || FusionChartsModules.name) {
52+
core.addDep(FusionChartsModules);
53+
} else {
54+
FusionChartsModules(core);
55+
}
5056
});
5157
}
5258
}

0 commit comments

Comments
 (0)