Spline Area in Angular Chart component
13 Dec 202424 minutes to read
Spline Area
To render a spline area series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:
-
Set the series type: Define the series
type
asSplineArea
in your chart configuration. This indicates that the data should be represented as a spline area chart, where data points are connected by smooth, curved lines (splines) instead of straight lines. -
Inject the SplineAreaSeries module: Use the
@NgModule.providers
method to inject theSplineAreaSeriesService
module into your chart. This step is essential, as it ensures that the necessary functionalities for rendering spline area series are available in your chart.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public marker?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: true, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: 8 },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: 16 },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
Binding data with series
You can bind data to the chart using the dataSource
property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName
and yName
properties.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public marker?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: true, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: 8 },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: 16 },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
Series customization
The following properties can be used to customize the spline area
series.
Fill
The fill property determines the color applied to the series.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker' fill='yellow'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public marker?: Object;
border?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: false, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: 8 },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: 16 },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
The fill property can be used to apply a gradient color to the spline area series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker' fill='url(#gradient)'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public marker?: Object;
border?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: false, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: 8 },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: 16 },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
Opacity
The opacity property specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker' opacity='0.5'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public marker?: Object;
border?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: false, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: 8 },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: 16 },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
Border
Use the border property to customize the width, color and dasharray of the series border.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker' [border]='border'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public marker?: Object;
public border?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.border = {
width: 2, color: 'red', dashArray='5,5'
};
this.marker = { visible: false, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: 8 },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: 16 },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
Empty points
Data points with null
or undefined
values are considered empty. Empty data points are ignored and not plotted on the chart.
Mode
Use the mode
property to define how empty or missing data points are handled in the series. The default mode for empty points is Gap
.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker' [emptyPointSettings]='emptyPointSettings'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public emptyPointSettings?: Object;
public marker?: Object;
border?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: true, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
this.emptyPointSettings= {
mode: 'Gap'
}
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: null },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: undefined },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
Fill
Use the fill
property to customize the fill color of empty points in the series.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker' [emptyPointSettings]='emptyPointSettings'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public emptyPointSettings?: Object;
public marker?: Object;
border?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: true, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
this.emptyPointSettings= {
mode: 'Average', fill: 'red'
}
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: null },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: undefined },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
Border
Use the border
property to customize the width and color of the border for empty points.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker' [emptyPointSettings]='emptyPointSettings'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public emptyPointSettings?: Object;
public marker?: Object;
border?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: true, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
this.emptyPointSettings= {
mode: 'Average', fill: 'red', border: {width: 2, color: 'green'}
}
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: null },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: undefined },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
Events
Series render
The seriesRender
event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { ISeriesRenderEventArgs } from '@syncfusion/ej2-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" (seriesRender)='seriesRender($event)' [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public marker?: Object;
border?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: false, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
}
public seriesRender(args: ISeriesRenderEventArgs){
args.fill = '#ff6347';
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: 8 },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: 16 },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];
Point render
The pointRender
event allows you to customize each data point before it is rendered on the chart.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { IPointRenderEventArgs } from '@syncfusion/ej2-charts'
import { CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { chartData } from './datasource';
@Component({
imports: [
ChartModule
],
providers: [ CategoryService, LineSeriesService, StepLineSeriesService, SplineSeriesService, StackingLineSeriesService, DateTimeService,
SplineAreaSeriesService, MultiColoredLineSeriesService, ParetoSeriesService, ColumnSeriesService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" (pointRender)='pointRender($event)' [primaryXAxis]='primaryXAxis' [title]='title'>
<e-series-collection>
<e-series [dataSource]='chartData' type='SplineArea' xName='x' yName='y' name='London' width=2 [marker]='marker'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public primaryYAxis?: Object;
public marker?: Object;
border?: Object;
ngOnInit(): void {
this.chartData = chartData;
this.primaryXAxis = {
title: 'Month',
valueType: 'Category'
};
this.marker = { visible: true, width: 10, height: 10 };
this.title = 'Climate Graph-2012';
}
public pointRender(args: IPointRenderEventArgs){
args.fill = 'red';
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
export let chartData: Object[] = [
{ x: 'Jan', y: -1 },
{ x: 'Feb', y: -1 },
{ x: 'Mar', y: 2 },
{ x: 'Apr', y: 8 },
{ x: 'May', y: 13 },
{ x: 'Jun', y: 18 },
{ x: 'Jul', y: 21 },
{ x: 'Aug', y: 20 },
{ x: 'Sep', y: 16 },
{ x: 'Oct', y: 10 },
{ x: 'Nov', y: 4 },
{ x: 'Dec', y: 0 }
];