|
| 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/) |
0 commit comments