<!DOCTYPE html>
<html>
<head>
<base href="." />
<title>Angular2 playground - FusionCharts</title>
<link rel="stylesheet" href="style.css" />
<script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js/dist/zone.js"></script>
<script src="https://unpkg.com/zone.js/dist/long-stack-trace-zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script>
<script src="https://unpkg.com/systemjs@0.19.31/dist/system.js"></script>
<script src="config.js"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
<h1>Creating your Chart in Angular using <i>FusionCharts</i>!</h1>
</my-app>
</body>
</html>
/* Styles go here */
h1 {
display: block;
font-size: 3em;
margin-top: 3.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
font-family:Roboto;
color:#2c7fb2;
text-align:center;
}
### FusionCharts Angular 2 Example
System.config({
//use typescript for compilation
transpiler: 'ts',
// transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
"target": "es5",
"module": "commonjs",
"experimentalDecorators": true
},
meta: {
'typescript': {
"exports": "ts"
}
},
paths: {
'npm:': 'https://unpkg.com/',
'git:': 'https://rawgit.com/'
},
//map tells the System loader where to look for things
map: {
'app': './src',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'rxjs': 'npm:rxjs',
'typescript': 'npm:typescript@2.0.2/lib/typescript.js',
'ts': 'npm:plugin-typescript@7.0.6 /lib/plugin.js',
'fusioncharts': 'npm:fusioncharts/',
'angular2-fusioncharts': 'npm:angular2-fusioncharts/dist/'
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
},
fusioncharts: {
main: './fusioncharts.js',
defaultExtension: 'js'
},
'angular2-fusioncharts': {
main: './index.js',
defaultExtension: 'js'
}
}
});
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './module';
platformBrowserDynamic().bootstrapModule(AppModule)
//our root app component
import {Component, NgModule} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
@Component({
selector: 'my-app',
template: `<fusioncharts
width="100%"
height="450"
type="stackedcolumn2d"
dataFormat="json"
[dataSource]=dataSource >
</fusioncharts>
`,
})
export class App {
demoId: string;
constructor() {
this.demoId = "ex1";
this.dataSource = {
chart: {
"caption": "Quarterly expenditure",
"subCaption": "",
"xAxisname": "Quarter",
"yAxisName": "Expenditure (In USD)",
"numberPrefix": "$",
"baseFont": "Roboto",
"baseFontSize": "14",
"labelFontSize": "15",
"captionFontSize": "20",
"subCaptionFontSize": "16",
"paletteColors": "#2c7fb2,#6cc184,#fed466",
"bgColor": "#ffffff",
"borderAlpha": "20",
"showCanvasBorder": "0",
"usePlotGradientColor": "0",
"plotBorderAlpha": "10",
"legendBorderAlpha": "0",
"legendShadow": "0",
"valueFontColor": "#ffffff",
"showXAxisLine": "1",
"xAxisLineColor": "#999999",
"divlineColor": "#999999",
"divLineIsDashed": "1",
"showAlternateHGridColor": "0",
"subcaptionFontBold": "0",
"subcaptionFontSize": "14",
"showHoverEffect": "1"
},
"categories": [{
"category": [{
"label": "Q1"
}, {
"label": "Q2"
}, {
"label": "Q3"
}, {
"label": "Q4"
}]
}],
"dataset": [{
"seriesname": "Marketing",
"data": [{
"value": "121000"
}, {
"value": "135000"
}, {
"value": "123500"
}, {
"value": "145000"
}]
}, {
"seriesname": "Management",
"data": [{
"value": "190000"
}, {
"value": "195000"
}, {
"value": "187000"
}, {
"value": "190000"
}]
}, {
"seriesname": "Operations",
"data": [{
"value": "225000"
}, {
"value": "260000"
}, {
"value": "245000"
}, {
"value": "250000"
}]
}]
};
}
}
//our root app component
import {NgModule} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import {App} from './app'
// Fix for "Expression has changed after it was checked. Previous value: container-"
import {enableProdMode} from '@angular/core'
enableProdMode();
import {FusionChartsModule} from 'angular2-fusioncharts';
// Load FusionCharts
import * as FusionCharts from 'fusioncharts';
// Load charts module
import * as Charts from 'fusioncharts/fusioncharts.charts';
// Load Ocean theme
import * as Fint from 'fusioncharts/themes/fusioncharts.theme.fint';
@NgModule({
imports: [
BrowserModule,
FusionChartsModule.forRoot(FusionCharts, Charts, Fint)
],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule {}