import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
// import the ChartModule for the Chart component
import { ChartModule, LineSeriesService, TooltipService, ZoomService} from '@syncfusion/ej2-ng-charts';
import { AppComponent } from './app.component';
@NgModule({
// declaration of ej2-ng-charts module into NgModule
imports: [ BrowserModule, ChartModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ],
// Injecting the required services for the chart
providers: [LineSeriesService, TooltipService, ZoomService]
})
export class AppModule { } |
import { Component, ViewEncapsulation } from '@angular/core';
import { TooltipSettingsModel, ZoomSettingsModel} from '@syncfusion/ej2-ng-charts';
@Component({
selector: 'app-container',
// specifies the template string for the Charts component
template:
`<ej-chart id='chartcontainer' style="display: block;" [tooltip]='tootip' [zoomSettings]='zoom'>
<e-series-collection>
<e-series [dataSource]='data' fill="#E56590" type='Line' xName='x' yName='y'>
</e-series>
</e-series-collection>
</ej-chart>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
public data: Object[] = [
{ x: 2005, y: 28 }, { x: 2006, y: 25 }, { x: 2007, y: 26 }, { x: 2008, y: 27 },
{ x: 2009, y: 32 }, { x: 2010, y: 35 }, { x: 2011, y: 30 }
];
public tootip: TooltipSettingsModel = {
enable: true,
};
public zoom: ZoomSettingsModel = {
enableSelectionZooming: true
};
} |