22
33## Installation
44
5- To install this library, run:
5+ To install ` angular2-fusioncharts ` library, run:
66
77``` bash
88$ npm install angular2-fusioncharts --save
99```
1010
11- and then from your Angular ` AppModule ` :
11+ And then in your Angular ` AppModule ` :
1212
1313``` typescript
1414import { BrowserModule } from ' @angular/platform-browser' ;
1515import { NgModule } from ' @angular/core' ;
1616
1717import { AppComponent } from ' ./app.component' ;
1818
19- // Import your library
20- import { FusionChartsComponent } from ' angular2-fusioncharts' ;
19+ // Import angular2-fusioncharts
20+ import { FusionChartsModule } from ' angular2-fusioncharts' ;
21+
22+ // Import FusionCharts library
23+ import * as FusionCharts from ' fusioncharts' ;
24+ // Import FusionCharts Charts module
25+ import * as Charts from ' fusioncharts/fusioncharts.charts' ;
2126
2227@NgModule ({
2328 declarations: [
@@ -26,20 +31,63 @@ import { FusionChartsComponent } from 'angular2-fusioncharts';
2631 ],
2732 imports: [
2833 BrowserModule ,
29-
30- // Specify your library as an import
31- LibraryModule
34+ // Specify FusionChartsModule as an import
35+ // and pass FusionCharts and Charts as a dependency
36+ FusionChartsModule . forRoot ( FusionCharts , Charts ),
3237 ],
3338 providers: [],
3439 bootstrap: [AppComponent ]
3540})
3641export class AppModule { }
3742```
3843
39- Once your library is imported, you can use its components, directives and pipes in your Angular application:
44+ Once the library is imported, you can use its components, directives in your Angular application:
45+
46+ In your Angular AppComponent:
47+
48+ ``` javascript
49+ import {Component } from ' @angular/core' ;
50+
51+ @Component ({
52+ selector: ' my-app' ,
53+ templateUrl: ' ./app.component.html'
54+ })
55+ export class AppComponent {
56+ dataSource: Object ;
57+ title: string;
58+
59+ constructor () {
60+ this .title = " Angular 2 FusionCharts Sample" ;
61+
62+ this .dataSource = {
63+ " chart" : {
64+ " caption" : " Harry's SuperMart" ,
65+ " subCaption" : " Top 5 stores in last month by revenue"
66+ },
67+ " data" : [{
68+ " label" : " Bakersfield Central" ,
69+ " value" : " 880000"
70+ }, {
71+ " label" : " Garden Groove harbour" ,
72+ " value" : " 730000"
73+ }, {
74+ " label" : " Los Angeles Topanga" ,
75+ " value" : " 590000"
76+ }, {
77+ " label" : " Compton-Rancho Dom" ,
78+ " value" : " 520000"
79+ }, {
80+ " label" : " Daly City Serramonte" ,
81+ " value" : " 330000"
82+ }]
83+ }
84+ }
85+ }
86+ ```
4087
88+
4189``` xml
42- <!-- You can now use your library component in app.component.html -->
90+ <!-- You can now use fusioncharts component in app.component.html -->
4391<h1 >
4492 {{title}}
4593</h1 >
@@ -48,35 +96,7 @@ Once your library is imported, you can use its components, directives and pipes
4896 height =" 350"
4997 type =" Column2D"
5098 dataFormat =" JSON"
51- dataSource =`{
52- " chart" : {
53- " caption" : " Harry's SuperMart" ,
54- " subCaption" : " Top 5 stores in last month by revenue"
55- },
56- " data" : [
57- {
58- " label" : " Bakersfield Central" ,
59- " value" : " 880000"
60- },
61- {
62- " label" : " Garden Groove harbour" ,
63- " value" : " 730000"
64- },
65- {
66- " label" : " Los Angeles Topanga" ,
67- " value" : " 590000"
68- },
69- {
70- " label" : " Compton-Rancho Dom" ,
71- " value" : " 520000"
72- },
73- {
74- " label" : " Daly City Serramonte" ,
75- " value" : " 330000"
76- }
77- ]
78- }
79- `
99+ [dataSource]=" dataSource"
80100></fusioncharts >
81101```
82102
0 commit comments